Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sachdes-stripe
Copy link

@sachdes-stripe sachdes-stripe commented Jan 28, 2026

Context / Problem

Summary of Changes

This PR restores the fast parsing path while keeping CVE guardrails intact:

  • Reintroduced parsing constructors for full Java gencode (fast path).
  • Added safe extension finalization hook (internalMakeExtensionsImmutable) so generated code can freeze extensions without triggering pre‑22 guardrails.
  • Optimization 1: Unknown fields:Lazy initialization remains (no builder unless unknowns are seen).
  • Optimization 2: Cache per‑field message parsers in parsing constructor.

Why this stays CVE‑safe

  • The CVE is triggered by mutable↔immutable flips during parsing.
  • This PR does not change the runtime guardrails added in Refactoring Java parsing (22.x) #10664 on v22.x; parsing constructors now call safe runtime helpers and finalize extensions via the new hook.

Benchmarks

Benchmark used are same as the one defined here #24828 (comment)

Performance (DebugProtobuf, ms/op)

Overall

Version Min Median Mean P95 Throughput (MB/s)
v21.6 (pre‑regression) 91.14 92.41 92.41 94.42 589.69
v21.7 (post‑#10665) 130.53 138.80 148.13 193.22 367.87
Current (this PR) 101.82 102.52 103.04 105.59 528.82
Main HEAD (no fixes) 149.71 153.19 155.37 167.69 350.70

Mean Latency (DebugProtobuf, ms/op)

Depth v21.6 v21.7 current main_clean
1 0.00205 0.00268 0.00239 0.00299
2 0.00261 0.00498 0.00487 0.00706
3 0.00628 0.01028 0.00742 0.01131
4 0.02420 0.03732 0.02690 0.03884
5 0.18908 0.27126 0.18712 0.22296
6 1.16909 1.69483 1.25734 1.62867
7 7.76149 13.41769 8.66132 12.70589
8 95.96273 173.74663 102.43108 151.64732

Throughput (MB/s)

Depth v21.6 v21.7 current main_clean
1 3.72 2.84 3.19 2.55
2 37.96 19.90 20.38 14.05
3 151.91 92.87 128.62 84.42
4 365.06 236.75 328.41 227.49
5 421.19 293.58 425.58 357.19
6 606.07 418.07 563.53 435.05
7 803.95 465.05 720.43 491.10
8 567.83 313.62 531.97 359.32

CVE Clusterfuzz (Runtime + GC pauses)

Version Iters Total ms Avg ms Mem delta (KB) GC full GC young
v21.6 1 2012 2012 866013 1 93
v21.6 10 18048 1804 742117 1 830
v21.6 100 179750 1797 781969 1 7667
v21.7 1 47 47 3505 1 0
v21.7 10 47 4 9989 1 1
v21.7 100 168 1 136744 1 5
Current (this PR) 1 60 60 4891 1 0
Current (this PR) 10 86 8 5427 1 2
Current (this PR) 100 202 2 180018 1 5
Main HEAD (no fixes) 1 74 74 4886 1 0
Main HEAD (no fixes) 10 70 7 5354 1 2
Main HEAD (no fixes) 100 190 1 181486 1 5

Notes

  • This PR focuses on performance wins without regression risk, no hardcoding, CVE‑safe, and fully backward‑compatible.

Co-authored-by: Anshuman Mishra [email protected]

@sachdes-stripe sachdes-stripe force-pushed the sachdes/latency_perf_improvements branch from ede68e1 to 5a732a3 Compare January 28, 2026 09:17
@sachdes-stripe sachdes-stripe marked this pull request as ready for review January 28, 2026 15:06
@sachdes-stripe sachdes-stripe requested a review from a team as a code owner January 28, 2026 15:07
@sachdes-stripe sachdes-stripe requested review from shaod2 and removed request for a team January 28, 2026 15:07
@karenwuz karenwuz added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Jan 29, 2026
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants