CSHARP-6064: Fix BsonEncodingPoco benchmark null bloat and stale DataSetSize#2027
Conversation
…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).
|
Sage Bot can help with this pull request. Just |
| 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)) |
There was a problem hiding this comment.
@sage-bot this should be 22_840_000 (in both locations).
|
Corrected the |
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.
There was a problem hiding this comment.
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]toDeepPocoNodeproperties to avoid serializing null fields in POCO benchmarks. - Updated the
DataSetSizeconstant forextended_bson/deep_bson.jsonin 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.
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.