Skip to content

Improve speed of sshd tree-sitter grammar#1551

Open
SteveL-MSFT wants to merge 1 commit into
PowerShell:mainfrom
SteveL-MSFT:sshd-grammar
Open

Improve speed of sshd tree-sitter grammar#1551
SteveL-MSFT wants to merge 1 commit into
PowerShell:mainfrom
SteveL-MSFT:sshd-grammar

Conversation

@SteveL-MSFT
Copy link
Copy Markdown
Member

PR Summary

Simplify match to give speed improvement. Before changes:

  invalid_expressions:
      1. ✓ missing space after keyword -- Warning: Slow parse rate (436.364 bytes/ms)
  valid_expressions:
     26. ✓ parse empty line -- Warning: Slow parse rate (370.370 bytes/ms)

After, still have warning on slow parse rate, but significant improvement:

  invalid_expressions:
      1. ✓ missing space after keyword -- Warning: Slow parse rate (679.887 bytes/ms)
  valid_expressions:
     26. ✓ parse empty line -- Warning: Slow parse rate (666.667 bytes/ms)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Performance optimization for the sshd tree-sitter grammar by reducing parser ambiguity and inlining hot rules. The _commaSeparatedString rule (which required at least one comma) is merged into a single _stringArg rule that handles both single and comma-separated strings via repeat, eliminating the need for a separate $.string alternative in _argument. Explicit precedence between boolean, number, and string plus inlining _new_line/_argument reportedly improves parse rates by ~60-80%.

Changes:

  • Add inline for _new_line and _argument, and a precedences declaration ordering boolean > number > string to resolve token conflicts.
  • Replace _commaSeparatedString (requiring repeat1) with _stringArg using repeat, so it now subsumes the bare $.string branch in _argument.
  • Flatten a redundant nested seq in the match rule.

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