Skip to content

perf(core): Implement getClass using cborlite - #3937

Draft
RafaelGranza wants to merge 1 commit into
perf/cbor/encoderfrom
perf/cbor/class
Draft

perf(core): Implement getClass using cborlite#3937
RafaelGranza wants to merge 1 commit into
perf/cbor/encoderfrom
perf/cbor/class

Conversation

@RafaelGranza

@RafaelGranza RafaelGranza commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

getClass RPC in a saturated node is ~1.6x faster.

Considering only the decode time, decoding a large sierra is ~6x faster. deprecatedCairo is 2x faster.

Class Generic (fxamacker) cborlite Speedup
sierra 601,091 ns 97,248 ns 6.18x
521,248 B / 96 allocs 250,865 B / 92 allocs 2.08x less memory
deprecatedCairo 4,502 ns 2,089 ns 2.16x
16,328 B / 14 allocs 8,120 B / 11 allocs 2.01x less memory

Flame Graph (Main):

Screenshot 2026-08-13 at 2 51 20 AM

Flame Graph (This PR):

Screenshot 2026-08-13 at 2 51 04 AM

The Handler.Class used to use ~41% of CPU, now uses only ~15%.

@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.92308% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.79%. Comparing base (e3e936b) to head (c47dbca).

Files with missing lines Patch % Lines
core/class.go 57.14% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@                  Coverage Diff                  @@
##           perf/cbor/encoder    #3937      +/-   ##
=====================================================
- Coverage              74.81%   74.79%   -0.03%     
=====================================================
  Files                    469      469              
  Lines                  41433    41440       +7     
=====================================================
- Hits                   30997    30993       -4     
- Misses                  8313     8322       +9     
- Partials                2123     2125       +2     
Flag Coverage Δ
jsonv2 77.38% <76.92%> (-0.05%) ⬇️

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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

A class is the biggest value the node reads out of its own database, and the
generic decoder walks it twice: once to check it is well formed, then again to
fill the value.

Both accessors and UnmarshalBinary go through cborlite now, so no step of the
read touches the generic decoder unless it declines the shape. Worth 5.7x on a
Sierra class, and half the memory, since the wrapper is aliased instead of
copied.
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.

1 participant