Skip to content

CSHARP-6064: Fix BsonEncodingPoco benchmark null bloat and stale DataSetSize#2027

Merged
BorisDog merged 2 commits into
mainfrom
sage-bot/CSHARP-6064/sage-CSHARP-6064-1780680659957
Jun 5, 2026
Merged

CSHARP-6064: Fix BsonEncodingPoco benchmark null bloat and stale DataSetSize#2027
BorisDog merged 2 commits into
mainfrom
sage-bot/CSHARP-6064/sage-CSHARP-6064-1780680659957

Conversation

@mongodb-sage-bot
Copy link
Copy Markdown
Contributor

@mongodb-sage-bot mongodb-sage-bot Bot commented Jun 5, 2026

Add [BsonIgnoreIfNull] to all four properties on DeepPocoNode to prevent
serializing null fields that inflate BSON output by ~48%. Update the
DataSetSize constant for deep_bson.json from 19_640_000 to 22_840_000 in
both BsonEncodingBenchmark and BsonDecodingBenchmark to match the current
file size (2,286 bytes per document × 10,000 iterations).


Important

MongoDB Contribution Guidelines

This pull request was generated by sage-bot on behalf of boris.dogadov@mongodb.com (ticket assignee). The assignee must self-review the changes before requesting review from another engineer.
The assignee is not allowed to merge their own PR without approval from another engineer.

…SetSize

Add [BsonIgnoreIfNull] to all four properties on DeepPocoNode to prevent
serializing null fields that inflate BSON output by ~48%. Update the
DataSetSize constant for deep_bson.json from 19_640_000 to 22_860_000 in
both BsonEncodingBenchmark and BsonDecodingBenchmark to match the current
file size (2,286 bytes per document × 10,000 iterations).
@mongodb-sage-bot
Copy link
Copy Markdown
Contributor Author

Sage Bot can help with this pull request. Just @sage-bot in comments and I'll start working on changes in this branch.
Learn more about Sage Bot

new("extended_bson/flat_bson.json", "Flat", 75_310_000, typeof(FlatPoco)),
new("extended_bson/full_bson.json", "Full", 57_340_000, typeof(FullPoco)),
new("extended_bson/deep_bson.json", "Deep", 19_640_000, typeof(DeepPocoRoot))
new("extended_bson/deep_bson.json", "Deep", 22_860_000, typeof(DeepPocoRoot))
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.

@sage-bot this should be 22_840_000 (in both locations).

@mongodb-sage-bot
Copy link
Copy Markdown
Contributor Author

mongodb-sage-bot Bot commented Jun 5, 2026

Corrected the deep_bson.json DataSetSize from 22_860_000 to 22_840_000 in both BsonEncodingBenchmark.cs and BsonDecodingBenchmark.cs, as @BorisDog requested.

@BorisDog BorisDog added the chore Non–user-facing code changes (tests, build scripts, etc.). label Jun 5, 2026
Corrected the deep_bson.json DataSetSize value from 22_860_000 to
22_840_000 in both BsonEncodingBenchmark.cs and BsonDecodingBenchmark.cs,
as requested by @BorisDog.
@BorisDog BorisDog marked this pull request as ready for review June 5, 2026 18:12
@BorisDog BorisDog requested a review from a team as a code owner June 5, 2026 18:12
@BorisDog BorisDog requested review from adelinowona and Copilot June 5, 2026 18:12
Copy link
Copy Markdown
Contributor

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 updates the BSON benchmarks to make the “Deep” POCO encoding dataset comparable to the source document by preventing null-valued fields from being serialized, and refreshes the recorded dataset size used for throughput scoring.

Changes:

  • Added [BsonIgnoreIfNull] to DeepPocoNode properties to avoid serializing null fields in POCO benchmarks.
  • Updated the DataSetSize constant for extended_bson/deep_bson.json in both encoding and decoding benchmarks.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
benchmarks/MongoDB.Driver.Benchmarks/Bson/BsonEncodingBenchmark.cs Updates the “Deep” dataset size used to compute MB/s throughput scores for encoding benchmarks.
benchmarks/MongoDB.Driver.Benchmarks/Bson/BsonDecodingBenchmark.cs Updates the “Deep” dataset size used to compute MB/s throughput scores for decoding benchmarks.
benchmarks/MongoDB.Driver.Benchmarks/Bson/BsonBenchmarkDataTypes.cs Adds [BsonIgnoreIfNull] to Deep POCO node properties to prevent null field bloat during POCO serialization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread benchmarks/MongoDB.Driver.Benchmarks/Bson/BsonEncodingBenchmark.cs
Comment thread benchmarks/MongoDB.Driver.Benchmarks/Bson/BsonDecodingBenchmark.cs
Copy link
Copy Markdown
Contributor

@BorisDog BorisDog left a comment

Choose a reason for hiding this comment

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

LGTM

@BorisDog BorisDog merged commit a6d290d into main Jun 5, 2026
9 of 27 checks passed
@BorisDog BorisDog deleted the sage-bot/CSHARP-6064/sage-CSHARP-6064-1780680659957 branch June 5, 2026 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Non–user-facing code changes (tests, build scripts, etc.).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants