Comprehensive overhaul and hardening of MessageDifferencer microbenchmarks in message_differencer_unittest.cc to accurately model production serving conditions and eliminate benchmark gaming vectors: - #29535
Draft
copybara-service[bot] wants to merge 1 commit into
Conversation
…marks in message_differencer_unittest.cc to accurately model production serving conditions and eliminate benchmark gaming vectors:
- Equal-Length String Mismatches: Replaced string length alterations (appending "_mismatch" or altering index digit lengths) with in-place character mutation (MutateStringEqualLength) across repeated lists, repeated sets (kDisjoint, kPartialOverlap), and map keys. This prevents string comparisons from early-exiting on string size check (lhs.size() != rhs.size()) without reading memory payloads, properly exercising SIMD/memcmp comparisons.
- Cardinality Spectrum for Repeated Sets: Expanded repeated set benchmarks from artificial small N <= 15 to a representative cardinality spectrum (N in {2, 10, 50, 200, 1000}). This prevents microbenchmarks from artificially favoring O(N^2) pairwise brute force over scalable O(N) hash/sort algorithms on production-scale collections.
- Distributed Mismatch Positions:
- Repeated lists: Mismatches are distributed across indices (first, middle, last) rather than exclusively mutating index 0.
- Wide schemas: Mismatches exercise multiple field types and tag positions (scalars, strings, enums, nested submessages) rather than exclusively aborting on tag 1 optional_int32.
- Deep schemas: Mismatch paths ensure full traversal to leaf nodes, evaluating all leaf fields rather than short-circuiting on tag 1.
- Field Presence Asymmetry: Added dedicated kPresenceAsymmetry benchmarks exercising FieldBefore(field1, field2) and FieldBefore(field2, field1) comparison paths where one message populates fields that the other lacks.
- Map Field Realism: Separated map field presence asymmetry from key lookup failures (ContainsMapKey) and value comparisons, using equal-length key mutations.
- Entry Point Ephemerality & Setup Measurement: Added ephemeral TreatAsSet repeated set evaluations alongside long-lived instance benchmarks to capture per-comparison configuration overhead versus steady-state comparison.
- Benchmark Deduplication: Removed redundant benchmark template instantiations (BM_EntryPoint_Wide_Compare / BM_WideSchema_Identical and BM_EntryPoint_Deep_Compare / BM_DeepSchema_Identical).
- Pool Integrity Validation: Expanded automated unit tests (ValidateWideMessagePool, ValidateDeepMessagePool, ValidateMapMessagePool, ValidateRepeatedListMessagePool, ValidateRepeatedSetMessagePool) to verify behavioral correctness across all scenarios, field types, and cardinalities up to N=1000.
PiperOrigin-RevId: 974107248
copybara-service
Bot
force-pushed
the
test_974107248
branch
from
September 2, 2026 20:39
cc2a990 to
6770b1c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Comprehensive overhaul and hardening of MessageDifferencer microbenchmarks in message_differencer_unittest.cc to accurately model production serving conditions and eliminate benchmark gaming vectors: