Skip to content

Add lite interpreter#921

Draft
mateuszsikora wants to merge 15 commits intomainfrom
ms-add-lite-interpreter
Draft

Add lite interpreter#921
mateuszsikora wants to merge 15 commits intomainfrom
ms-add-lite-interpreter

Conversation

@mateuszsikora
Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 4, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4a0f9053-1efa-4b1e-afcc-6a5a67010fb2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR introduces support for a new "Lite" PVM backend variant across the codebase. Changes include adding a Lite member to the SelectedPvm enum, updating the ALL_PVMS configuration array, extending the selectedPvmToBackend converter function, and adding the variant to test runner configurations. A new dependency on @fluffylabs/pvm-interpreter-lite is added, along with instantiation logic in the PvmInstanceManager. The PvmBackend enum and PvmBackendNames array are expanded to support the third backend option.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Run STF tests using only one VM #798 — Established the foundational multi-PVM architecture that this PR extends by adding the Lite variant to existing enums, converters, and test infrastructure.

Suggested reviewers

  • skoszuta
  • tomusdrw
  • DrEverr

Poem

🐰 A fluffy tale of backends new,
Where Lite hops in to join the crew,
With Ananas and BuiltIn standing tall,
Three PVMs answer to the call!
Enum'd, convert'd, test'd with care—
The Lite one floats upon the air! 🌟

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to evaluate relatedness to the changeset. Please provide a pull request description explaining the purpose and scope of adding the Lite interpreter support.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add lite interpreter' directly and clearly describes the main change—adding support for a new Lite PVM backend interpreter throughout the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ms-add-lite-interpreter

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@mateuszsikora mateuszsikora marked this pull request as draft March 4, 2026 15:24
Copy link
Copy Markdown
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

🧹 Nitpick comments (2)
packages/jam/config/pvm-backend.ts (1)

2-2: Add Lite to accumulate backend test matrix.

packages/jam/transition/accumulate/accumulate.test.ts currently loops only over BuiltIn/Ananas, so the new Lite backend path is not covered there.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/jam/config/pvm-backend.ts` at line 2, The test matrix in
accumulate.test.ts omits the new "lite" backend; update the test to include Lite
by either referencing the exported PvmBackendNames array (export const
PvmBackendNames) so the loop automatically covers "built-in", "ananas", and
"lite", or explicitly add "lite" to the list used in the test runner so the
accumulate tests exercise the Lite backend path as well.
bin/test-runner/w3f/runners.ts (1)

50-50: Consider reusing ALL_PVMS to avoid backend list drift.

This list is now duplicated from bin/test-runner/common.ts; importing ALL_PVMS here would reduce future update misses when new backends are added.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bin/test-runner/w3f/runners.ts` at line 50, The pvms array duplicates the
backend list; replace the hard-coded const pvms: SelectedPvm[] = [...] with an
import and usage of the canonical ALL_PVMS to avoid drift: import ALL_PVMS (or
the exported name holding all SelectedPvm values) from the module that defines
it and use that constant wherever pvms is referenced (replace references to pvms
with ALL_PVMS and remove the local SelectedPvm array declaration).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/jam/config/pvm-backend.ts`:
- Around line 10-11: The new enum value PvmBackend.Lite (numeric value 2) is not
handled by the importer deserialization logic and causes "Invalid PvmBackend: 2"
at runtime; update the importer protocol deserializer (the function that
validates/parses PvmBackend in packages/workers/importer/protocol.ts) to accept
numeric value 2 and map it to PvmBackend.Lite (add a case/branch for 2 or
include 2 in the allowed values), ensuring the deserializer returns the
PvmBackend.Lite enum value instead of rejecting it and adjust any related error
text to include unexpected values only.

---

Nitpick comments:
In `@bin/test-runner/w3f/runners.ts`:
- Line 50: The pvms array duplicates the backend list; replace the hard-coded
const pvms: SelectedPvm[] = [...] with an import and usage of the canonical
ALL_PVMS to avoid drift: import ALL_PVMS (or the exported name holding all
SelectedPvm values) from the module that defines it and use that constant
wherever pvms is referenced (replace references to pvms with ALL_PVMS and remove
the local SelectedPvm array declaration).

In `@packages/jam/config/pvm-backend.ts`:
- Line 2: The test matrix in accumulate.test.ts omits the new "lite" backend;
update the test to include Lite by either referencing the exported
PvmBackendNames array (export const PvmBackendNames) so the loop automatically
covers "built-in", "ananas", and "lite", or explicitly add "lite" to the list
used in the test runner so the accumulate tests exercise the Lite backend path
as well.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e025cbea-5678-4027-a9a8-c3c8c5a85f8c

📥 Commits

Reviewing files that changed from the base of the PR and between b3da767 and 131d2b2.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • bin/test-runner/common.ts
  • bin/test-runner/javajam-071.ts
  • bin/test-runner/w3f/accumulate.ts
  • bin/test-runner/w3f/runners.ts
  • packages/core/pvm-host-calls/package.json
  • packages/core/pvm-host-calls/pvm-instance-manager.ts
  • packages/jam/config/pvm-backend.ts

Comment thread packages/jam/config/pvm-backend.ts
@mateuszsikora
Copy link
Copy Markdown
Contributor Author

@fluffylabs-bot benchmark

@fluffylabs-bot
Copy link
Copy Markdown
Contributor

fluffylabs-bot Bot commented Mar 5, 2026

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

🔗 Check the Actions tab for workflow progress.

@fluffylabs-bot
Copy link
Copy Markdown
Contributor

fluffylabs-bot Bot commented Mar 5, 2026

Picofuzz Benchmark Results

fallback

Metric @typeberry/jam@0.5.7 Current Difference
min 4.32ms 3.80ms 🟢 -0.51ms (-11.88%)
mean 6.15ms 5.56ms ≈ -0.60ms (-9.72%)
p90 7.96ms 7.79ms ≈ -0.17ms (-2.18%)
p99 11.74ms 10.19ms 🟢 -1.55ms (-13.21%)

safrole

Metric @typeberry/jam@0.5.7 Current Difference
min 4.46ms 4.02ms ≈ -0.44ms (-9.77%)
mean 13.92ms 13.51ms ≈ -0.41ms (-2.94%)
p90 24.77ms 24.36ms ≈ -0.41ms (-1.65%)
p99 30.28ms 30.24ms ≈ -0.04ms (-0.13%)

storage

Metric @typeberry/jam@0.5.7 Current Difference
min 4.74ms 4.45ms ≈ -0.29ms (-6.10%)
mean 33.43ms 35.56ms ≈ +2.13ms (+6.36%)
p90 70.91ms 82.32ms 🔴 +11.41ms (+16.09%)
p99 95.21ms 120.68ms 🔴 +25.47ms (+26.75%)

storage_light

Metric @typeberry/jam@0.5.7 Current Difference
min 6.59ms 6.09ms ≈ -0.50ms (-7.61%)
mean 20.92ms 19.91ms ≈ -1.02ms (-4.86%)
p90 33.27ms 34.45ms ≈ +1.17ms (+3.52%)
p99 44.34ms 46.88ms ≈ +2.54ms (+5.72%)

🤖 Automated benchmark

@mateuszsikora mateuszsikora force-pushed the ms-add-lite-interpreter branch from c5cd60c to a412f33 Compare March 10, 2026 10:44
Comment thread packages/README.md
@mateuszsikora
Copy link
Copy Markdown
Contributor Author

@fluffylabs-bot benchmark

@fluffylabs-bot
Copy link
Copy Markdown
Contributor

fluffylabs-bot Bot commented Mar 10, 2026

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

🔗 Check the Actions tab for workflow progress.

@mateuszsikora
Copy link
Copy Markdown
Contributor Author

@fluffylabs-bot benchmark

@fluffylabs-bot
Copy link
Copy Markdown
Contributor

fluffylabs-bot Bot commented Mar 10, 2026

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

🔗 Check the Actions tab for workflow progress.

@mateuszsikora
Copy link
Copy Markdown
Contributor Author

@fluffylabs-bot benchmark

@fluffylabs-bot
Copy link
Copy Markdown
Contributor

fluffylabs-bot Bot commented Mar 11, 2026

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

🔗 Check the Actions tab for workflow progress.

@github-actions
Copy link
Copy Markdown

View all
File Benchmark Ops
bytes/hex-from.ts[0] parse hex using Number with NaN checking 62208.3 ±3.55% 86.49% slower
bytes/hex-from.ts[1] parse hex from char codes 460517.46 ±0.39% fastest ✅
bytes/hex-from.ts[2] parse hex from string nibbles 258459.63 ±0.48% 43.88% slower
bytes/hex-to.ts[0] number toString + padding 90294.15 ±0.69% fastest ✅
bytes/hex-to.ts[1] manual 7426.98 ±0.66% 91.77% slower
codec/bigint.compare.ts[0] compare custom 94750792.86 ±4.84% fastest ✅
codec/bigint.compare.ts[1] compare bigint 91389232.69 ±5.6% 3.55% slower
codec/bigint.decode.ts[0] decode custom 71128313.42 ±3.42% 26.43% slower
codec/bigint.decode.ts[1] decode bigint 96682932.43 ±4.06% fastest ✅
codec/decoding.ts[0] manual decode 9887056.46 ±0.56% 85.65% slower
codec/decoding.ts[1] int32array decode 65823175.09 ±3.44% 4.43% slower
codec/decoding.ts[2] dataview decode 68877199.34 ±3.22% fastest ✅
codec/encoding.ts[0] manual encode 1076838.49 ±0.8% 13.25% slower
codec/encoding.ts[1] int32array encode 1241290.16 ±0.25% fastest ✅
codec/encoding.ts[2] dataview encode 1208999.03 ±0.29% 2.6% slower
collections/map-set.ts[0] 2 gets + conditional set 71192.9 ±0.17% fastest ✅
collections/map-set.ts[1] 1 get 1 set 47014.41 ±0.45% 33.96% slower
logger/index.ts[0] console.log with string concat 4754937.7 ±41.08% fastest ✅
logger/index.ts[1] console.log with args 1431163.28 ±81.97% 69.9% slower
math/add_one_overflow.ts[0] add and take modulus 55339658.9 ±60.47% 44.22% slower
math/add_one_overflow.ts[1] condition before calculation 99203262.18 ±5.08% fastest ✅
math/count-bits-u32.ts[0] standard method 38539545.18 ±2.16% 57.05% slower
math/count-bits-u32.ts[1] magic 89740574.93 ±4.22% fastest ✅
math/count-bits-u64.ts[0] standard method 284375.07 ±0.5% 90.4% slower
math/count-bits-u64.ts[1] magic 2961508.4 ±0.44% fastest ✅
math/mul_overflow.ts[0] multiply and bring back to u32 95242736.69 ±5.11% fastest ✅
math/mul_overflow.ts[1] multiply and take modulus 95094656.39 ±5.8% 0.16% slower
math/switch.ts[0] switch 98964053.74 ±5.17% fastest ✅
math/switch.ts[1] if 97432436.85 ±5.78% 1.55% slower
hash/index.ts[0] hash with numeric representation 67.05 ±0.88% 31.05% slower
hash/index.ts[1] hash with string representation 41.76 ±1.15% 57.05% slower
hash/index.ts[2] hash with symbol representation 65.25 ±0.49% 32.9% slower
hash/index.ts[3] hash with uint8 representation 73.63 ±0.09% 24.28% slower
hash/index.ts[4] hash with packed representation 97.24 ±0.13% fastest ✅
hash/index.ts[5] hash with bigint representation 72.35 ±0.25% 25.6% slower
hash/index.ts[6] hash with uint32 representation 90.01 ±0.71% 7.44% slower
bytes/bytes-to-number.ts[0] Conversion with bitops 3374.25 ±5.89% fastest ✅
bytes/bytes-to-number.ts[1] Conversion without bitops 2755.89 ±3.88% 18.33% slower
bytes/compare.ts[0] Comparing Uint32 bytes 11955.46 ±0.22% 0.88% slower
bytes/compare.ts[1] Comparing raw bytes 12061.69 ±0.16% fastest ✅
codec/view_vs_collection.ts[0] Get first element from Decoded 14368.5 ±0.69% 55.04% slower
codec/view_vs_collection.ts[1] Get first element from View 31960.05 ±0.51% fastest ✅
codec/view_vs_collection.ts[2] Get 50th element from Decoded 14640.5 ±0.68% 54.19% slower
codec/view_vs_collection.ts[3] Get 50th element from View 16735.13 ±1.09% 47.64% slower
codec/view_vs_collection.ts[4] Get last element from Decoded 14561.08 ±1.74% 54.44% slower
codec/view_vs_collection.ts[5] Get last element from View 11636.4 ±0.88% 63.59% slower
codec/view_vs_object.ts[0] Get the first field from Decoded 197609.22 ±0.57% 1.18% slower
codec/view_vs_object.ts[1] Get the first field from View 50628.33 ±0.41% 74.68% slower
codec/view_vs_object.ts[2] Get the first field as view from View 50278.79 ±0.46% 74.86% slower
codec/view_vs_object.ts[3] Get two fields from Decoded 199969.14 ±0.57% fastest ✅
codec/view_vs_object.ts[4] Get two fields from View 40230.28 ±0.47% 79.88% slower
codec/view_vs_object.ts[5] Get two fields from materialized from View 80367.01 ±0.48% 59.81% slower
codec/view_vs_object.ts[6] Get two fields as views from View 40251.17 ±0.51% 79.87% slower
codec/view_vs_object.ts[7] Get only third field from Decoded 199038.1 ±0.58% 0.47% slower
codec/view_vs_object.ts[8] Get only third field from View 49657.01 ±0.36% 75.17% slower
codec/view_vs_object.ts[9] Get only third field as view from View 33277.91 ±64.24% 83.36% slower
collections/map_vs_sorted.ts[0] Map 127555.92 ±0.5% fastest ✅
collections/map_vs_sorted.ts[1] Map-array 46994.11 ±0.22% 63.16% slower
collections/map_vs_sorted.ts[2] Array 31515.18 ±81.77% 75.29% slower
collections/map_vs_sorted.ts[3] SortedArray 83026.93 ±0.41% 34.91% slower
collections/hash-dict-vs-blob-dict_delete.ts[0] StringHashDictionary 2680.92 ±0.4% fastest ✅
collections/hash-dict-vs-blob-dict_delete.ts[1] BlobDictionary(1) 2675.54 ±0.34% 0.2% slower
collections/hash-dict-vs-blob-dict_delete.ts[2] BlobDictionary(2) 2652.17 ±0.39% 1.07% slower
collections/hash-dict-vs-blob-dict_delete.ts[3] BlobDictionary(3) 2656.74 ±1.1% 0.9% slower
collections/hash-dict-vs-blob-dict_delete.ts[4] BlobDictionary(4) 2660.27 ±0.65% 0.77% slower
collections/hash-dict-vs-blob-dict_delete.ts[5] BlobDictionary(5) 2663.07 ±0.41% 0.67% slower
collections/hash-dict-vs-blob-dict_get.ts[0] StringHashDictionary 2958.94 ±0.54% fastest ✅
collections/hash-dict-vs-blob-dict_get.ts[1] BlobDictionary(1) 2900.18 ±0.49% 1.99% slower
collections/hash-dict-vs-blob-dict_get.ts[2] BlobDictionary(2) 2928.67 ±0.42% 1.02% slower
collections/hash-dict-vs-blob-dict_get.ts[3] BlobDictionary(3) 2882.28 ±1.32% 2.59% slower
collections/hash-dict-vs-blob-dict_get.ts[4] BlobDictionary(4) 2901.91 ±0.38% 1.93% slower
collections/hash-dict-vs-blob-dict_get.ts[5] BlobDictionary(5) 2900.28 ±0.47% 1.98% slower
collections/hash-dict-vs-blob-dict_set.ts[0] StringHashDictionary 2308.07 ±0.4% fastest ✅
collections/hash-dict-vs-blob-dict_set.ts[1] BlobDictionary(1) 2228.43 ±0.44% 3.45% slower
collections/hash-dict-vs-blob-dict_set.ts[2] BlobDictionary(2) 2183.11 ±1.24% 5.41% slower
collections/hash-dict-vs-blob-dict_set.ts[3] BlobDictionary(3) 2258.38 ±0.39% 2.15% slower
collections/hash-dict-vs-blob-dict_set.ts[4] BlobDictionary(4) 2227.4 ±0.42% 3.5% slower
collections/hash-dict-vs-blob-dict_set.ts[5] BlobDictionary(5) 2224.61 ±0.45% 3.62% slower
hash/blake2b.ts[0] our hasher 1.07 ±0.4% fastest ✅
hash/blake2b.ts[1] blake2b js 0.03 ±0.2% 97.2% slower
crypto/ed25519.ts[0] native crypto 5.73 ±1.02% fastest ✅
crypto/ed25519.ts[1] wasm lib 2.22 ±0.34% 61.26% slower
crypto/ed25519.ts[2] wasm lib batch 2.17 ±0.51% 62.13% slower

Benchmarks summary: 83/83 OK ✅

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