-
Notifications
You must be signed in to change notification settings - Fork 10.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reenable JumpTableToSwitch pass by default #83229
base: main
Are you sure you want to change the base?
Reenable JumpTableToSwitch pass by default #83229
Conversation
@llvm/pr-subscribers-llvm-transforms Author: Alexander Shaposhnikov (alexander-shaposhnikov) ChangesThis is a recommit of 1069823 (#82546) Test plan:
Full diff: https://github.com/llvm/llvm-project/pull/83229.diff 9 Files Affected:
|
Edit: I forgot to rebuild, ignore me :) |
Remembering to rebuild this time, I tried a few thresholds:
Not sure that a jump table size of 3 even worth looking at, but it's what tames the build. For context, this is happening on a server with 160 Ampere Altra (Neoverse N1) cores, so it can do plenty of work while waiting for flang files to compile which helps the overall build time. Also we may be bumping up against single core performance perhaps that is why you were able to use threshold 5. It does not seem like a good idea to introduce something that even high end hardware struggles with, even if Flang's design might not be ideal. If there is a Google codebase that kinda looks like flang but does not have these problems, perhaps we can compare and refactor flang to match, but that's a whole other task. Again the bot's config is available in the build logs, https://lab.llvm.org/buildbot/#/builders/179/builds/9480, if you want to see if there's some flag that might be making this worse but in general it's gonna be what's in the flang sources as you've already seen. |
How do the build times change relative to without the pass being enabled, i.e. what does the pass contribute to the overall compile-time.
yeah, I don't think we should enable something by default that causes excessive compile-time increases for valid input. |
I'll get pass on/off and various threshold times for one of the large pre-processed files. |
With the pass disabled, or
Which is not exactly nuanced but there it is. Perhaps that file only has tables of a certain size. Certainly this explains why lowering the threshold to 5 got further into the build, but then got stuck on another file that probably has a different distribution of sizes.
|
@DavidSpickett thanks for confirming. Before adjusting the threshold, I think it would be good to make sure there are no compile-time explosions. Seems like the flang codebase is great at uncovering those in this particular case |
Final time for compiling the reproducer If you make reproducers from the problematic files, I am happy to try them on our hardware if that helps. Also if you find anything that Flang could do to reduce its compile time (regardless of this pass), I have colleagues working on it who might be able to implement that. We're probably stuck with the overall design but perhaps there's some small things we can do to help the compiler. |
@DavidSpickett - would you be so kind to try to build Flang from the latest source (using a bootstrapped version of Clang with the optimization enabled (need to add cl::init(true) to EnableJumpTableToSwitch) (but leave the threshold unchanged)) on your machine and see how long it takes ? |
clang 15 (release package) building -> clang 19 (88a733f with Took around 6.5 hours before I killed it. The same build without enabling the pass takes 15 minutes. |
@DavidSpickett - thanks, just want to clarify - is flang (release) = the current trunk ? p.s. what would be the best way for me to reproduce this (if any) - i.e. is there any way to trigger this particular builld bot before the commit? |
FWIW, I think that even if the specific flang issue is no longer present due to source changes in flang, we shouldn't re-enable this pass without some analysis for why that compile-time explosion happened in LLVM terms, and mitigation to avoid it -- beyond just lowering the threshold to avoid specific examples. It seems plausible that it could still happen in other cases with the lowered threshold. |
@nikic - I've looked (just a bit) into what's going on (probably will look more thoroughly when I have time, currently I'm overloaded with other work).
|
Yes it was 88a733f for the clang and then I used the same commit for flang. You mentioned libstdc++ vs. libcxx, this build is using libstdc++. We do have a builder that uses libcxx but it's single stage.
There is no way to run a pre-merge branch on a buildbot (but one day I hope). The buildbot is running a docker container based on Ubuntu Focal. Our image is https://hub.docker.com/layers/linaro/ci-arm64-tcwg-llvmbot-ubuntu/focal/images/sha256-19e78b36b34f63c27ee53cdc92b6d38c4158167ba32856924442fc652e719c60?context=explore / https://git.linaro.org/ci/dockerfiles.git/tree/focal-arm64-tcwg-base/focal-arm64-tcwg-llvmbot/Dockerfile but there shouldn't be anything in there that's majorly different from the base Ubuntu so try that first. If it's known to be AArch64 specific and you don't have access to a machine I can setup a container for you on one of ours. Email me at my commits address if you want to do that (and you / your employer is comfortable with that). It may reproduce on an AWS Graviton, I'm checking now, I'm pretty sure it will. That's another option if you have access to AWS. |
Also if you need someone to dig more into Flang specifically, I can ask one of my Linaro colleagues to look into this (I just report problems, they actually work on it :) ). |
It did reproduce on a Graviton. At On the original machine the overnight build is at 14 hours and counting and a few processes got killed by the system, so I'll stop it there. Not a particularly useful result but I was curious if it would complete. |
@DavidSpickett - thanks a lot, this is very useful (I'm still busy but hope to get back to this) |
This is a recommit of 1069823 (#82546)
with the default value of JumpTableSizeThreshold decreased from 10 to 5.
Added a comment with data points in JumpTableToSwitch.cpp.
Test plan: