Skip to content

GODRIVER-4154 Fix correctness bugs in the benchmark harness. - #2621

Open
matthewdale wants to merge 1 commit into
mongodb:masterfrom
matthewdale:godriver4154-fix-bench
Open

matthewdale wants to merge 1 commit into
mongodb:masterfrom
matthewdale:godriver4154-fix-bench

Conversation

@matthewdale

@matthewdale matthewdale commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

GODRIVER-4154

Summary

Bugs fixed:

  • Fix benchmarkSingleInsert so it use the source parameter to load the fixture data instead of hard-coding the smallData file.
    • Previously BenchmarkLargeDocInsertOne used the smallData fixture, making the results identical to BenchmarkSmallDocInsertOne.
  • Call ResetTimer before starting the benchmark loop in benchmarkSingleInsert so the benchmark doesn't try to measure the test setup phase.
  • Replace the buggy testdataDir func with a relative path constant.
    • File paths are always evaluated relative to the package directory, so there's no need to dynamically determine the "testdata" dir.
  • setupBench never calls the CancelFunc for the Context used to Ping.
  • Fix the broken "benchmark" task in the Taskfile.

Improvements:

  • Download the benchmark fixtures in TestMain so they're downloaded independent of how the benchmarks are run.

Background & Motivation

While experimenting with ways to reduce noise in the PR benchmark data, Claude found a number of bugs in the existing benchmark code.

@github-actions github-actions Bot added the review-priority-normal Medium Priority PR for Review: within 1 business day label Sep 18, 2026
@mongodb-drivers-pr-bot

Copy link
Copy Markdown
Contributor

API Change Report

No changes found!

@matthewdale
matthewdale force-pushed the godriver4154-fix-bench branch from c01c887 to acda99e Compare September 18, 2026 03:51
@mongodb-drivers-pr-bot

mongodb-drivers-pr-bot Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

🧪 Performance Results

Commit SHA: 9b39f80

The following benchmark tests for version 6aaddab6430f68000743dde6 had statistically significant changes (i.e., |z-score| > 1.96):

Benchmark Measurement % Change Patch Value Stable Region H-Score Z-Score
BenchmarkLargeDocInsertOne allocated_bytes_per_op 389351.4068 22248334.0000 Avg: 5712.7368
Med: 5712.0000
Stdev: 2.0360
1.0000 10924934.8493
BenchmarkLargeDocInsertOne ns_per_op 18586.6475 33350085.0000 Avg: 178470.1348
Med: 178076.5000
Stdev: 4584.6788
0.9999 7235.3192
BenchmarkLargeDocInsertOne total_bytes_allocated 1725.6994 689698376.0000 Avg: 37777213.9070
Med: 37875316.0000
Stdev: 1285596.2542
0.9990 507.0963
BenchmarkLargeDocInsertOne ops_per_second_med -99.4867 30.1127 Avg: 5866.6496
Med: 5874.9492
Stdev: 141.3304
0.9863 -41.2971
BenchmarkLargeDocInsertOne ops_per_second_max -99.4602 34.6424 Avg: 6417.5832
Med: 6412.0033
Stdev: 135.9278
0.9880 -46.9583
BenchmarkLargeDocInsertOne total_mem_allocs -99.2466 3657.0000 Avg: 485430.1337
Med: 486963.0000
Stdev: 16515.2821
0.9825 -29.1714
BenchmarkLargeDocInsertOne ops_per_second_min -98.4665 23.9229 Avg: 1559.9754
Med: 1630.0104
Stdev: 293.7671
0.9023 -5.2288
BenchmarkLargeDocInsertOne total_time_seconds -12.5616 1.0339 Avg: 1.1824
Med: 1.1826
Stdev: 0.0269
0.9062 -5.5180
BenchmarkMultiInsertSmallDocument total_mem_allocs 12.4411 2640890.0000 Avg: 2348688.1631
Med: 2307333.0000
Stdev: 147167.2145
0.7527 1.9855
BenchmarkMultiInsertSmallDocument total_bytes_allocated 8.7934 499363840.0000 Avg: 459002159.6312
Med: 455619444.0000
Stdev: 18657138.7105
0.7657 2.1633
BenchmarkSingleFindOneByID ops_per_second_med -6.8782 4063.5210 Avg: 4363.6643
Med: 4379.0890
Stdev: 142.8575
0.7948 -2.1010
BenchmarkSingleFindOneByID ops_per_second_max -6.1805 4610.8447 Avg: 4914.5904
Med: 4943.4958
Stdev: 126.7364
0.7985 -2.3967
BenchmarkMultiInsertLargeDocument ns_per_op 6.1704 31288095.0000 Avg: 29469707.9055
Med: 29429670.0000
Stdev: 865209.7076
0.7475 2.1017
BenchmarkSmallDocInsertOne total_bytes_allocated -5.9677 35412536.0000 Avg: 37659977.6889
Med: 37735116.0000
Stdev: 979458.1726
0.7598 -2.2946
BenchmarkSingleFindOneByID ns_per_op 5.7765 255448.0000 Avg: 241497.8320
Med: 241627.5000
Stdev: 7037.0841
0.7308 1.9824
BenchmarkSmallDocInsertOne total_mem_allocs -5.2393 458603.0000 Avg: 483959.0000
Med: 484646.5000
Stdev: 12569.1292
0.7301 -2.0173
BenchmarkBSONFullDocumentDecoding ns_per_op 5.1445 77792.0000 Avg: 73985.7662
Med: 73762.5000
Stdev: 1593.2580
0.7754 2.3890
BenchmarkBSONFullDocumentDecoding total_bytes_allocated -4.8122 390814352.0000 Avg: 410571723.9712
Med: 411637056.0000
Stdev: 8722573.7849
0.7599 -2.2651
BenchmarkBSONFullDocumentDecoding total_mem_allocs -4.8097 9445622.0000 Avg: 9922878.0863
Med: 9949970.0000
Stdev: 209727.9298
0.7613 -2.2756
BenchmarkBSONDeepDocumentDecoding total_mem_allocs -4.5983 12746072.0000 Avg: 13360424.6071
Med: 13327786.0000
Stdev: 262036.0126
0.7628 -2.3445
BenchmarkBSONDeepDocumentDecoding total_bytes_allocated -4.5873 276948856.0000 Avg: 290264049.2857
Med: 289556096.0000
Stdev: 5680629.6408
0.7627 -2.3440
BenchmarkSmallDocInsertOne ops_per_second_max -4.5043 6131.3958 Avg: 6420.5961
Med: 6419.7214
Stdev: 133.5309
0.7408 -2.1658
BenchmarkBSONDeepDocumentDecoding ns_per_op 4.4843 65038.0000 Avg: 62246.6964
Med: 62397.0000
Stdev: 1169.7529
0.7666 2.3862
BenchmarkSmallDocInsertOne total_time_seconds -4.0974 1.1346 Avg: 1.1830
Med: 1.1836
Stdev: 0.0243
0.7365 -1.9937
BenchmarkBSONFullDocumentDecoding ops_per_second_med -3.9157 13995.9971 Avg: 14566.3706
Med: 14597.7410
Stdev: 278.6110
0.7393 -2.0472
BenchmarkBSONFullDocumentEncoding ns_per_op 3.7301 24112.0000 Avg: 23244.9353
Med: 23250.0000
Stdev: 408.5194
0.7424 2.1225
BenchmarkBSONFullDocumentEncoding total_bytes_allocated -3.6895 257277248.0000 Avg: 267133168.9784
Med: 267106956.0000
Stdev: 4730958.7970
0.7348 -2.0833
BenchmarkBSONDeepDocumentDecoding ops_per_second_med -3.6220 16427.9143 Avg: 17045.3014
Med: 16959.2131
Stdev: 312.1018
0.7195 -1.9782
BenchmarkBSONDeepDocumentDecoding allocated_bytes_per_op 0.0117 15101.0000 Avg: 15099.2374
Med: 15099.0000
Stdev: 0.7318
0.7850 2.4087

For a comprehensive view of all microbenchmark results for this PR's commit, please check out the Evergreen perf task for this patch.

@matthewdale
matthewdale force-pushed the godriver4154-fix-bench branch 2 times, most recently from 2ff1431 to d80589e Compare September 18, 2026 21:41
@matthewdale
matthewdale force-pushed the godriver4154-fix-bench branch from d80589e to 9b39f80 Compare September 19, 2026 00:43
@matthewdale
matthewdale marked this pull request as ready for review September 19, 2026 00:48
@matthewdale
matthewdale requested a review from a team as a code owner September 19, 2026 00:48
@matthewdale
matthewdale requested review from ayesha-ilm and qingyang-hu and a lite review from Copilot September 19, 2026 00:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The changes are internally consistent and address the described benchmark harness issues without identified blockers.

Review effort: Lite
Findings: None

What changed in this PR

This PR fixes benchmark harness correctness and makes fixture setup work consistently for both individual benchmarks and the full suite.

Changes:

  • Corrects single-insert fixture selection and benchmark timing.
  • Simplifies fixture paths and provisions test data in TestMain.
  • Fixes benchmark Taskfile commands and Ping context cleanup.
File Description
Taskfile.yml Updates benchmark task commands.
internal/​cmd/​benchmark/​benchmark_test.go Fixes fixture loading, setup cleanup, timing, and data provisioning.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/cd review-priority-normal Medium Priority PR for Review: within 1 business day

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants