-
Notifications
You must be signed in to change notification settings - Fork 242
Add a way to run multithreaded lookups in mmdblookup #154
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
Conversation
de969ca
to
78aabad
Compare
This is similar to the existing benchmark mode, but runs in several threads.
78aabad
to
ec604d7
Compare
Not too certain about the Windows detection here. Also, perhaps this would be better as a separate program, or be combined more with the existing benchmark code. Possibly it doesn't belong in this repo at all. I did find it useful for finding one race, so I think it or something like it would be good to have somewhere. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable, but I think the ifdef
s could be simpler.
bin/mmdblookup.c
Outdated
@@ -131,13 +164,14 @@ LOCAL const char **get_options(int argc, char **argv, char **mmdb_file, | |||
{ "verbose", no_argument, 0, 'v' }, | |||
{ "version", no_argument, 0, 'n' }, | |||
{ "benchmark", required_argument, 0, 'b' }, | |||
{ "threads", required_argument, 0, 't' }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we remove this option on Windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.
bin/mmdblookup.c
Outdated
int const iterations) | ||
{ | ||
#ifdef _WIN32 | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just remove the function definitions for these on Windows altogether and remove the following?
Lines 82 to 89 in ec604d7
if (thread_count > 0) { | |
if (!start_threaded_benchmark(&mmdb, thread_count, iterations)) { | |
MMDB_close(&mmdb); | |
exit(1); | |
} | |
MMDB_close(&mmdb); | |
exit(0); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's nicer. Mainly I was trying to work around regen-prototypes.pl
not being happy with macros (it deletes them from its section). I found a different workaround that seems better, although is still a bit ugly what with the extra NO_PROTOTYPE
macro. I wonder if we need regen-prototypes.pl
. It's not a huge pain to keep them up to date manually and would avoid this problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I would be fine getting rid of that script. I don't find it particularly useful.
This is similar to the existing benchmark mode, but runs in several
threads.