SIGN IN SIGN UP

Protocol Buffers - Google's data interchange format

0 0 35 C++

Fix for performance penalty in deep dependencies (#20392)

The goal of this PR is to fix #20371 (closed) #24267 and #24330 and improve the performance of csharp runtime when dealing with deep nested dependencies of .proto files.

- The fix consists in caching the recursive calls for the search of extensions.

- Two identical datasets (nested proto files) are created automatically using Bazel: one to test it with caching enabled, and another one to test it with no caching. Note: the same dataset cannot be used because once it is loaded inside the test, it cannot be unloaded.

- The created datasets have a width of 6 and a depth of 6, enough to showcase the dependency impact and to not impact the testing time for unit tests. This could be configured.

- In the dataset there is only one proto file with a message `Example` whose descriptor is loaded, and by doing so all the dependencies (and sub dependencies) that it has.

- A set of benchmark metrics have been created to evaluate the performance impact before and after the fix.

- The assertion inside the unit test makes sure that when using metrics the number of traversed extensions (dependencies of the dependencies) when using caching, is reduced by a factor of 1000x.

- The second assertion also makes sure that the time used to load the descriptor when using cache is less than the one without using cache.

Closes #20392

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/20392 from fgarciacorona:fix_20371_csharp_deep_dependencies b1353f6fd1ca02a0ade27b7974a0ac640eb36c35
PiperOrigin-RevId: 919713760
F
Fernando Garcia Corona committed
aeb0dc2f970766cf52999545493a2070cb306ffc
Parent: 3981478
Committed by Copybara-Service <copybara-worker@google.com> on 5/22/2026, 4:26:03 PM