Closed pangloss closed 10 years ago
This is definitely a known issue: Parslet is slow. However, it is extremely easy to prototype in. The best solution would be to rewrite the parser in C, but doing that takes some time. I think this problem is one to keep in mind for the future, but is really seeking the right developer excited about taking it on.
Using rsec instead of parslet will only gain you a factor of about 2-4, not 1000 as pangloss suggests. The way to go here would really be a hand-written parser. parslets performance has been improving over the past two years. A lot of performance comparisons out there are not done with the newer versions, but with really ancient ones.
To clarify, the 1000x number is just the comparison to JSON, which I think is relevant since it's the obvious alternative to EDN.
I had gotten the impression rsec might be faster than that, so that's disappointing news. By the way, are you talking about plain rsec or rsec-ext? Do you have any benchmarks that you could link?
As a side note, I should have pointed out that generating EDN with this gem is fast; comparable in speed to JSON.
You can run https://github.com/kschiess/parslet-benchmarks bin/compare - it shows rsec (Ruby version) to have 16x the performance of parslet and roughly 4x that of treetop. Note that rsec does half the work, so that explains a lot. Further discussion of relative speeds in private? ;) (I don't think it helps the trouble ticket)
/me still thinks that the title of this trouble ticket is extremely poorly chosen.
@kschiess Agreed. Ticket updated @pangloss A pull request that improves parsing performance while keeping existing readability and test suite green would be welcome.
@cldwalker I agree, but will have to leave the task to someone else.
We switched to a hand coded parser in 1.0.5. Performance is dramatically better.
EDN is roughly 1000x slower than JSON at deserializing the following trivial string.
I've used Parselet in a project before, so I know exactly where your speed problems are coming from. Please consider using a faster parser. For instance http://rsec.heroku.com/ looks promising (via http://www.ruby-forum.com/topic/3444183 ).
Compare this to JSON performance: