Skip to content

Conversation

@tomusdrw
Copy link
Contributor

@tomusdrw tomusdrw commented Nov 3, 2025

  • latest w3f-davxy main branch
  • latest jam-conformance traces

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 3, 2025

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added BigInt support for gas value handling and parsing across the system for improved precision.
  • Chores

    • Updated test vector configurations for JAM conformance and W3F compatibility testing.
    • Refactored accumulation result processing for improved data aggregation and state updates.
    • Enhanced preimage tracking to include service context information.
    • Simplified privileged service update mechanisms and parameter naming.

Walkthrough

This changeset: adds a json.fromBigInt helper; switches multiple gas-related JSON deserializers from number to bigint; extends UpdatePreimage.provide to include a providedFor (serviceId) field; propagates providedFor through preimage creation and tests; refactors accumulation to collect per-service parallel results as a Map and introduces mergePerallelAccumulationResults plus helpers (getTransfers, updateStatistics, updateYieldedRoots); adds accumulation-result-merge-utils to merge per-service results; updates accumulate-externalities to remove per-field privileged-service reconciliation and to apply preimage updates to both target and current service when different; adjusts test runners and load-test REF.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45–60 minutes

  • Files/areas requiring focused review:
    • packages/jam/transition/accumulate/accumulate.ts — large refactor to per-service Map results and new merge/update helpers.
    • packages/jam/transition/accumulate/accumulation-result-merge-utils.ts — new merge logic that composes final state and gas accounting.
    • packages/jam/transition/externalities/accumulate-externalities.ts & packages/jam/transition/preimages.ts — API/name changes and new preimage propagation behavior.
    • JSON parsing changes: packages/core/json-parser/descriptors.ts and all modified state-json/work-*.ts — ensure bigint handling is correct and consistent.
    • Tests and call-sites: packages/jam/state/in-memory-state.test.ts, externalities tests — verify UpdatePreimage.provide signature changes are fully propagated.

Possibly related PRs

Suggested reviewers

  • tomusdrw
  • DrEverr

Poem

🐇 I hopped through JSON, found BigInt in store,
Gave preimages a name — providedFor, and more.
Services now map their little gas trail,
Merged every hop into one tidy tale,
Tiny rabbit cheers: merge, parse, and soar! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.79% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'Bump test-vectors' is vague and generic. It uses a non-descriptive term ('Bump') that doesn't clearly convey the specific nature of the changes beyond indicating version updates. Consider a more descriptive title that specifies which test vectors are being updated or updated. For example: 'Update test vector references for w3f-davxy and jam-conformance' or 'Update test vector traces and references'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The description is related to the changeset. It mentions 'latest w3f-davxy main branch' and 'latest jam-conformance traces', which correspond to test vector updates visible in the pull request files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch td-071-traces

Comment @coderabbitai help to get the list of available commands and usage tips.

@tomusdrw
Copy link
Contributor Author

tomusdrw commented Nov 6, 2025

@fluffylabs-bot benchmark

@fluffylabs-bot
Copy link

fluffylabs-bot bot commented Nov 6, 2025

Benchmark workflow triggered successfully! 🎉
Requested by: @tomusdrw
PR number: #758
Target repository: FluffyLabs/typeberry-testing

🔗 Check the Actions tab for workflow progress.

@fluffylabs-bot
Copy link

fluffylabs-bot bot commented Nov 6, 2025

Picofuzz Benchmark Results

fallback

Metric Baseline Current Difference
min 43.52ms 13.45ms 🟢 -30.07ms (-69.10%)
mean 59.21ms 16.33ms 🟢 -42.88ms (-72.42%)
p90 64.46ms 18.50ms 🟢 -45.96ms (-71.30%)
p99 72.28ms 23.84ms 🟢 -48.44ms (-67.02%)

safrole

Metric Baseline Current Difference
min 46.08ms 13.08ms 🟢 -33.01ms (-71.63%)
mean 108.27ms 65.24ms 🟢 -43.03ms (-39.75%)
p90 183.14ms 142.95ms 🟢 -40.20ms (-21.95%)
p99 194.51ms 149.19ms 🟢 -45.33ms (-23.30%)

storage

Metric Baseline Current Difference
min 45.27ms 14.40ms 🟢 -30.86ms (-68.18%)
mean 280.08ms 48.01ms 🟢 -232.07ms (-82.86%)
p90 660.18ms 92.80ms 🟢 -567.37ms (-85.94%)
p99 983.43ms 120.44ms 🟢 -862.99ms (-87.75%)

storage_light

Metric Baseline Current Difference
min 46.11ms 15.81ms 🟢 -30.30ms (-65.71%)
mean 122.74ms 32.78ms 🟢 -89.95ms (-73.29%)
p90 218.95ms 47.87ms 🟢 -171.08ms (-78.14%)
p99 410.08ms 71.85ms 🟢 -338.23ms (-82.48%)

🤖 Automated benchmark

@tomusdrw tomusdrw marked this pull request as ready for review November 6, 2025 22:27
@tomusdrw tomusdrw requested a review from DrEverr November 6, 2025 22:27
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/jam/transition/accumulate/accumulate.ts (1)

868-878: Return the actual pending transfers

legacyTransfers only accumulates values in the pre‑0.7.1 path, so for modern flows we always return an empty array even when services emitted transfers. After fixing the merge above, the real data sits in state.transfers—we should return it.

-      pendingTransfers: legacyTransfers,
+      pendingTransfers: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
+        ? state.transfers
+        : legacyTransfers,

Otherwise every transfer executed during accumulation is silently dropped.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dabd741 and dc51c3c.

📒 Files selected for processing (13)
  • .github/scripts/load-test-ref.sh (1 hunks)
  • bin/test-runner/jam-conformance-070.ts (1 hunks)
  • bin/test-runner/w3f-davxy-071.ts (1 hunks)
  • packages/core/json-parser/descriptors.ts (1 hunks)
  • packages/jam/block-json/work-report.ts (1 hunks)
  • packages/jam/block-json/work-result.ts (1 hunks)
  • packages/jam/state-json/statistics.ts (2 hunks)
  • packages/jam/state/in-memory-state.test.ts (7 hunks)
  • packages/jam/state/state-update.ts (2 hunks)
  • packages/jam/transition/accumulate/accumulate.ts (15 hunks)
  • packages/jam/transition/externalities/accumulate-externalities.test.ts (7 hunks)
  • packages/jam/transition/externalities/accumulate-externalities.ts (3 hunks)
  • packages/jam/transition/preimages.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
packages/core/**/*.ts

⚙️ CodeRabbit configuration file

packages/core/**/*.ts: Core packages must not import any JAM-related packages
(i.e. packages defined under packages/jam/**)

Files:

  • packages/core/json-parser/descriptors.ts
**/*.ts

⚙️ CodeRabbit configuration file

**/*.ts: rules from ./CODESTYLE.md should be adhered to.

**/*.ts: Any function whose documentation mention it must not be used in production code,
can be safely used in *.test.ts files. Other usage should be carefuly reviewed
and the comment must explain why it's safe to use there.

**/*.ts: as conversions must not be used. Suggest using tryAs conversion methods.

**/*.ts: Classes with static Codec field must have private constructor and static create method.

**/*.ts: Casting a bigint (or U64) using Number(x) must have an explanation comment why
it is safe.

**/*.ts: When making changes to code with comments containing links (in classes, constants, methods, etc.)
to graypaper.fluffylabs.dev, ensure those links point to the current version for this update.

Files:

  • packages/core/json-parser/descriptors.ts
  • packages/jam/block-json/work-result.ts
  • packages/jam/state/in-memory-state.test.ts
  • packages/jam/state/state-update.ts
  • bin/test-runner/w3f-davxy-071.ts
  • packages/jam/block-json/work-report.ts
  • packages/jam/transition/preimages.ts
  • bin/test-runner/jam-conformance-070.ts
  • packages/jam/state-json/statistics.ts
  • packages/jam/transition/externalities/accumulate-externalities.test.ts
  • packages/jam/transition/externalities/accumulate-externalities.ts
  • packages/jam/transition/accumulate/accumulate.ts
🧠 Learnings (4)
📓 Common learnings
Learnt from: tomusdrw
Repo: FluffyLabs/typeberry PR: 419
File: packages/jam/transition/accumulate/accumulate.ts:193-193
Timestamp: 2025-06-10T12:04:56.072Z
Learning: In the typeberry codebase, the Service.getPreimage() method was updated to return BytesBlob | null directly instead of PreimageItem | null, so the returned value is already a BytesBlob and doesn't need .blob property access.
📚 Learning: 2025-06-10T12:20:17.513Z
Learnt from: tomusdrw
Repo: FluffyLabs/typeberry PR: 419
File: packages/jam/state/state-inmemory.ts:141-149
Timestamp: 2025-06-10T12:20:17.513Z
Learning: In the `InMemoryService.copyFrom` function in `packages/jam/state/state-inmemory.ts`, duplicate checking for `(hash, length)` pairs in the lookup history is not necessary because the function operates under the assumption that the input `ServiceEntries` comes from an existing well-formed state, which already maintains the invariant of unique lookup history entries per hash and length combination.

Applied to files:

  • packages/jam/state/in-memory-state.test.ts
📚 Learning: 2025-06-10T12:10:10.532Z
Learnt from: tomusdrw
Repo: FluffyLabs/typeberry PR: 419
File: packages/jam/state-merkleization/serialize-update.ts:115-126
Timestamp: 2025-06-10T12:10:10.532Z
Learning: In packages/jam/state-merkleization/serialize-update.ts, service removal is handled separately from service updates. The UpdateServiceKind enum does not include a Remove variant. Service removals are handled via the servicesRemoved parameter in serializeUpdate() which is processed by serializeRemovedServices(), while service updates/creations are handled via servicesUpdates parameter processed by serializeServiceUpdates().

Applied to files:

  • packages/jam/state/in-memory-state.test.ts
  • packages/jam/state/state-update.ts
  • packages/jam/transition/externalities/accumulate-externalities.test.ts
  • packages/jam/transition/externalities/accumulate-externalities.ts
  • packages/jam/transition/accumulate/accumulate.ts
📚 Learning: 2025-06-10T12:04:56.072Z
Learnt from: tomusdrw
Repo: FluffyLabs/typeberry PR: 419
File: packages/jam/transition/accumulate/accumulate.ts:193-193
Timestamp: 2025-06-10T12:04:56.072Z
Learning: In the typeberry codebase, the Service.getPreimage() method was updated to return BytesBlob | null directly instead of PreimageItem | null, so the returned value is already a BytesBlob and doesn't need .blob property access.

Applied to files:

  • packages/jam/state/state-update.ts
  • packages/jam/transition/externalities/accumulate-externalities.test.ts
  • packages/jam/transition/externalities/accumulate-externalities.ts
  • packages/jam/transition/accumulate/accumulate.ts
🧬 Code graph analysis (8)
packages/core/json-parser/descriptors.ts (1)
packages/core/json-parser/types.ts (2)
  • Parser (28-28)
  • FromJsonWithParser (31-31)
packages/jam/block-json/work-result.ts (1)
packages/jam/block/common.ts (1)
  • tryAsServiceGas (32-32)
packages/jam/state/state-update.ts (2)
packages/jam/state/service.ts (1)
  • PreimageItem (158-174)
packages/jam/block/common.ts (1)
  • TimeSlot (16-16)
packages/jam/block-json/work-report.ts (1)
packages/jam/block/common.ts (1)
  • tryAsServiceGas (32-32)
packages/jam/state-json/statistics.ts (2)
packages/jam/block/common.ts (1)
  • tryAsServiceGas (32-32)
packages/core/utils/compatibility.ts (1)
  • Compatibility (50-109)
packages/jam/transition/externalities/accumulate-externalities.test.ts (3)
packages/jam/block/common.ts (1)
  • tryAsServiceId (28-28)
packages/jam/state/state-update.ts (1)
  • UpdatePreimage (24-103)
packages/jam/state/service.ts (1)
  • PreimageItem (158-174)
packages/jam/transition/externalities/accumulate-externalities.ts (5)
packages/jam/state/common.ts (1)
  • PerCore (8-8)
packages/jam/block/common.ts (3)
  • ServiceId (26-26)
  • ServiceGas (31-31)
  • tryAsServiceId (28-28)
packages/jam/state/privileged-services.ts (1)
  • PrivilegedServices (10-48)
packages/jam/state/state-update.ts (2)
  • update (130-135)
  • UpdatePreimage (24-103)
packages/jam/state/service.ts (1)
  • PreimageItem (158-174)
packages/jam/transition/accumulate/accumulate.ts (8)
packages/jam/jam-host-calls/externalities/state-update.ts (1)
  • AccumulationStateUpdate (51-138)
packages/jam/block/common.ts (5)
  • ServiceGas (31-31)
  • ServiceId (26-26)
  • tryAsServiceGas (32-32)
  • TimeSlot (16-16)
  • EntropyHash (40-40)
packages/core/numbers/index.ts (3)
  • U32 (21-21)
  • sumU64 (93-104)
  • tryAsU32 (45-48)
packages/jam/jam-host-calls/externalities/pending-transfer.ts (1)
  • PendingTransfer (12-37)
packages/jam/transition/statistics.ts (1)
  • CountAndGasUsed (51-54)
packages/jam/transition/accumulate/accumulate-data.ts (1)
  • AccumulateData (26-215)
packages/jam/state/privileged-services.ts (1)
  • PrivilegedServices (10-48)
packages/jam/state/common.ts (1)
  • tryAsPerCore (10-16)
⏰ Context from checks skipped due to timeout of 120000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: e2e (22.x)
  • GitHub Check: benchmarks (22.x)
  • GitHub Check: run (22.x)
  • GitHub Check: state_transition (22.x)
  • GitHub Check: run (22.x)
  • GitHub Check: test (22.x)
🔇 Additional comments (8)
bin/test-runner/jam-conformance-070.ts (1)

9-10: LGTM! Appropriate handling of buggy test vectors.

The addition of these ignored test vectors is well-documented and aligns with the test-vectors bump in this PR.

.github/scripts/load-test-ref.sh (1)

2-2: LGTM! Test vectors reference updated.

The update to the new commit hash aligns with the PR objective of bumping test-vectors.

bin/test-runner/w3f-davxy-071.ts (1)

9-9: LGTM! Test coverage expanded.

Removing previously ignored test vectors suggests these tests are now passing with the updated test-vectors.

packages/core/json-parser/descriptors.ts (1)

15-26: LGTM! Well-designed BigInt parser.

The new fromBigInt function provides flexible handling of numeric inputs by accepting both number and bigint, converting numbers to BigInt before parsing. Using "object" as the discriminator (similar to fromAny) is appropriate for handling multiple input types.

packages/jam/block-json/work-result.ts (1)

80-80: LGTM! Consistent BigInt migration for gas field.

The change from fromNumber to fromBigInt for accumulate_gas is compatible with tryAsServiceGas which accepts number | bigint, and aligns with the BigInt migration for gas fields across the codebase.

packages/jam/block-json/work-report.ts (1)

50-50: LGTM! Consistent BigInt migration for gas field.

The migration of auth_gas_used to fromBigInt is consistent with the broader gas field updates across the codebase.

packages/jam/state-json/statistics.ts (1)

48-48: LGTM! Comprehensive BigInt migration for all gas fields.

All gas-related fields in statistics (gas_used, refinement_gas_used, accumulate_gas_used, on_transfers_gas_used) have been consistently migrated to use fromBigInt, aligning with the broader codebase changes.

Also applies to: 80-80, 86-86, 90-90

packages/jam/transition/preimages.ts (1)

84-84: LGTM! Appropriate addition of providedFor metadata.

Adding providedFor: requester to track which service the preimage is being provided for is logically sound and aligns with the infrastructure changes for preimage provision metadata tracking mentioned in the PR summary.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/jam/transition/accumulate/accumulate.ts (1)

646-728: Surface transfers produced by the ≥0.7.1 accumulation path.

In the modern branch we never mutate legacyTransfers, yet we still return it as pendingTransfers, so every transfer emitted during accumulation disappears from the transition output. Thread the actual transfers coming back from accumulateSequentially and return them here (e.g. extend SequentialAccumulationResult to include transfers and propagate that value).

-    const { accumulatedReports, gasCost, state, ...rest } = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
+    const {
+      accumulatedReports,
+      gasCost,
+      state,
+      transfers: pendingTransfers,
+      ...rest
+    } = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
         ? await this.accumulateSequentially(
             gasLimit,
             accumulatableReports,
-            [],
+            [],
             slot,
             entropy,
             statistics,
             AccumulationStateUpdate.empty(),
             autoAccumulateServices,
             yieldedRoots,
           )
         : await this.accumulateSequentiallyLegacy(
             gasLimit,
             accumulatableReports,
             slot,
             entropy,
             statistics,
             AccumulationStateUpdate.empty(),
             autoAccumulateServices,
             yieldedRoots,
             legacyTransfers,
           );
@@
-      pendingTransfers: legacyTransfers,
+      pendingTransfers: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1) ? pendingTransfers : legacyTransfers,

(Be sure to update both sequential helpers so the ≥0.7.1 path returns the accumulated transfers.)

♻️ Duplicate comments (1)
packages/jam/transition/accumulate/accumulation-result-merge-utils.ts (1)

200-208: Don’t drop preimages added by other services.

Overwriting outputState.services.preimages with only currentServiceUpdates discards entries already queued for this service by other providers (or from inputState), so the hand-off vanishes as soon as we merge the recipient’s own result. Merge with the existing array instead of replacing it.

-    outputState.services.preimages.set(serviceId, currentServiceUpdates);
+    if (currentServiceUpdates.length > 0) {
+      const existing = outputState.services.preimages.get(serviceId) ?? [];
+      outputState.services.preimages.set(serviceId, [...existing, ...currentServiceUpdates]);
+    }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc51c3c and bcfac21.

📒 Files selected for processing (2)
  • packages/jam/transition/accumulate/accumulate.ts (14 hunks)
  • packages/jam/transition/accumulate/accumulation-result-merge-utils.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.ts

⚙️ CodeRabbit configuration file

**/*.ts: rules from ./CODESTYLE.md should be adhered to.

**/*.ts: Any function whose documentation mention it must not be used in production code,
can be safely used in *.test.ts files. Other usage should be carefuly reviewed
and the comment must explain why it's safe to use there.

**/*.ts: as conversions must not be used. Suggest using tryAs conversion methods.

**/*.ts: Classes with static Codec field must have private constructor and static create method.

**/*.ts: Casting a bigint (or U64) using Number(x) must have an explanation comment why
it is safe.

**/*.ts: When making changes to code with comments containing links (in classes, constants, methods, etc.)
to graypaper.fluffylabs.dev, ensure those links point to the current version for this update.

Files:

  • packages/jam/transition/accumulate/accumulation-result-merge-utils.ts
  • packages/jam/transition/accumulate/accumulate.ts
🧠 Learnings (2)
📚 Learning: 2025-06-10T12:10:10.532Z
Learnt from: tomusdrw
Repo: FluffyLabs/typeberry PR: 419
File: packages/jam/state-merkleization/serialize-update.ts:115-126
Timestamp: 2025-06-10T12:10:10.532Z
Learning: In packages/jam/state-merkleization/serialize-update.ts, service removal is handled separately from service updates. The UpdateServiceKind enum does not include a Remove variant. Service removals are handled via the servicesRemoved parameter in serializeUpdate() which is processed by serializeRemovedServices(), while service updates/creations are handled via servicesUpdates parameter processed by serializeServiceUpdates().

Applied to files:

  • packages/jam/transition/accumulate/accumulation-result-merge-utils.ts
  • packages/jam/transition/accumulate/accumulate.ts
📚 Learning: 2025-06-10T12:20:17.513Z
Learnt from: tomusdrw
Repo: FluffyLabs/typeberry PR: 419
File: packages/jam/state/state-inmemory.ts:141-149
Timestamp: 2025-06-10T12:20:17.513Z
Learning: In the `InMemoryService.copyFrom` function in `packages/jam/state/state-inmemory.ts`, duplicate checking for `(hash, length)` pairs in the lookup history is not necessary because the function operates under the assumption that the input `ServiceEntries` comes from an existing well-formed state, which already maintains the invariant of unique lookup history entries per hash and length combination.

Applied to files:

  • packages/jam/transition/accumulate/accumulate.ts
🧬 Code graph analysis (2)
packages/jam/transition/accumulate/accumulation-result-merge-utils.ts (8)
packages/jam/config/chain-spec.ts (1)
  • ChainSpec (41-106)
packages/jam/transition/accumulate/accumulate-state.ts (1)
  • AccumulateState (23-32)
packages/jam/jam-host-calls/externalities/state-update.ts (1)
  • AccumulationStateUpdate (51-138)
packages/jam/block/common.ts (2)
  • ServiceGas (31-31)
  • tryAsServiceGas (32-32)
packages/jam/jam-host-calls/externalities/pending-transfer.ts (1)
  • PendingTransfer (12-37)
packages/jam/state/privileged-services.ts (1)
  • PrivilegedServices (10-48)
packages/jam/state/common.ts (1)
  • tryAsPerCore (10-16)
packages/core/numbers/index.ts (1)
  • sumU64 (93-104)
packages/jam/transition/accumulate/accumulate.ts (5)
packages/jam/jam-host-calls/externalities/state-update.ts (1)
  • AccumulationStateUpdate (51-138)
packages/jam/block/common.ts (5)
  • ServiceGas (31-31)
  • tryAsServiceGas (32-32)
  • ServiceId (26-26)
  • TimeSlot (16-16)
  • EntropyHash (40-40)
packages/jam/transition/accumulate/accumulation-result-merge-utils.ts (2)
  • mergePerallelAccumulationResults (9-27)
  • ParallelAccumulationResult (33-33)
packages/jam/transition/statistics.ts (1)
  • CountAndGasUsed (51-54)
packages/jam/transition/accumulate/accumulate-data.ts (1)
  • AccumulateData (26-215)
⏰ Context from checks skipped due to timeout of 120000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: run (22.x)
  • GitHub Check: test (22.x)
  • GitHub Check: run (22.x)
  • GitHub Check: run (22.x)
  • GitHub Check: e2e (22.x)
  • GitHub Check: state_transition (22.x)

@github-actions
Copy link

github-actions bot commented Nov 7, 2025

View all
File Benchmark Ops
bytes/hex-to.ts[0] number toString + padding 272871.6 ±1.54% fastest ✅
bytes/hex-to.ts[1] manual 14610.23 ±1.7% 94.65% slower
codec/bigint.decode.ts[0] decode custom 156801373.22 ±3.26% fastest ✅
codec/bigint.decode.ts[1] decode bigint 91548957.07 ±2.8% 41.61% slower
codec/encoding.ts[0] manual encode 2570005.95 ±1.06% 16.88% slower
codec/encoding.ts[1] int32array encode 3006214.85 ±1.27% 2.77% slower
codec/encoding.ts[2] dataview encode 3091760.28 ±1.04% fastest ✅
bytes/hex-from.ts[0] parse hex using Number with NaN checking 124175.98 ±1.13% 83.85% slower
bytes/hex-from.ts[1] parse hex from char codes 768739.85 ±1.4% fastest ✅
bytes/hex-from.ts[2] parse hex from string nibbles 514340.69 ±0.82% 33.09% slower
math/count-bits-u64.ts[0] standard method 1380471.92 ±1.22% 84.81% slower
math/count-bits-u64.ts[1] magic 9088621.72 ±1.98% fastest ✅
math/add_one_overflow.ts[0] add and take modulus 228195570.88 ±6.26% fastest ✅
math/add_one_overflow.ts[1] condition before calculation 208542265.16 ±6.99% 8.61% slower
math/mul_overflow.ts[0] multiply and bring back to u32 210300110.27 ±7.93% fastest ✅
math/mul_overflow.ts[1] multiply and take modulus 200328010.23 ±7.58% 4.74% slower
math/count-bits-u32.ts[0] standard method 71973469.05 ±2.76% 65.99% slower
math/count-bits-u32.ts[1] magic 211639759.75 ±5.61% fastest ✅
math/switch.ts[0] switch 229503032.73 ±7.06% fastest ✅
math/switch.ts[1] if 220491264.71 ±6% 3.93% slower
hash/index.ts[0] hash with numeric representation 168.53 ±1.33% 34.29% slower
hash/index.ts[1] hash with string representation 105.67 ±1.72% 58.8% slower
hash/index.ts[2] hash with symbol representation 178.63 ±0.38% 30.35% slower
hash/index.ts[3] hash with uint8 representation 163.56 ±0.3% 36.23% slower
hash/index.ts[4] hash with packed representation 256.48 ±0.45% fastest ✅
hash/index.ts[5] hash with bigint representation 187.06 ±0.5% 27.07% slower
hash/index.ts[6] hash with uint32 representation 202.41 ±0.36% 21.08% slower
codec/bigint.compare.ts[0] compare custom 246341448.26 ±5.28% fastest ✅
codec/bigint.compare.ts[1] compare bigint 246031319.39 ±7.1% 0.13% slower
codec/decoding.ts[0] manual decode 22650143.51 ±0.71% 86.24% slower
codec/decoding.ts[1] int32array decode 164549253.47 ±3.31% fastest ✅
codec/decoding.ts[2] dataview decode 153262082.23 ±3.32% 6.86% slower
collections/map-set.ts[0] 2 gets + conditional set 119352.4 ±0.4% fastest ✅
collections/map-set.ts[1] 1 get 1 set 60625.81 ±0.42% 49.2% slower
logger/index.ts[0] console.log with string concat 8517908.61 ±37.84% fastest ✅
logger/index.ts[1] console.log with args 640848.21 ±99.56% 92.48% slower
codec/view_vs_collection.ts[0] Get first element from Decoded 23652.5 ±1.39% 57.29% slower
codec/view_vs_collection.ts[1] Get first element from View 55374.74 ±1.04% fastest ✅
codec/view_vs_collection.ts[2] Get 50th element from Decoded 25564.49 ±1.11% 53.83% slower
codec/view_vs_collection.ts[3] Get 50th element from View 28026.82 ±1.25% 49.39% slower
codec/view_vs_collection.ts[4] Get last element from Decoded 24373.56 ±1.6% 55.98% slower
codec/view_vs_collection.ts[5] Get last element from View 17747.03 ±1.76% 67.95% slower
codec/view_vs_object.ts[0] Get the first field from Decoded 402615.41 ±0.83% fastest ✅
codec/view_vs_object.ts[1] Get the first field from View 85797.59 ±0.78% 78.69% slower
codec/view_vs_object.ts[2] Get the first field as view from View 82048.97 ±0.78% 79.62% slower
codec/view_vs_object.ts[3] Get two fields from Decoded 395584.86 ±0.96% 1.75% slower
codec/view_vs_object.ts[4] Get two fields from View 67902.69 ±0.81% 83.13% slower
codec/view_vs_object.ts[5] Get two fields from materialized from View 140616.35 ±1.08% 65.07% slower
codec/view_vs_object.ts[6] Get two fields as views from View 65547.35 ±0.85% 83.72% slower
codec/view_vs_object.ts[7] Get only third field from Decoded 399399.57 ±0.83% 0.8% slower
codec/view_vs_object.ts[8] Get only third field from View 83938.96 ±0.83% 79.15% slower
codec/view_vs_object.ts[9] Get only third field as view from View 82322.82 ±0.92% 79.55% slower
bytes/compare.ts[0] Comparing Uint32 bytes 15687.38 ±2.68% 22.58% slower
bytes/compare.ts[1] Comparing raw bytes 20262.41 ±2.8% fastest ✅
collections/map_vs_sorted.ts[0] Map 285282.86 ±0.32% fastest ✅
collections/map_vs_sorted.ts[1] Map-array 101662.63 ±0.38% 64.36% slower
collections/map_vs_sorted.ts[2] Array 46027.05 ±4.6% 83.87% slower
collections/map_vs_sorted.ts[3] SortedArray 191338.24 ±0.42% 32.93% slower
hash/blake2b.ts[0] our hasher 2.18 ±1.63% fastest ✅
hash/blake2b.ts[1] blake2b js 0.05 ±0.53% 97.71% slower
crypto/ed25519.ts[0] native crypto 5.92 ±16.84% 80.71% slower
crypto/ed25519.ts[1] wasm lib 10.89 ±0.03% 64.52% slower
crypto/ed25519.ts[2] wasm lib batch 30.69 ±0.44% fastest ✅

Benchmarks summary: 63/63 OK ✅

Copy link
Contributor Author

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! Can't approve, because it's my PR 😅

@tomusdrw tomusdrw merged commit 262995a into main Nov 10, 2025
16 checks passed
@tomusdrw tomusdrw deleted the td-071-traces branch November 10, 2025 12:56
@tomusdrw
Copy link
Contributor Author

@mateuszsikora please address the comments and add any other stuff that you wanted in a separate PR.

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.

4 participants