Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorder and refactor code #152

Merged
merged 1 commit into from
Jul 24, 2024
Merged

Conversation

jdujava
Copy link
Contributor

@jdujava jdujava commented Jul 23, 2024

No description provided.

Signed-off-by: Jonas Dujava <jonas.dujava@gmail.com>
@jdujava jdujava force-pushed the refactor-reorder branch from b4584f5 to f26246e Compare July 23, 2024 08:29
@clason
Copy link

clason commented Jul 23, 2024

Pay attention to the parser complexity; this is an issue for this grammar specifically. Look at the generated parser.c, especially the LARGE_STATE_COUNT stat at the top -- this should ideally become smaller, but not larger. It's always helpful to report before/after for these stats. (If the parser is checked into the repo, this is clear from the diff, but here one has to rely on the PR description.)

@jdujava
Copy link
Contributor Author

jdujava commented Jul 23, 2024

Good to know, thanks!

If I checked correctly, before and after are the same at LARGE_STATE_COUNT 2271.

@jdujava
Copy link
Contributor Author

jdujava commented Jul 23, 2024

@clason @pfoerster I don't know how to do it, but couldn't some CI return and display LARGE_STATE_COUNT (and potentially other stuff) somewhere automatically?

@pfoerster
Copy link
Member

@jdujava @clason I think we have 3 ways to keep track of LARGE_STATE_COUNT:

  1. Add something like cat src/parser.c | grep '#define LARGE_STATE_COUNT' | sed 's/#define //g' to the CI job and compare it with main by checking the CI log (probably easy to miss)
  2. Same as 1. but report it as a comment under the PR instead (can be quite spammy if you don't add the logic to update the existing comment)
  3. Commit parser.c again and check the PR diff (probably the easiest way)

What do you think?

@pfoerster pfoerster merged commit 7ee50b2 into latex-lsp:master Jul 24, 2024
4 checks passed
@clason
Copy link

clason commented Jul 24, 2024

I'd keep it simple (and share your distaste of codecringecov comments). So if option 1 is simple enough to realize (you probably want to test generation anyway?), especially the comparison to main, then I'd recommend that. You can fail the test if the new count is greater than, say 1.2 times the old count or so (free ratchet ;)).

Or just add it to the PR template -- ask people to test tree-sitter g --nobindings and report the state counts; maybe raising awareness is enough?

@jdujava jdujava deleted the refactor-reorder branch July 24, 2024 14:57
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.

3 participants