SIGN IN SIGN UP

Protocol Buffers - Google's data interchange format

0 0 3 C++

Refactor to shrink CodedInputStream.readMessage, to increase where it is inlined.

The refactor shrinks the method's bytecode to be below 35 bytes instead of above, and 35 bytes is one of the relevant default threshold conditions for inlining.

The theory behind this change is to improve a very hot case of:
- gencode always calls readMessage with the concrete builder types of fields
- That means readMessage itself is called with all reachable Builder types
- If readMessage is not inlined, it will be highly megamorphic (= too many different types for the JIT to try to monomorphize it), which makes it true dynamic dispatch at runtime. But if it is inlined instead, then it will trivially dispatch to one specific Builder type instead.

It isn't so easy to benchmark how much this will impact the fleet in reality, but since this change is otherwise very benign we can just make the change and then post-hoc see if it looks like it improved things.

PiperOrigin-RevId: 915625779
P
Protobuf Team Bot committed
5613198ab61e010295ed6cc2c2ee6d71b3c3fa97
Parent: 4d47a27
Committed by Copybara-Service <copybara-worker@google.com> on 5/14/2026, 9:46:01 PM