Processing 2 GB XRay traces with "llvm-xray convert -output-format=yaml"
currently takes 1.5+ hours on my machine. When YAML is finally printed,
profiling shows huge amounts of time in YAML's needQuotes and isNumber,
doing regexp matching. That shouldn't be necessary for arbitrary input
and leaving it only when there's a chance of a float appearing makes it
consume only 40 minutes instead. More CPU savings to come.
Details
Diff Detail
- Repository
- rL LLVM
- Build Status
Buildable 15561 Build 15561: arc lint + arc unit
Event Timeline
Adding Reid and Zach who might be able to give more insight here.
include/llvm/Support/YAMLTraits.h | ||
---|---|---|
479–481 | Does it make sense to make the Regex object static and const so that we only compile/initialise it once? |
sync
include/llvm/Support/YAMLTraits.h | ||
---|---|---|
479–481 | I was too lazy to look into Regex implementation to check whether it actually makes sense. I bet the current version is faster though. |
include/llvm/Support/YAMLTraits.h | ||
---|---|---|
479–481 | Why would this be faster than having it compiled once, and only the first time it's needed? I suspect if you do that, instead of having to do a linear search first, would be much faster if it's possible to re-use a Regex object, compile it once, and re-use for all the times it's needed. |
include/llvm/Support/YAMLTraits.h | ||
---|---|---|
479–481 | Agree, this will make the case where it's not a number faster, but that's the uncommon case. The case where it *is* a number will become slower. I agree with Dean's suggestion of compiling the regex only once, but we can still do an early out if it's obviously not a number. However, instead of checking the entire string, how about just checking the first character? |
That regex is relatively simple. If we're worried about performance, maybe we should just roll it out into a series of find_first_(not_)of/consume_front/... statements
Does it make sense to make the Regex object static and const so that we only compile/initialise it once?