This avoid rediscovering this table when reading each options, providing
a sensible 2% speedup when processing and empty file, and a measurable
speedup on typical workloads, see:
Details
- Reviewers
nikic JDevlieghere alexander-shaposhnikov jhenderson MaskRay - Group Reviewers
Restricted Project - Commits
- rG07bb29d8ffc3: [OptTable] Precompute OptTable prefixes union table through tablegen
Diff Detail
Event Timeline
Could we make this an optional opt-in maybe? I imagine for the majority of the tools, this has no measurable effect, but it currently makes the Opt library harder to use for every client.
Sure, let's have two constructors, one that uses a precomputed table and one that does the precomputation.
Would you prefer having only clang use the faster-but-less efficient method, or can I keep the changes as is?
I'd only use it in clang tbh. Clang uses many orders of magnitudes more opts than all other tools, and even there it's not a _huge_ win. (2% on empty file is very nice! But most of the time, people don't compile empty files, and I'm guessing on non-empty files this is a negligible win even in clang.) What do you think?
Added to versions of OptTable, one that uses a precomputed Table, generated by TableGen, and one that relies on the old, generic approach. Both are tested using the same test bench.
Updated benchmark: https://llvm-compile-time-tracker.com/compare.php?from=4da6cb3202817ee2897d6b690e4af950459caea4&to=19a492b704e8f5c1dea120b9c0d3859bd78796be&stat=instructions:u
As showcased by https://llvm-compile-time-tracker.com/compare.php?from=4da6cb3202817ee2897d6b690e4af950459caea4&to=19a492b704e8f5c1dea120b9c0d3859bd78796be&stat=instructions:u, it's not neglectible in -O0 (and obviously even less neglictible for the preprocessing-only step)
(rebased on main. Note that this patch is applied on top of https://reviews.llvm.org/D140699)
nope. Why would there be?
llvm/unittests/Option/OptionParsingTest.cpp | ||
---|---|---|
327 | @nikic: the DISABLED_ prefix seems to be a gtest convention, see https://github.com/google/googletest/blob/main/docs/advanced.md#temporarily-disabling-tests |
LGTM
Something about missing virtual destructors on a non-final class? Not sure when exactly that warning applies.
llvm/unittests/Option/OptionParsingTest.cpp | ||
---|---|---|
327 | Huh, TIL. |
Thanks for this change :)
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp | ||
---|---|---|
140 | C | |
140 | …not sure what this was, please ignore :) | |
llvm/include/llvm/Option/OptTable.h | ||
257 | (nit, kind of too late now: I would've renamed the base class to BaseOptTable or what and kept OptTable for this one, so that all the tools wouldn't have to be touched at all.) |
C