Repository navigation
Convert spike PDFs to Markdown, update VM docs, add optimization log - #105
Conversation
- Convert all 4 PDF spike documents (string performance, hashmap performance, generics performance, dispatch performance) to Markdown for better AI agent parsing - Fix stale TSouffleValue documentation: 26 bytes → 16 bytes, string[23] → string[13] across souffle-vm.md, design-decisions.md - Update test count to 3,501 across all docs (AGENTS.md, README.md, souffle-vm.md, design-decisions.md) - Add svkString to TSouffleValue kinds list in AGENTS.md - Add THashMap optimization details to AGENTS.md component table - Add docs/optimization-log.md with full VM optimization history, experiment results, remaining work, and key insights for fresh context pickup - Add hashmap spike update note documenting TScopeMap removal, TOrderedStringMap refactoring, and THashMap hash optimization Made-with: Cursor
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughAdds documentation spikes and logs; reduces Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (2)
docs/spikes/fpc-hashmap-performance.md (1)
9-9: Use one spelling variant for “optimized/optimised” in this document.The text mixes UK and US variants; pick one for consistency within this file.
Also applies to: 420-420
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/spikes/fpc-hashmap-performance.md` at line 9, The document mixes the US and UK spellings "optimized" and "optimised"; choose one variant (e.g., "optimized") and replace all occurrences consistently throughout the file, including the instance in the paragraph describing the benchmarked hash maps and the occurrence around line 420. Search for both "optimized" and "optimised" and perform a global replace to the chosen spelling, then run a quick pass to ensure surrounding grammar still reads correctly and update any headings or captions that used the other variant.docs/spikes/fpc-string-performance.md (1)
44-44: Tiny style polish for readability.Consider “44-second pathology” and rephrasing “…remains ~2x faster even then…” for smoother flow.
Also applies to: 145-145
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/spikes/fpc-string-performance.md` at line 44, Change the phrasing for readability: replace "44 second pathology" with "44-second pathology" and reword instances of "...remains ~2x faster even then..." (found near TStringBuilder/TUnicodeStringBuilder/FData and TAnsiStringBuilder mentions) to a smoother phrase such as "...remains ~2× faster even so..." or "...remains approximately 2× faster even then..." for consistent, polished style; update both occurrences referenced (lines around the TStringBuilder/TUnicodeStringBuilder/FData sentence and the TAnsiStringBuilder sentence).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/optimization-log.md`:
- Line 208: Remove or modify the map-unit renaming recommendation in the docs so
it no longer suggests renaming shared utility units (BaseMap.pas,
OrderedMap.pas, HashMap.pas, OrderedStringMap.pas) to Goccia.*; instead state
that shared/utility units are intentionally unprefixed and that any naming
follow-up is tracked in issue `#104`, aligning the guidance with the repository
convention.
In `@docs/souffle-vm.md`:
- Around line 367-371: The text incorrectly says "13 characters" for
TSouffleInlineString; change the wording to "13 bytes" and clarify that
TSouffleInlineString = string[13] is byte-counted in this FPC mode (AnsiString),
so Length() is in bytes and UTF‑8 multi‑byte characters may exceed the inline
limit; update the description of svkString, svkReference, and the
SouffleString(AValue) constructor bullets to use "bytes" (Length(AValue) <= 13
bytes → svkString with AsInlineString; > 13 bytes → svkReference to a new
TSouffleHeapString) and add a short note about UTF‑8 characters potentially
requiring more than one byte.
In `@docs/spikes/fpc-generics-performance.md`:
- Around line 25-32: The Local Variables table has incorrect ratio values:
recompute each Ratio as median / baseline (baseline is TGenericStack<Integer>
142.0 ms) and replace the wrong entries (e.g., THandRolledStack and
TDoubleInheritedStack). Specifically, update TSpecialisedStack (140.0 -> x0.99),
TInheritedStack (149.0 -> x1.05), THandRolledStack (222.0 -> x1.56), and
TDoubleInheritedStack (264.0 -> x1.86) in the table row entries so the Ratio
column reflects median/baseline formatted consistently (e.g., x1.56).
- Around line 35-42: The table's Ratio column is incorrect for rows
THandRolledStack and TDoubleInheritedStack; using the baseline median 127.0 ms
recompute ratio = median / 127.0 and update those cells: set THandRolledStack
ratio to x1.72 (219.0/127.0 ≈ 1.72) and TDoubleInheritedStack ratio to x1.96
(249.0/127.0 ≈ 1.96); verify other ratios (TSpecialisedStack and
TInheritedStack) remain x0.98 and x0.99 respectively and keep Verdict text
unchanged unless you want to adjust it after correcting the ratios.
In `@docs/spikes/fpc-hashmap-performance.md`:
- Around line 22-23: The doc still recommends the deleted TScopeMap; update the
spike to remove or mark as historical any recommendations that TScopeMap be used
(sections around the listed ranges) and replace guidance to reflect the current
implementation: note that units/ScopeMap.pas was deleted and scope bindings now
use TOrderedStringMap<TLexicalBinding> with recursive TGocciaScope walking, and
where the text compares performance (e.g., “TScopeMap linear scan + parent chain
walk”) either delete that line or annotate it as historical/removed and add the
correct description of current behavior using TOrderedStringMap and TGocciaScope
traversal.
---
Nitpick comments:
In `@docs/spikes/fpc-hashmap-performance.md`:
- Line 9: The document mixes the US and UK spellings "optimized" and
"optimised"; choose one variant (e.g., "optimized") and replace all occurrences
consistently throughout the file, including the instance in the paragraph
describing the benchmarked hash maps and the occurrence around line 420. Search
for both "optimized" and "optimised" and perform a global replace to the chosen
spelling, then run a quick pass to ensure surrounding grammar still reads
correctly and update any headings or captions that used the other variant.
In `@docs/spikes/fpc-string-performance.md`:
- Line 44: Change the phrasing for readability: replace "44 second pathology"
with "44-second pathology" and reword instances of "...remains ~2x faster even
then..." (found near TStringBuilder/TUnicodeStringBuilder/FData and
TAnsiStringBuilder mentions) to a smoother phrase such as "...remains ~2× faster
even so..." or "...remains approximately 2× faster even then..." for consistent,
polished style; update both occurrences referenced (lines around the
TStringBuilder/TUnicodeStringBuilder/FData sentence and the TAnsiStringBuilder
sentence).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 055af991-61a0-412c-beaa-6a4e3db28b51
⛔ Files ignored due to path filters (4)
docs/spikes/fpc-dispatch-performance.pdfis excluded by!**/*.pdfdocs/spikes/fpc-generics-performance.pdfis excluded by!**/*.pdfdocs/spikes/fpc-hashmap-performance.pdfis excluded by!**/*.pdfdocs/spikes/fpc-string-performance.pdfis excluded by!**/*.pdf
📒 Files selected for processing (10)
AGENTS.mdREADME.mddocs/code-style.mddocs/design-decisions.mddocs/optimization-log.mddocs/souffle-vm.mddocs/spikes/fpc-dispatch-performance.mddocs/spikes/fpc-generics-performance.mddocs/spikes/fpc-hashmap-performance.mddocs/spikes/fpc-string-performance.md
Benchmark Results254 benchmarks Interpreted: 🟢 188 improved · 🔴 1 regressed · 65 unchanged · avg +10.4% arraybuffer.js — Interp: 🟢 12, 2 unch. · avg +16.4% · Bytecode: 14 unch. · avg -1.3%
arrays.js — Interp: 🟢 17, 2 unch. · avg +12.7% · Bytecode: 19 unch. · avg +0.3%
async-await.js — Interp: 🟢 6 · avg +15.5% · Bytecode: 6 unch. · avg -1.1%
classes.js — Interp: 🟢 31 · avg +17.6% · Bytecode: 🟢 1, 30 unch. · avg -0.2%
closures.js — Interp: 🟢 11 · avg +11.8% · Bytecode: 11 unch. · avg -0.4%
collections.js — Interp: 🟢 5, 7 unch. · avg +7.3% · Bytecode: 12 unch. · avg +0.4%
destructuring.js — Interp: 🟢 21, 1 unch. · avg +11.4% · Bytecode: 22 unch. · avg -0.2%
fibonacci.js — Interp: 🟢 4, 4 unch. · avg +7.4% · Bytecode: 8 unch. · avg +1.9%
for-of.js — Interp: 🟢 6, 1 unch. · avg +10.3% · Bytecode: 7 unch. · avg +1.2%
iterators.js — Interp: 🟢 11, 9 unch. · avg +7.5% · Bytecode: 20 unch. · avg +0.6%
json.js — Interp: 🟢 18, 2 unch. · avg +9.5% · Bytecode: 🟢 2, 🔴 1, 17 unch. · avg -0.4%
jsx.jsx — Interp: 🟢 19, 2 unch. · avg +11.6% · Bytecode: 🔴 7, 14 unch. · avg -5.7%
numbers.js — Interp: 🟢 9, 2 unch. · avg +8.7% · Bytecode: 11 unch. · avg -2.3%
objects.js — Interp: 🟢 4, 3 unch. · avg +6.4% · Bytecode: 7 unch. · avg -0.0%
promises.js — Interp: 🟢 4, 8 unch. · avg +5.6% · Bytecode: 🔴 1, 11 unch. · avg -3.8%
strings.js — Interp: 🟢 2, 🔴 1, 8 unch. · avg +3.4% · Bytecode: 🔴 1, 10 unch. · avg -1.0%
typed-arrays.js — Interp: 🟢 8, 14 unch. · avg +4.7% · Bytecode: 🔴 2, 20 unch. · avg -3.1%
Measured on ubuntu-latest x64. Changes within ±7% are considered insignificant. |
Suite Timing
Measured on ubuntu-latest x64. |
- Rewrite optimization-log.md with correct PR numbers for all 22 PRs since #73 (previous version had multiple wrong PR-to-description mappings) - Add missing PRs: #73, #74, #75, #76, #77, #79, #80, #81, #82, #83, #85, #88, #89, plus infrastructure PRs #90, #92, #98 - Fix GC section: Collect-after-each-file is deliberate, not a workaround; any GC revisit needs fresh analysis - Fix minor items: link to actual issues #103 and #104, correct naming convention context (shared units should NOT use Goccia.* prefix) - Create docs/decision-log.md with 1-3 sentence summaries linking to detailed documentation - Link fpc-generics-performance.md and fpc-dispatch-performance.md from AGENTS.md, code-style.md, design-decisions.md, and optimization-log.md Made-with: Cursor
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/optimization-log.md`:
- Line 238: The PR reference in "Key Insight `#4`" incorrectly attributes the
boolean opcode promotion to PR `#88`; update the line in docs/optimization-log.md
(the sentence mentioning "promoting boolean opcodes") to point to the correct PR
number that implemented boolean opcode promotion or remove the PR reference if
you're unsure of the exact PR, ensuring the text no longer cross-references PR
`#88` which is about async/await.
- Around line 45-46: Update the contradictory statement about decorator
compilation: change the claim that "All decorated classes are compiled natively
via GOCCIA_EXT_BEGIN_DECORATORS / APPLY_ELEMENT_DECORATOR / FINISH_DECORATORS"
to reflect that decorated classes are deferred to the interpreter using
FPendingClasses and GOCCIA_EXT_EVAL_CLASS / EvaluateClassByIndex because
IsSimpleClass always returned True previously; ensure the doc consistently
describes the deferred path (FPendingClasses + GOCCIA_EXT_EVAL_CLASS /
EvaluateClassByIndex) and remove or reword any remaining assertion that
decorated classes are compiled natively (references:
GOCCIA_EXT_BEGIN_DECORATORS, APPLY_ELEMENT_DECORATOR, FINISH_DECORATORS,
IsSimpleClass, GOCCIA_EXT_EVAL_CLASS, EvaluateClassByIndex, FPendingClasses).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: cf607dfe-bd6c-4f5d-a852-80f07847034d
📒 Files selected for processing (5)
AGENTS.mddocs/code-style.mddocs/decision-log.mddocs/design-decisions.mddocs/optimization-log.md
🚧 Files skipped from review as they are similar to previous changes (1)
- docs/code-style.md
- Fix generics spike ratio values (arithmetic errors from original PDF) - Change "13 characters" to "13 bytes" in souffle-vm.md (FPC string[N] is byte-counted), add UTF-8 note - Mark TScopeMap as removed/historical in hashmap spike document - Fix Key Insight #4 PR reference (was #88 async/await, not boolean) - Remove stale GOCCIA_EXT_EVAL_CLASS / FPendingClasses / decorator bridge references from AGENTS.md, souffle-vm.md, design-decisions.md (decorators are now compiled natively via BEGIN/APPLY/FINISH opcodes) - Fix "44 second" → "44-second" hyphenation in string spike Made-with: Cursor
There was a problem hiding this comment.
♻️ Duplicate comments (1)
docs/spikes/fpc-hashmap-performance.md (1)
67-68:⚠️ Potential issue | 🟠 MajorRemove remaining normative
TScopeMapguidance from historical section.These lines still read as current recommendation (“sweet spot” / “overall recommendations unchanged”), which conflicts with the March 2026 update and current implementation.
[suggested patch]
🛠️ Suggested wording adjustment
-TScopeMap wins at N=10 (1.5× faster) where linear scan has less overhead than hashing. At N=30 the O(n) scan crosses over and TDictionary's O(1) amortised lookup wins. The sweet spot for TScopeMap is scopes with fewer than ~20 bindings, which covers the vast majority of real-world function scopes. Its Resolve and Assign methods provide chain-walking semantics that no hash map can replicate. +Historically, TScopeMap won at N=10 (1.5× faster) where linear scan had less overhead than hashing. At N=30 the O(n) scan crossed over and hash-based lookup won. This is baseline data only: TScopeMap has been removed, and current scope bindings use `TOrderedStringMap<TLexicalBinding>` with recursive parent walking in `TGocciaScope`. @@ -- **Original benchmarks remain valid.** The benchmarks in sections 3.1–3.5 remain valid for the general comparison; the updates only affected implementation details, not the overall recommendations. +- **Original benchmarks are historical baseline data.** The benchmark data remains useful for comparison, but scope-binding recommendations are superseded by the March 2026 architecture update.Based on learnings:
units/ScopeMap.paswas deleted, and scope bindings now useTOrderedStringMap<TLexicalBinding>with recursiveTGocciaScopewalking.Also applies to: 426-426
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/spikes/fpc-hashmap-performance.md` around lines 67 - 68, Remove the remaining normative recommendation language about TScopeMap (mentions like “sweet spot for TScopeMap”, “Resolve and Assign” semantics, and comparisons to TDictionary) and replace it with a brief historical note stating that TScopeMap and units/ScopeMap.pas were removed and that scope bindings now use TOrderedStringMap<TLexicalBinding> with recursive TGocciaScope walking; update any language that implies active recommendation (e.g., references to Resolve/Assign or performance sweet spots) to reflect that this is historical context only and not current guidance.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@docs/spikes/fpc-hashmap-performance.md`:
- Around line 67-68: Remove the remaining normative recommendation language
about TScopeMap (mentions like “sweet spot for TScopeMap”, “Resolve and Assign”
semantics, and comparisons to TDictionary) and replace it with a brief
historical note stating that TScopeMap and units/ScopeMap.pas were removed and
that scope bindings now use TOrderedStringMap<TLexicalBinding> with recursive
TGocciaScope walking; update any language that implies active recommendation
(e.g., references to Resolve/Assign or performance sweet spots) to reflect that
this is historical context only and not current guidance.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b8f643d1-2a78-4608-a970-fb212adb604b
📒 Files selected for processing (7)
AGENTS.mddocs/design-decisions.mddocs/optimization-log.mddocs/souffle-vm.mddocs/spikes/fpc-generics-performance.mddocs/spikes/fpc-hashmap-performance.mddocs/spikes/fpc-string-performance.md
The spike originally recommended TScopeMap for scope bindings based on micro-benchmarks at N≤10. After implementation (PR #66), real-world profiling showed the assumption about scope sizes was incorrect — global and bridged scopes far exceed 20 bindings, causing a 2.7× regression. The update section now tells the complete timeline: original recommendation → implementation → profiling discovery → revert. Made-with: Cursor
Introduce a new 'grill-me' agent skill that relentlessly interviews users about a plan or design, exploring each branch of the decision tree until a shared understanding is reached and dependencies are resolved. The skill prefers to inspect the codebase when that can answer a question. Updated skills lock to include the new skill.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
docs/spikes/fpc-hashmap-performance.md (1)
7-7: Minor: Spelling consistency (optimise vs optimize).Line 7 uses "optimised" (British spelling) while line 434 uses "optimized" (American spelling). Consider standardizing to one variant throughout the document for consistency.
Also applies to: 434-434
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/spikes/fpc-hashmap-performance.md` at line 7, The document uses both "optimised" and "optimized"; pick one spelling (e.g., use "optimized" to match line 434) and make all occurrences consistent by replacing "optimised" with "optimized" (or vice versa if you prefer British spelling) throughout the file; search for the tokens "optimised" and "optimized" and update every match in the docs/spikes/fpc-hashmap-performance.md content to the chosen variant.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@docs/spikes/fpc-hashmap-performance.md`:
- Line 7: The document uses both "optimised" and "optimized"; pick one spelling
(e.g., use "optimized" to match line 434) and make all occurrences consistent by
replacing "optimised" with "optimized" (or vice versa if you prefer British
spelling) throughout the file; search for the tokens "optimised" and "optimized"
and update every match in the docs/spikes/fpc-hashmap-performance.md content to
the chosen variant.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4d6b36d1-756c-4053-a318-1848a996f789
📒 Files selected for processing (1)
docs/spikes/fpc-hashmap-performance.md
Summary
fpc-string-performance,fpc-hashmap-performance,fpc-generics-performance,fpc-dispatch-performance) for better AI agent parsing and accessibilityTSouffleValuedocumentation acrosssouffle-vm.mdanddesign-decisions.md: 26 bytes → 16 bytes,string[23]→string[13](reflecting PR Experiment: SOUFFLE_INLINE_STRING_MAX = 13 #96)AGENTS.md,README.md,souffle-vm.md,design-decisions.md)svkStringtoTSouffleValuekinds list andTHashMapoptimization details inAGENTS.mddocs/optimization-log.md— a comprehensive record of all VM optimization experiments, what worked, what didn't, remaining work, and key insights for future contributorsTScopeMapremoval andTHashMap/TOrderedStringMapoptimizationsTest plan
.pdfreferences in any.mdfilesAGENTS.mdincludes newoptimization-log.mdMade with Cursor
Summary by CodeRabbit
New Features
Performance
Documentation
New Skill