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

Use SparseSet-like structure for SuffixCache #513

Merged
merged 1 commit into from
Sep 11, 2018

Conversation

RReverser
Copy link
Contributor

For simple regexes, allocating and filling 1000 of SuffixCache elements seemed to be quite high on the profile as part of Compiler::new, so I decided to optimise it by using ideas similar to sparse set, but specialised for a hashmap-like structure, instead of a flat array with versioning.

In my performance comparisons this gives 8-10% improvement for simple regexes where overhead of Compiler::new is most noticeable.

For simple regexes, allocating and filling 1000 of SuffixCache elements seemed to be quite high on the profile as part of Compiler::new, so I decided to optimise it by using ideas similar to sparse set, but specialised for a hashmap-like structure, instead of a flat array with versioning.

In my performance comparisons this gives 8-10% improvement for simple regexes where overhead of Compiler::new is most noticeable.
@RReverser
Copy link
Contributor Author

FWIW I understand that SuffixCache is meant to be as simple as possible, but I think (hope) this change doesn't make it any more complicated while brings nice performance improvement.

Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

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

Nice, I like it!

FYI, this is definitely one of the areas I plan on putting a lot of focus on. The FSMs for Unicode character classes are way too big currently. RE2 has done some nice work in this area.

@RReverser
Copy link
Contributor Author

RReverser commented Sep 10, 2018

@BurntSushi Seems to pass all the checks?

@BurntSushi BurntSushi merged commit cd6f1e2 into rust-lang:master Sep 11, 2018
@RReverser RReverser deleted the faster-suffix-cache-new branch September 11, 2018 17:16
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