Conversation
Drop the `#[cached(...)]` attribute invocations in word, tokenizer, arithmetic, prompt, and shell parsing, inlining the cached wrapper functions where they existed. Remove the now-unused `cached` dependency from brush-parser; brush-core keeps it for the direct `cached::LruCache` usage in regex.rs. This is an experiment to obtain a baseline for benchmarking before deciding how to replace or tune the caching. Assisted-by: opencode:deepseek-v4-flash-free
Performance Benchmark Report
Benchmarks added:
Code Coverage Report: Only Changed Files listed
Minimum allowed coverage is Test Summary: bash-completion test suite
|
Add two benchmarks that exercise a realistic, mixed set of distinct commands rather than repeating a single identical command: - `run_mixed_script`: runs a script containing a variety of shell constructs (assignment, arithmetic, expansions, loops, conditionals, case, functions, command substitution, redirections). - `run_mixed_commands`: runs 128 distinct commands one at a time, sized to exceed the 64-entry parse cache so most commands miss. These provide a more representative baseline for evaluating the effect of the cached-crate parsing caches removed in the preceding commit. Assisted-by: opencode:deepseek-v4-flash-free
Benchmark comparison: cached (main) vs uncached (this branch)I ran the benchmarks locally on both Delta column = change in the uncached result relative to cached. Positive = uncached is slower; negative = uncached is faster. Existing micro-benchmarks (repeat the same command every iteration — cache's best case)
New mixed-command benchmarks (added in a1330ef)
Interpretation
Net takeaway: the cache is a win for repeated-identical-input workloads but roughly a wash-to-slight-loss for varied scripts. This gives us a baseline to decide whether to keep, replace (e.g. a simpler hashmap, larger capacity), or drop the caches. Note: Assisted-by: opencode:deepseek-v4-flash-free |
Summary
Drop the
#[cached(...)]attribute invocations in word, tokenizer, arithmetic, prompt, and shell parsing. Where a public function delegated to a private cached wrapper, the wrapper is inlined into the public function. The now-unusedcacheddependency is removed frombrush-parser;brush-corekeeps it becausebrush-core/src/regex.rsstill usescached::LruCachedirectly (not the macro).Motivation
This is an initial experiment to establish a baseline for benchmarking. It removes the
cachedcrate macro usage so we can measure the cost/benefit of the caching before deciding how to replace or tune it.Changes
brush-parser/src/word.rs— inlinecacheable_parseintoparsebrush-parser/src/tokenizer.rs— drop theuncached_tokenize_stringwrapper;tokenize_str_with_optionscallsuncached_tokenize_strdirectlybrush-parser/src/arithmetic.rs— inlinecacheable_parseintoparsebrush-core/src/prompt.rs— drop attribute onparse_promptbrush-core/src/shell/parsing.rs— drop attribute onparse_string_implbrush-parser/Cargo.toml+Cargo.lock— removecacheddependencyTesting
cargo clippy --package brush-parser --package brush-corepassescargo test --package brush-parser --package brush-corepassesAssisted-by: opencode:deepseek-v4-flash-free