Skip to content

⚡ perf(lang): optimize lexer keyword/identifier parsing#1752

Merged
harehare merged 2 commits into
mainfrom
perf/lexer-ident-keyword-optimization
May 17, 2026
Merged

⚡ perf(lang): optimize lexer keyword/identifier parsing#1752
harehare merged 2 commits into
mainfrom
perf/lexer-ident-keyword-optimization

Conversation

@harehare

Copy link
Copy Markdown
Owner

No description provided.

@harehare harehare requested a review from Copilot May 17, 2026 12:38
@codspeed-hq

codspeed-hq Bot commented May 17, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 15.44%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 20 improved benchmarks
✅ 9 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
eval_array_chained_operations 9.8 ms 8.7 ms +12.17%
eval_array_filter 10.4 ms 9.3 ms +11.25%
eval_nested_object_access 7.4 ms 6.3 ms +17.37%
eval_nodes 7 ms 5.9 ms +17.83%
eval_array_fold 8 ms 7 ms +15.23%
eval_string_interpolation 60.7 µs 55 µs +10.31%
eval_variable_assignment_chain 876.8 µs 749.7 µs +16.95%
eval_object_field_access 7.8 ms 6.7 ms +16.41%
eval_array_map 8.6 ms 7.6 ms +14.13%
eval_yaml_parse 8.1 ms 6.8 ms +18.68%
eval_pipeline_with_conditionals 7.6 ms 6.5 ms +16.34%
eval_csv_parse 8 ms 6.7 ms +19.06%
parse_fibonacci 188.9 µs 171 µs +10.45%
eval_foreach 7.4 ms 6.3 ms +16.68%
eval_qualified_access_to_csv_module 8 ms 6.8 ms +18.82%
eval_if_else_branching 8.8 ms 7.7 ms +13.83%
eval_string_equality 7.4 ms 6.2 ms +18.4%
eval_json_parse 7.6 ms 6.4 ms +18.42%
eval_macro_expansion_nested 111.4 µs 98.6 µs +12.9%
eval_long_pipeline 8.4 ms 7.3 ms +14.21%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing perf/lexer-ident-keyword-optimization (f5575f4) with main (3bef7c2)

Open in CodSpeed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR focuses on improving mq-lang lexer performance by simplifying keyword handling and reducing allocations during comment skipping.

Changes:

  • Replaced many per-keyword parsers with a consolidated ident_or_keyword matcher.
  • Added skip_comment to skip # ... comments without allocating comment text in the whitespace-skip path.
  • Updated token parsing order to rely on ident_or_keyword for keyword recognition.

Comment thread crates/mq-lang/src/lexer.rs
Comment thread crates/mq-lang/src/lexer.rs Outdated
Comment thread crates/mq-lang/src/lexer.rs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread crates/mq-lang/src/lexer.rs
Comment thread crates/mq-run/src/cli.rs
@harehare harehare merged commit fa577d9 into main May 17, 2026
14 checks passed
@harehare harehare deleted the perf/lexer-ident-keyword-optimization branch May 17, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants