Skip to content

Conversation

qingyang-hu
Copy link
Collaborator

@qingyang-hu qingyang-hu commented Oct 6, 2025

GODRIVER-3668
GODRIVER-3582

Summary

Add bypassEmptyTsReplacement option to:

  • insertOne
  • insertMany
  • updateOne
  • updateMany
  • replaceOne
  • findOneAndUpdate
  • findOneAndReplace
  • collection.bulkWrite
  • client.bulkWrite

Background & Motivation

Copy link
Contributor

mongodb-drivers-pr-bot bot commented Oct 6, 2025

🧪 Performance Results

Commit SHA: 446c2e1

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

Benchmark Measurement % Change Patch Value Stable Region H-Score Z-Score
BenchmarkSingleFindOneByID ops_per_second_min 43.8462 1811.5876 Avg: 1259.3918
Med: 1247.3152
Stdev: 180.9659
0.8238 3.0514
BenchmarkMultiFindMany ops_per_second_max -18.8371 3424657.5342 Avg: 4219484.4039
Med: 4219484.4039
Stdev: 25178.2788
0.9888 -31.5680
BenchmarkMultiFindMany ops_per_second_med -18.5987 3048780.4878 Avg: 3745370.8899
Med: 3745370.8899
Stdev: 19838.0311
0.9899 -35.1139
BenchmarkBSONDeepDocumentDecoding ns_per_op 16.5938 73313.0000 Avg: 62879.0000
Med: 62879.0000
Stdev: 741.0479
0.9749 14.0801
BenchmarkBSONDeepDocumentDecoding ops_per_second_med -15.0886 14420.5464 Avg: 16983.0433
Med: 16983.0433
Stdev: 376.6983
0.9480 -6.8025
BenchmarkBSONDeepDocumentDecoding ops_per_second_max -14.4652 15011.4087 Avg: 17550.0516
Med: 17550.0516
Stdev: 305.0804
0.9575 -8.3212
BenchmarkBSONDeepDocumentDecoding total_bytes_allocated -14.1797 247220688.0000 Avg: 288067960.0000
Med: 288067960.0000
Stdev: 3193961.7326
0.9724 -12.7889
BenchmarkBSONDeepDocumentDecoding total_mem_allocs -14.1523 11383152.0000 Avg: 13259700.5000
Med: 13259700.5000
Stdev: 147422.5715
0.9722 -12.7290
BenchmarkBSONFlatDocumentEncoding ops_per_second_med -14.0656 68875.2669 Avg: 80148.6853
Med: 80148.6853
Stdev: 3752.3824
0.8823 -3.0043
BenchmarkBSONFullDocumentDecoding ops_per_second_max -13.6919 13118.0229 Avg: 15199.0668
Med: 15199.0668
Stdev: 58.4788
0.9901 -35.5863
BenchmarkBSONFlatDocumentEncoding ns_per_op 13.5439 16180.0000 Avg: 14250.0000
Med: 14250.0000
Stdev: 422.8499
0.9225 4.5643
BenchmarkBSONFlatDocumentDecoding ns_per_op 13.5214 59945.0000 Avg: 52805.0000
Med: 52805.0000
Stdev: 1268.5496
0.9372 5.6285
BenchmarkBSONFlatDocumentDecoding ops_per_second_max -13.2835 18610.8836 Avg: 21461.7681
Med: 21461.7681
Stdev: 344.8704
0.9572 -8.2665
BenchmarkBSONFullDocumentDecoding ops_per_second_med -13.1874 12670.2566 Avg: 14594.9582
Med: 14594.9582
Stdev: 123.1298
0.9774 -15.6315
BenchmarkBSONFlatDocumentDecoding ops_per_second_med -13.1252 17829.4435 Avg: 20523.1553
Med: 20523.1553
Stdev: 309.7114
0.9593 -8.6975
BenchmarkBSONFullDocumentDecoding ns_per_op 13.0956 84099.0000 Avg: 74361.0000
Med: 74361.0000
Stdev: 67.8823
0.9975 143.4543
BenchmarkBSONFlatDocumentDecoding total_bytes_allocated -12.5242 360518552.0000 Avg: 412135396.0000
Med: 412135396.0000
Stdev: 9247480.2590
0.9367 -5.5817
BenchmarkBSONFlatDocumentDecoding total_mem_allocs -12.4930 9170075.0000 Avg: 10479244.5000
Med: 10479244.5000
Stdev: 235634.1424
0.9364 -5.5559
BenchmarkBSONFlatDocumentEncoding ops_per_second_max -9.7956 75528.7009 Avg: 83730.6417
Med: 83730.6417
Stdev: 2853.8031
0.8770 -2.8740
BenchmarkBSONFullDocumentEncoding ops_per_second_med -8.9264 41788.5499 Avg: 45884.3582
Med: 45884.3582
Stdev: 334.9541
0.9711 -12.2280
BenchmarkBSONFullDocumentEncoding ns_per_op 8.9150 25668.0000 Avg: 23567.0000
Med: 23567.0000
Stdev: 21.2132
0.9964 99.0421
BenchmarkBSONFullDocumentEncoding ops_per_second_max -8.8157 43176.0287 Avg: 47350.2788
Med: 47350.2788
Stdev: 412.1801
0.9651 -10.1272
BenchmarkBSONFullDocumentEncoding total_mem_allocs -7.3810 1407362.0000 Avg: 1519518.0000
Med: 1519518.0000
Stdev: 11602.2081
0.9634 -9.6668
BenchmarkBSONFlatDocumentEncoding total_time_seconds 3.5930 1.2350 Avg: 1.1921
Med: 1.1918
Stdev: 0.0190
0.7519 2.2508
BenchmarkSmallDocInsertOne allocated_bytes_per_op 0.5831 5692.0000 Avg: 5659.0000
Med: 5660.0000
Stdev: 6.4758
0.8934 5.0959
BenchmarkLargeDocInsertOne allocated_bytes_per_op 0.5538 5691.0000 Avg: 5659.6562
Med: 5660.0000
Stdev: 5.8398
0.9045 5.3672
BenchmarkSingleFindOneByID allocated_bytes_per_op 0.2396 22488.0000 Avg: 22434.2500
Med: 22433.0000
Stdev: 24.0336
0.7509 2.2365
BenchmarkBSONDeepDocumentDecoding allocated_bytes_per_op -0.0571 15094.0000 Avg: 15102.6250
Med: 15104.0000
Stdev: 3.0431
0.8601 -2.8343
BenchmarkBSONFlatDocumentDecoding allocated_bytes_per_op -0.0360 18046.0000 Avg: 18052.5000
Med: 18052.5000
Stdev: 0.7071
0.9615 -9.1924

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

Copy link
Contributor

API Change Report

./v2/x/mongo/driver/operation

compatible changes

(*FindAndModify).AdditionalCmd: added
(*Insert).AdditionalCmd: added
(*Update).AdditionalCmd: added

@qingyang-hu qingyang-hu changed the title GODRIVER-3370 Add bypassEmptyTsReplacement option. GODRIVER-3668 Add bypassEmptyTsReplacement option. Oct 7, 2025
@qingyang-hu qingyang-hu marked this pull request as ready for review October 7, 2025 14:52
@qingyang-hu qingyang-hu requested a review from a team as a code owner October 7, 2025 14:52
@Copilot Copilot AI review requested due to automatic review settings October 7, 2025 14:52
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds the bypassEmptyTsReplacement option to various MongoDB write operations by implementing an "addCommandFields" mechanism that allows arbitrary command fields to be added to operations.

  • Adds support for bypassEmptyTsReplacement option across insert, update, replace, findOneAndUpdate, findOneAndReplace, and bulk write operations
  • Implements addCommandFields functionality in internal options handling to support additional command parameters
  • Adds comprehensive test coverage to verify the option is properly passed through to MongoDB commands

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
x/mongo/driver/xoptions/options.go Adds "addCommandFields" case handling to all internal option setters
x/mongo/driver/operation/update.go Adds additionalCmd field and AdditionalCmd method to Update operation
x/mongo/driver/operation/insert.go Adds additionalCmd field and AdditionalCmd method to Insert operation
x/mongo/driver/operation/find_and_modify.go Adds additionalCmd field and AdditionalCmd method to FindAndModify operation
mongo/collection.go Integrates addCommandFields option handling into collection methods
mongo/client_bulk_write.go Adds additionalCmd field to clientBulkWrite struct
mongo/client.go Integrates addCommandFields option handling into Client.BulkWrite
mongo/bulk_write.go Adds additionalCmd field and integrates it into bulk write operations
internal/integration/collection_test.go Adds comprehensive tests for bypassEmptyTsReplacement option
internal/integration/client_test.go Adds tests for client bulk write with bypassEmptyTsReplacement and fixes test assertions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant