Skip to content

perf: Cache serialized extensions to speed up encoding - #3210

Merged
aborgna-q merged 2 commits into
mainfrom
ab/extension-serialization-cache
Sep 1, 2026
Merged

perf: Cache serialized extensions to speed up encoding#3210
aborgna-q merged 2 commits into
mainfrom
ab/extension-serialization-cache

Conversation

@aborgna-q

Copy link
Copy Markdown
Collaborator

Keep the serialized json buffer around when loading an extension in Rust, so we don't need to re-encode them each time.

Extensions are shared inside Arcs, so the buffer is only stored once.

@aborgna-q aborgna-q added the C-perf Category: PR/issue with code/suggestions for performance improvements label Aug 18, 2026
@aborgna-q aborgna-q changed the title perf: Cache the serialized extension to speed up encoding perf: Cache serialized extensions to speed up encoding Aug 18, 2026
@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.41772% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.55%. Comparing base (3aa55e9) to head (d98ef26).

Files with missing lines Patch % Lines
hugr-core/src/extension.rs 73.68% 8 Missing and 7 partials ⚠️
hugr-core/src/envelope/reader.rs 77.77% 0 Missing and 4 partials ⚠️
hugr-core/src/envelope/writer.rs 0.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3210      +/-   ##
==========================================
- Coverage   81.55%   81.55%   -0.01%     
==========================================
  Files         242      242              
  Lines       47309    47373      +64     
  Branches    40906    40970      +64     
==========================================
+ Hits        38584    38633      +49     
- Misses       6713     6721       +8     
- Partials     2012     2019       +7     
Flag Coverage Δ
python 89.39% <ø> (ø)
rust 80.32% <73.41%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq

codspeed-hq Bot commented Aug 18, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 32.63%

⚡ 3 improved benchmarks
✅ 42 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
serialization/simple_cfg/capnp/with_extensions/encode 490.1 µs 325 µs +50.78%
serialization/t_factory/capnp/with_extensions/encode 14.6 ms 11.1 ms +31.09%
serialization/simple_cfg/sexpr/with_extensions/encode 1.2 ms 1 ms +18.05%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing ab/extension-serialization-cache (d98ef26) with main (3aa55e9)

Open in CodSpeed

@aborgna-q
aborgna-q force-pushed the ab/extension-serialization-cache branch from a72ae13 to 6107e9c Compare September 1, 2026 13:08
@aborgna-q
aborgna-q marked this pull request as ready for review September 1, 2026 14:08
@aborgna-q
aborgna-q requested a review from a team as a code owner September 1, 2026 14:08
@aborgna-q
aborgna-q requested a review from cqc-alec September 1, 2026 14:08
@aborgna-q
aborgna-q added this pull request to the merge queue Sep 1, 2026
Merged via the queue into main with commit e609c66 Sep 1, 2026
41 of 42 checks passed
@aborgna-q
aborgna-q deleted the ab/extension-serialization-cache branch September 1, 2026 15:02
This was referenced Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-perf Category: PR/issue with code/suggestions for performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants