-
Notifications
You must be signed in to change notification settings - Fork 24
Switch from pcre to re2 #72
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
base: master
Are you sure you want to change the base?
Conversation
|
Would an updated #65 to compare to be helpful? |
|
This looks good, but I'm concerned that there's a fairly substantial performance hit from the switch. I'm surprised, because rsc tends to gush about re2 performance, specifically compared to pcre. Are you seeing the same? re2 is pretty simple -- I don't know that there's anything we can tweak to narrow the gap. |
|
I am also seeing the same noticeable slow down compared to either pcre1 or pcre2. |
|
I am just a random passerby, but out of curiosity, how to reproduce the slowdown you are seeing? At least in my initial testing, at least 10 ms penalty comes simply from relocations after dynamic linking against re2 (it isn't visible when one links statically). |
|
Well, it's been a while, but I don't believe that I was profiling any specific -- just a basic regex-flavored search and measuring overall walltime. And honestly, that's the metric that matters to the end user in the current implementation of pkgfile regardless of where the walltime comes from. |
|
I did some more profiling and I think I have some lead where the slowdown comes from. For a simple If I am reading this correctly, around 80% of the time is spent in Now I didn't initially plan for this, I only wanted to have cleaner output, but when I compiled --- a/src/pkgfile.cc
+++ b/src/pkgfile.cc
@@ -240,7 +240,7 @@ int Pkgfile::SearchRepoChunks(Database::RepoChunks repo_chunks,
}
const auto num_workers =
- std::min<int>(std::thread::hardware_concurrency(), queue.size());
+ std::min<int>(1, queue.size());
std::vector<std::thread> workers;
workers.reserve(num_workers);It might be, because now, mutex (un)locking takes "only" ~23% of our time. Here are my
Full
|
|
Yeah, this analysis is spot on. Can confirm that if I build the RE2 object within each worker then I get performance which is at least equivalent to pcre. This is annoying, because:
|
No description provided.