Skip to content

feat: cache frequently parsed objects#816

Draft
anthony-swirldslabs wants to merge 2 commits intomainfrom
814-cacheParsedObjects
Draft

feat: cache frequently parsed objects#816
anthony-swirldslabs wants to merge 2 commits intomainfrom
814-cacheParsedObjects

Conversation

@anthony-swirldslabs
Copy link
Copy Markdown
Contributor

@anthony-swirldslabs anthony-swirldslabs commented May 8, 2026

Description:
Caching frequently parsed objects.

Benchmark results:
https://github.com/hashgraph/pbj/actions/runs/25529183974/job/74931484011

Benchmark             (frequency)  (numOfFrequentModels)                     (type)   Mode  Cnt    Score    Error   Units
CacheableBench.bench            2                      1  NotCacheableAccountIDType  thrpt   15  291.257 ±  0.415  ops/us
CacheableBench.bench            2                      1     CacheableAccountIDType  thrpt   15  158.135 ±  1.345  ops/us
CacheableBench.bench            2                      2  NotCacheableAccountIDType  thrpt   15  290.601 ±  1.546  ops/us
CacheableBench.bench            2                      2     CacheableAccountIDType  thrpt   15  158.636 ±  0.769  ops/us
CacheableBench.bench            2                      3  NotCacheableAccountIDType  thrpt   15  290.363 ±  1.937  ops/us
CacheableBench.bench            2                      3     CacheableAccountIDType  thrpt   15  158.475 ±  1.097  ops/us
CacheableBench.bench            2                      7  NotCacheableAccountIDType  thrpt   15  290.103 ±  1.598  ops/us
CacheableBench.bench            2                      7     CacheableAccountIDType  thrpt   15  140.814 ±  0.228  ops/us
CacheableBench.bench            2                     17  NotCacheableAccountIDType  thrpt   15  267.626 ± 18.180  ops/us
CacheableBench.bench            2                     17     CacheableAccountIDType  thrpt   15  156.335 ±  2.795  ops/us
CacheableBench.bench            5                      1  NotCacheableAccountIDType  thrpt   15  284.757 ±  2.076  ops/us
CacheableBench.bench            5                      1     CacheableAccountIDType  thrpt   15  156.780 ±  0.628  ops/us
CacheableBench.bench            5                      2  NotCacheableAccountIDType  thrpt   15  287.358 ±  3.130  ops/us
CacheableBench.bench            5                      2     CacheableAccountIDType  thrpt   15  158.839 ±  0.398  ops/us
CacheableBench.bench            5                      3  NotCacheableAccountIDType  thrpt   15  290.532 ±  1.864  ops/us
CacheableBench.bench            5                      3     CacheableAccountIDType  thrpt   15  158.963 ±  0.376  ops/us
CacheableBench.bench            5                      7  NotCacheableAccountIDType  thrpt   15  291.032 ±  1.027  ops/us
CacheableBench.bench            5                      7     CacheableAccountIDType  thrpt   15  139.191 ±  2.379  ops/us
CacheableBench.bench            5                     17  NotCacheableAccountIDType  thrpt   15  290.181 ±  1.589  ops/us
CacheableBench.bench            5                     17     CacheableAccountIDType  thrpt   15  158.541 ±  0.861  ops/us
CacheableBench.bench           11                      1  NotCacheableAccountIDType  thrpt   15  290.478 ±  1.133  ops/us
CacheableBench.bench           11                      1     CacheableAccountIDType  thrpt   15  159.395 ±  0.122  ops/us
CacheableBench.bench           11                      2  NotCacheableAccountIDType  thrpt   15  290.049 ±  2.062  ops/us
CacheableBench.bench           11                      2     CacheableAccountIDType  thrpt   15  159.191 ±  0.269  ops/us
CacheableBench.bench           11                      3  NotCacheableAccountIDType  thrpt   15  290.370 ±  1.847  ops/us
CacheableBench.bench           11                      3     CacheableAccountIDType  thrpt   15  158.324 ±  0.830  ops/us
CacheableBench.bench           11                      7  NotCacheableAccountIDType  thrpt   15  290.603 ±  1.382  ops/us
CacheableBench.bench           11                      7     CacheableAccountIDType  thrpt   15  159.284 ±  0.287  ops/us
CacheableBench.bench           11                     17  NotCacheableAccountIDType  thrpt   15  290.812 ±  1.102  ops/us
CacheableBench.bench           11                     17     CacheableAccountIDType  thrpt   15  152.847 ±  6.451  ops/us
CacheableBench.bench           37                      1  NotCacheableAccountIDType  thrpt   15  264.612 ± 18.723  ops/us
CacheableBench.bench           37                      1     CacheableAccountIDType  thrpt   15  156.505 ±  1.293  ops/us
CacheableBench.bench           37                      2  NotCacheableAccountIDType  thrpt   15  285.340 ±  2.086  ops/us
CacheableBench.bench           37                      2     CacheableAccountIDType  thrpt   15  156.313 ±  1.049  ops/us
CacheableBench.bench           37                      3  NotCacheableAccountIDType  thrpt   15  289.482 ±  1.745  ops/us
CacheableBench.bench           37                      3     CacheableAccountIDType  thrpt   15  159.052 ±  0.219  ops/us
CacheableBench.bench           37                      7  NotCacheableAccountIDType  thrpt   15  290.797 ±  0.655  ops/us
CacheableBench.bench           37                      7     CacheableAccountIDType  thrpt   15  157.885 ±  1.180  ops/us
CacheableBench.bench           37                     17  NotCacheableAccountIDType  thrpt   15  290.747 ±  1.520  ops/us
CacheableBench.bench           37                     17     CacheableAccountIDType  thrpt   15  159.089 ±  0.238  ops/us

Related issue(s):

Fixes #814

Notes for reviewer:
All tests should pass.

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

Signed-off-by: Anthony Petrov <anthony@swirldslabs.com>
@anthony-swirldslabs anthony-swirldslabs self-assigned this May 8, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

JUnit Test Report

   521 files  +440     521 suites  +440   34s ⏱️ - 2m 29s
 1 519 tests ±  0   1 515 ✅ ±  0   4 💤 ±0  0 ❌ ±0 
10 407 runs  ±  0  10 379 ✅ ±  0  28 💤 ±0  0 ❌ ±0 

Results for commit f1a46c1. ± Comparison against base commit 27619fb.

This pull request removes 6 and adds 6 tests. Note that renamed tests count towards both.
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [1] FLOAT, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x0000000024497d78@2f408960, [0.1, 0.5, 100.0], 12, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000002449c000@1516f497
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [1] STRING, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00000000244a4450@34a482d0, [string 1, testing here, testing there], com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00000000244a4678@2a738d47
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [2] BYTES, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00000000244a48a0@23169374, [010203, ff7f0f, 42da07370bff], com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00000000244a4ac8@6c2a33af
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [2] DOUBLE, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000002449c228@923bf67, [0.1, 0.5, 100.0, 1.7653472635472653E240], 32, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000002449c450@938e54a
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [3] BOOL, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000002449c678@a165c11, [true, false, false, true, true, true], 6, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000002449c8a0@1eda12b3
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [4] ENUM, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000002449cac8@193792e6, [0, 2, 1], 3, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000002449ccf0@21f9a305
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [1] FLOAT, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00000000a349f730@4687fee7, [0.1, 0.5, 100.0], 12, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00000000a349f958@4a0fc665
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [1] STRING, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00000000a34a7cf0@9e092b5, [string 1, testing here, testing there], com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00000000a34ac000@52737c1
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [2] BYTES, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00000000a34ac228@62eb918, [010203, ff7f0f, 42da07370bff], com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00000000a34ac450@37e28b20
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [2] DOUBLE, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00000000a349fb80@25d87313, [0.1, 0.5, 100.0, 1.7653472635472653E240], 32, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00000000a349fda8@3c130cb2
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [3] BOOL, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00000000a34a4000@471d6571, [true, false, false, true, true, true], 6, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00000000a34a4228@213bd66a
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [4] ENUM, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00000000a34a4450@77a1df4d, [0, 2, 1], 3, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00000000a34a4678@5bbb0a25

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

Integration Test Report

    422 files  + 3      422 suites  +3   17m 7s ⏱️ - 3m 22s
115 009 tests +28  115 009 ✅ +28  0 💤 ±0  0 ❌ ±0 
115 251 runs  +28  115 251 ✅ +28  0 💤 ±0  0 ❌ ±0 

Results for commit f1a46c1. ± Comparison against base commit 27619fb.

This pull request removes 2 and adds 30 tests. Note that renamed tests count towards both.
com.hedera.pbj.integration.test.ParserNeverWrapsTest ‑ [1] com.hedera.pbj.integration.test.ParserNeverWrapsTest$$Lambda/0x0000000098bde690@79def82e
com.hedera.pbj.integration.test.ParserNeverWrapsTest ‑ [2] com.hedera.pbj.integration.test.ParserNeverWrapsTest$$Lambda/0x0000000098bde8d8@2211b9fa
com.hedera.pbj.integration.test.ParserNeverWrapsTest ‑ [1] com.hedera.pbj.integration.test.ParserNeverWrapsTest$$Lambda/0x0000000060c6eaf0@15416681
com.hedera.pbj.integration.test.ParserNeverWrapsTest ‑ [2] com.hedera.pbj.integration.test.ParserNeverWrapsTest$$Lambda/0x0000000060c6ed38@5dac357a
com.hedera.pbj.integration.test.VectorVarIntTest ‑ [1] true
com.hedera.pbj.integration.test.VectorVarIntTest ‑ [2] false
com.hedera.pbj.test.proto.pbj.tests.CacheableAccountIDTest ‑ [10] NoToStringWrapper{com.hedera.pbj.test.proto.pbj.CacheableAccountID}
com.hedera.pbj.test.proto.pbj.tests.CacheableAccountIDTest ‑ [11] NoToStringWrapper{com.hedera.pbj.test.proto.pbj.CacheableAccountID}
com.hedera.pbj.test.proto.pbj.tests.CacheableAccountIDTest ‑ [1] NoToStringWrapper{com.hedera.pbj.test.proto.pbj.CacheableAccountID}
com.hedera.pbj.test.proto.pbj.tests.CacheableAccountIDTest ‑ [2] NoToStringWrapper{com.hedera.pbj.test.proto.pbj.CacheableAccountID}
com.hedera.pbj.test.proto.pbj.tests.CacheableAccountIDTest ‑ [3] NoToStringWrapper{com.hedera.pbj.test.proto.pbj.CacheableAccountID}
com.hedera.pbj.test.proto.pbj.tests.CacheableAccountIDTest ‑ [4] NoToStringWrapper{com.hedera.pbj.test.proto.pbj.CacheableAccountID}
…

♻️ This comment has been updated with latest results.

Signed-off-by: Anthony Petrov <anthony@swirldslabs.com>
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.

Consider caching when parsing

1 participant