-
Notifications
You must be signed in to change notification settings - Fork 2
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
Optimise by filtering out empty values. #25
Conversation
Cool, well while I'm not really familiar with this code, or algorithm that is the only comments I had. That said I'm happy to give @ptersilie time to weigh in on things, if he feels inclined? |
The `fits` function (and to a lesser extent `apply`) previously did vast amounts of pointless work on empty values that could not succeed. This commit does something very simple: it pre-filters out all the empty values so that `fits` has a lot less work to do. On small grammars, the quantity of pointless work probably wasn't very noticeable, but on large grammars like Postgresql's, it became punishing. On my machine this commit takes nimbleparse's running time down from 101s to 3s.
2d37f94
to
6bca7f0
Compare
Just to check: this does the right thing on the grammars you care about? If so, you'll be an excellent reviewer and should feel free to merge (I've force pushed a squash). |
I've run it on a few grammars I care about, and everything seems to work. Sadly a great portion of the grammars I have laying around don't produce a valid state table, So I'll try and do that tomorrow. |
I think if it works on the ones you care about, we're probably good to go. I wouldn't object to a PR to add a |
Well, running through things adding the As such the below output part of a diff of the
If I look at that through Edit: I'll have a short investigation into how hard it would be to make the |
So I locally tested with fixed the pretty printing, checked the state tables of my projects and a bunch of projects from github with no hints of any unexpected differences. |
The
fits
function (and to a lesser extentapply
) previously did vast amounts of pointless work on empty values that could not succeed. This commit does something very simple: it pre-filters out all the empty values so thatfits
has a lot less work to do.On small grammars, the quantity of pointless work probably wasn't very noticeable, but on large grammars like Postgresql's, it became punishing. On my machine this commit takes nimbleparse's running time down from 101s to 3s.
Fixes softdevteam/grmtools#473 (comment). @ratmice I have only very lightly tested this, so if you're able to also verify whether this doesn't change anything (other than performance) for your use cases, I'd be very grateful!