-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Simplify/speedup "--show" and "--make-charset" #4430
Comments
Copying another observation of mine from #4388 to here:
which magnum confirmed there:
So I think should track it here, and fix it, and test the fix. |
I now realize that we'd first incur the overhead of |
Oh, right. And the real enemy for performance is However, I just noticed a thing. We have code like this in loader: prepared = (*format)->methods.prepare(fields, *format);
if (prepared)
valid = (*format)->methods.valid(prepared, *format);
else
valid = 0; This instance could be changed: prepared = alt->methods.prepare(fields, alt);
- if (alt->methods.valid(prepared, alt)) {
+ if (prepared && alt->methods.valid(prepared, alt)) { Third place: prepared = alt->methods.prepare(fields, alt);
if (!prepared)
continue; But our typical static char *prepare(char *split_fields[10], struct fmt_main *self)
{
static char out[33 + TAG_LENGTH + 1];
if (!valid(split_fields[1], self)) {
if (split_fields[3] && strlen(split_fields[3]) == 32) {
sprintf(out, "%s%s", FORMAT_TAG, split_fields[3]);
if (valid(out, self))
return out;
}
}
return split_fields[1];
} It will never return NULL! I'm pretty sure that's a very typical implementation... and this means
Thinking millions of hashes, this is a waste. We could at least improve this function so we return NULL when we already know it's not by any stretch a hash for this format. static char *prepare(char *split_fields[10], struct fmt_main *self)
{
static char out[33 + TAG_LENGTH + 1];
if (!valid(split_fields[1], self)) {
if (split_fields[3] && strlen(split_fields[3]) == 32) {
sprintf(out, "%s%s", FORMAT_TAG, split_fields[3]);
if (valid(out, self))
return out;
+ else
+ return NULL;
}
}
return split_fields[1];
} |
Implemented in #4726.
Looks like we already skip that due to the if (db->options->flags & DB_PLAINTEXTS) {
list_add(db->plaintexts, line);
return;
}
This is fixed with #4726. |
As I pointed out in #4388 (comment), jumbo's usage of
split()
on--show
is much heavier than core's, which is both good (allowing for #4428) and bad (slow). #4429 is a start at optimizing it, however we can do more.Perhaps most importantly, we can optimize the scanning of the formats list in
ldr_show_pot_line()
to cache and probe the previous line's format'svalid()
first.Also, I think right after merging #4429 (or adding to it) we can also make
ldr_cracked_hash()
case-sensitive.Further, why do we(?) even bother to build the
db->cracked_hash
table when invoked with--make-charset
? We should probably skip that.Finally, given that #4429 obsoletes
FMT_SPLIT_UNIFIES_CASE
, should we drop that flag from everywhere, keep it around in case we need it again later, or rename/repurpose it (e.g., to justFMT_SPLIT_UNIFIES
, so that we'd set it in more formats yet be able to skipsplit()
inldr_show_pot_line()
for most formats)?The text was updated successfully, but these errors were encountered: