Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@
## 2024-05-18 - Removed redundant clone of VM stack during trace logs
**Learning:** In `runtime/vm/src/executor.rs`, the debugging instruction trace `self.debugger.trace_instruction` was cloning the entire VM stack using `&self.stack.get_dump()` for every single instruction executed. This caused significant `O(N)` overhead inside the main fetch-decode-execute loop just to format debug output. A new `data_slice()` method was added to `ValueStack` to provide zero-copy slice access (`&[RuntimeValue]`) instead, completely eliminating the allocation overhead.
**Action:** Always scrutinize deep clones in logging, tracing, or hot path loops. Use slice references (`&[T]`) instead of `Vec::clone` when the caller only needs read-only access to a collection.
## 2024-06-25 - Suboptimal Line Search in LSP
**Learning:** Using `chars().nth()` with a byte offset (such as one returned by `.find()`) inside a loop over a string creates an O(N) penalty and may result in an incorrect character lookup if multi-byte unicode characters are present.
**Action:** Use string slicing with the byte index to create a subset string slice, and call `.chars().next_back()` or `.chars().next()` on it for an O(1) and UTF-8 safe boundary lookup.
<
9 changes: 8 additions & 1 deletion cli/src/commands/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,17 @@ fn post_process(source: &str) -> String {
/// Replace `prefix(args)` calls with `keyword args` (implicit call style).
fn replace_call(source: &str, prefix: &str, keyword: &str) -> String {
let full = format!("{prefix}(");
let full_str = full.as_str();

// Fast path: if the substring is not in the source, just return a copy.
if !source.contains(full_str) {
return source.to_string();
}

let mut result = String::with_capacity(source.len());
let mut remaining = source;
loop {
match remaining.find(full.as_str()) {
match remaining.find(full_str) {
None => {
result.push_str(remaining);
break;
Expand Down
12 changes: 6 additions & 6 deletions docs/benchmarks/benchmark_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ Generated on standard test environment (Windows target execution).
## Compilation Phase Speeds
| Phase | Duration |
| :--- | :--- |
| **Lexing & Tokenization** | 0.092 ms |
| **Pratt Parsing & AST Building** | 0.116 ms |
| **Semantic Check & Name Binding** | 0.199 ms |
| **SSA IR Lowering & Optimization** | 0.194 ms |
| **Bytecode Generation** | 0.110 ms |
| **VM Execution (Fibonacci 25)** | 38629.399 ms |
| **Lexing & Tokenization** | 0.090 ms |
| **Pratt Parsing & AST Building** | 0.245 ms |
| **Semantic Check & Name Binding** | 0.454 ms |
| **SSA IR Lowering & Optimization** | 0.103 ms |
| **Bytecode Generation** | 0.138 ms |
| **VM Execution (Fibonacci 25)** | 1279.449 ms |

## Benchmark Details
- **Test File**: Recursive Fibonacci 25 calculation (`fib(25)`)
Expand Down
Loading