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

Caching for Repeated Parsing #40

Open
joshcho opened this issue Sep 2, 2023 · 4 comments
Open

Caching for Repeated Parsing #40

joshcho opened this issue Sep 2, 2023 · 4 comments

Comments

@joshcho
Copy link

joshcho commented Sep 2, 2023

I'm working on a performance-critical project that requires repeated parsing with parseclj. I'm interested in knowing whether there's built-in support for caching parsed results. If not, would memoization be an effective way to add this feature? Additionally, are there any caveats or issues to be aware of when implementing caching in conjunction with parseclj? If there's any places I should look, let me know.

Thanks!

@joshcho joshcho changed the title How to Implement Caching for Repeated Parsing Operations to Improve Performance? Caching for Repeated Parsing Sep 2, 2023
@plexus
Copy link
Collaborator

plexus commented Sep 2, 2023 via email

@joshcho
Copy link
Author

joshcho commented Sep 2, 2023

I am essentially continually parsing an editing buffer, so most of it is identical. I am wondering which part/function of the package would best have the caching/memoization. Naively I can probably do sth like only cache inputs of strings that are large enough.

@plexus
Copy link
Collaborator

plexus commented Sep 2, 2023

Parseclj is a parse reduce parser, rather that a recursive descent parser. The only place I can imagine you might be able to do something is at the reduce step, based on the top few elements of the stack, but it's not gonna be as easy as wrapping some function in "memoize", this is going to require deep understanding of what it's doing.

@plexus
Copy link
Collaborator

plexus commented Sep 2, 2023

I would see what you can do to avoid parsing the whole buffer, maybe rerun the parser only on the current top level form.

Alternatively look into the treesitter parser, that's more built for this kind of use case.

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

No branches or pull requests

2 participants