llogick/extended-zccs
Extended Zig Compiler Components: Reduce parsing overhead by reusing data, e.g., in language servers.
The standard Zig parser is no slouch,
but it’s a full-document parser — reprocessing the entire document from scratch for every edit.
This becomes inefficient for frequent small edits, which this project aims to address through targeted optimizations.
NOTE: Uplift numbers are based on small edits. Performance may vary for large-scale changes.
G1: Reuse tokens
Achieves ~50% uplift (relatively flat latency regardless of edit location)
G2: Reuse root declarations (part 1)
Reuse root declarations before the edit point, with performance gains increasing toward document end.
Achieves G1 + 0–45% uplift
G3: Reuse root declarations (part 2)
Reuse as many root declarations as possible.
Increased complexity (calculations/viability checks, 2 extra allocations, replace nodes range, shift indices) may lower G2’s uplift but provides a more consistent ~30–45% uplift over G1 across all edit locations
G4: Parse only affected nodes
High complexity. Aims to ensure flat latency across all edit locations for a G1 + 40% total uplift.
Specialized AstCheck component
- Early Exit Support: Checks a thread-safe flag, `change_pending: *std.atomic.Value(bool)`,
early in `generate()` and in the `container_decl.ast.members` loop in `structDeclInner()`
Given that AstCheck shouldn't be called when ast.errors.len != 0, the cases that benefit are:
- rapidly inserting new lines
- modifying existing identifiers, ie edits that don't introduce parse errors
- distant third: ast-check errors past the 50% mark of a large document
Take a tailored version of ZLS for a spin and discover if it enhances your editing experience
Keep in Mind:
Half (50%) of a small number, is an even smaller number — for tiny files or on capable hardware, the speed-up might be imperceptible.
Suggested Test Files:
This project is licensed under the MIT License.
It includes large portions of code from Zig, which is also released under the MIT License.