[all-commits] [llvm/llvm-project] 2fcffc: [ADT] Simplifying hex string parsing so it runs fa...

Ben Vanik via All-commits all-commits at lists.llvm.org
Wed Nov 3 20:44:17 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2fcffcd0e8e54f3c8c12fcfc58db4af47d5c4272
      https://github.com/llvm/llvm-project/commit/2fcffcd0e8e54f3c8c12fcfc58db4af47d5c4272
  Author: Ben Vanik <benvanik at google.com>
  Date:   2021-11-03 (Wed, 03 Nov 2021)

  Changed paths:
    M llvm/include/llvm/ADT/StringExtras.h
    M llvm/unittests/ADT/StringExtrasTest.cpp

  Log Message:
  -----------
  [ADT] Simplifying hex string parsing so it runs faster in debug modes.

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.

Reviewed By: dblaikie, stellaraccident

Differential Revision: https://reviews.llvm.org/D112105




More information about the All-commits mailing list