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

Default to re2 parser is available #184

Merged
merged 1 commit into from
Feb 11, 2024

Conversation

masklinn
Copy link
Contributor

After benchmarking, the results are out, at least on the current sample file:

First, re2 is ridiculously faster than the basic parser, even with tons of caching. re2 does benefit from caching, but it's so fast that it needs very high hitrates (so a very large cache) for the caching to have a real impact, it's fast enough that at low hitrates (small sizes) the cache does slow down parsing visibly which is not the case of the basic parser.

Second, LRU is confirmed to be a better cache replacement policy than clearing (which... duh), it's not super sensible at very low sizes but at 100 entries it starts really pulling ahead, so definitely the better default at 200 (where even with the overhead of the more layered approach it's ahead of the legacy parser and its immutable 20 entries clearing cache).

The locking doesn't seem to have much impact without contention, and even contended the LRU seems to behave way better than the clearing cache still. So fallback onto locked LRU if re2 is not available.

After benchmarking, the results are out, at least on the current
sample file:

First, re2 is ridiculously faster than the basic parser, even with
tons of caching. re2 does benefit from caching, but it's so fast that
it needs very high hitrates (so a very large cache) for the caching to
have a real impact, it's fast enough that at low hitrates (small
sizes) the cache does slow down parsing visibly which is not the case
of the basic parser.

Second, LRU is confirmed to be a better cache replacement policy than
clearing (which... duh), it's not super sensible at very low sizes but
at 100 entries it starts really pulling ahead, so definitely the
better default at 200 (where even with the overhead of the more
layered approach it's ahead of the legacy parser and its immutable 20
entries clearing cache).

The locking doesn't seem to have much impact without contention, and
even contended the LRU seems to behave way better than the clearing
cache still. So fallback onto locked LRU if re2 is not available.
@masklinn masklinn enabled auto-merge (rebase) February 11, 2024 20:16
@masklinn masklinn merged commit fa27574 into ua-parser:master Feb 11, 2024
29 checks passed
@masklinn masklinn deleted the better-default-parser branch February 19, 2024 18:56
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.

1 participant