D7411: dirs: resolve fuzzer OOM situation by disallowing deep directory hierarchies
durin42 (Augie Fackler)
phabricator at mercurial-scm.org
Thu Nov 14 22:26:16 EST 2019
durin42 added inline comments.
durin42 marked an inline comment as done.
INLINE COMMENTS
> indygreg wrote in dirs.c:66
> What code calls this function? Do we have any good perf numbers for introducing this loop?
>
> I ask because the diffing code is surprisingly impacted by the the "find newlines" stage. Using an implementation that the compiler can expand to SSE/AVX instructions is substantially faster. FWIW glibc and other C implementations have assembly versions of `strchr()` and `memchr()`, which could be substantially faster if the compiler isn't smart enough to detect the "count occurrences of chars" pattern.
I'd be happy to use memchr() but it occurred to me as I was failing to use memchr() effectively that we already find slashes in a loop here, and there's no risk of on-disk corruption so we can just count slashes as we populate the dict and stop. It's not nearly as fast in the fuzzer, but it does pass for the specific input that we're stuck on.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D7411/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D7411
To: durin42, #hg-reviewers
Cc: indygreg, mercurial-devel
More information about the Mercurial-devel
mailing list