[PATCH] D112105: [ADT] Simplifying hex string parsing so it runs faster in debug modes.
Ben Vanik via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 19 16:14:42 PDT 2021
benvanik created this revision.
benvanik added a reviewer: rriddle.
benvanik added projects: LLVM, MLIR.
Herald added subscribers: Chia-hungDuan, dexonsmith.
benvanik requested review of this revision.
Herald added subscribers: llvm-commits, stephenneuendorffer.
This expands the lookup table statically and avoids routing through methods that
contain asserts (like StringRef/std::string element accessors and drop_front)
such that performance is more predictable across compilation environments. This
was primarily driven by slow debug mode performance but has a large benefit in
release builds as well.
ssd_mobilenet_v2_face_float (42MB .mlir)
Debug/MSVC (old): 5.22s
Debug/MSVC (new): 0.16s
Release/MSVC (old): 0.81s
Release/MSVC (new): 0.02s
huggingface_minilm (536MB .mlir)
Debug/MSVC (old): 65.31s
Debug/MSVC (new): 2.03s
Release/MSVC (old): 9.93s
Release/MSVC (new): 0.27s
Now in debug the time is split evenly between lexString, tryGetFromHex, and
element attrs hashing, with the next step to making it faster being to combine
the work (incremental hashing during conversion, etc) - but this is at least in
the right order of magnitude and retains the original API surface.
I have not profiled a build with clang but this is strictly less code and simpler
data structures so I'd expect improvements there as well.
This also fixes a bug where 0xFF bytes in the input would read out of bounds.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D112105
Files:
llvm/include/llvm/ADT/StringExtras.h
llvm/unittests/ADT/StringExtrasTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112105.380800.patch
Type: text/x-patch
Size: 4066 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211019/900d79e1/attachment.bin>
More information about the llvm-commits
mailing list