Symbol interning optimization #166
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
refactor
rust
technical-debt
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
navicore/patch-seq#166
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Issue #148 implemented symbol syntax (
:foo). Currently, symbols are stored as regularSeqStringvalues - each symbol literal allocates new memory.Current Behavior
Each
:foocreates a newSeqString, so:Desired Behavior
Implement compile-time symbol interning:
Design Constraints (from user)
This means:
HashMapwith locks for runtime symbol creationstring->symbolmay not participate in interning (or uses lock-free approach)Implementation Ideas
Compile-time string deduplication: Compiler emits each unique symbol literal once as a global constant. All uses reference the same constant.
Static interning table: Generate a perfect hash or sorted array of all symbol literals at compile time.
Runtime symbols stay uninterned:
string->symbolcreates uninterned symbols (like Clojure'ssymbolvs:keyword).Pattern Matching Performance Regression (PR #168)
Issue #149 changed variant tags from
u32toSeqString. This caused a runtime performance regression in pattern matching:Impact: Match expressions with N arms now require up to N-1 string comparisons in worst case.
Symbol interning will fix this: With interned symbols, pattern matching can use O(1) pointer equality instead of O(n) string comparison. The codegen could potentially be optimized back to LLVM switch on the interned pointer value.
Non-blocking
This is a performance optimization. The current implementation is semantically correct and sufficient for SON.
Related
https://github.com/navicore/patch-seq/pull/171