This is an archive of the discontinued LLVM Phabricator instance.

speeding up ext-tsp for huge instances
ClosedPublic

Authored by spupyrev on Mar 1 2022, 3:07 PM.

Details

Summary

Some (rare) control-flow graphs in datacenter binaries contain many basic
blocks, e.g, >50K. In such cases, the existing implementation might take
up to several hours. This diff introduces a simple flag, MaxChainSize, that
forbid creating chains of blocks exceeding the specified size. When setting
MaxChainSize=4096, the runtime of the alg increase by ~100x on some prod
benchmarks.

Separately introducing an option to disable ext-tsp for function w/o profile
data (OFF by default). If we ever hit a runtime problem, we may turn it ON.

Diff Detail

Event Timeline

spupyrev created this revision.Mar 1 2022, 3:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 1 2022, 3:07 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
spupyrev requested review of this revision.Mar 1 2022, 3:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 1 2022, 3:07 PM
spupyrev edited the summary of this revision. (Show Details)Mar 1 2022, 3:16 PM
spupyrev added reviewers: hoy, wenlei.
wenlei added a comment.Mar 1 2022, 3:58 PM

When setting MaxChainSize=4096, the runtime of the alg increase by ~100x on some prod benchmarks.

Maybe I'm missing something, setting MaxChainSize=4096 is what this change does, isn't it supposed to reduce runtime of the alg?

llvm/lib/Transforms/Utils/CodeLayout.cpp
73

What's the typical chain size and how often do we actually hit 4096 limit?

sorry misspelled increase/decrease

For clang-10 binary, no functions is affected. For the larger prod binary, 2 instances are affected: One is the gigantic with 50K blocks (max chain reaches >30K), another is with 20K blocks (max chain reaches 8K). I suspect it would be safe to set the max bound to 2048 or 1024 without measurable impact on the quality.

wenlei accepted this revision.Mar 1 2022, 4:42 PM

lgtm, thanks.

This revision is now accepted and ready to land.Mar 1 2022, 4:42 PM
hoy accepted this revision.Mar 1 2022, 5:51 PM
This revision was landed with ongoing or failed builds.Mar 2 2022, 7:23 AM
This revision was automatically updated to reflect the committed changes.