-
Notifications
You must be signed in to change notification settings - Fork 12k
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
[Coroutines] The cross suspend point analysis is not scaling #62348
Comments
@llvm/issue-subscribers-coroutines |
The root cause problem is that coroutines uses a textbook style data flow analysis for the lifetime analysis, which is powerful but not scaling. I feel it is not easy to refactor this fundamentally given it runs almost good for 5 years, we don't touch it frequently. So I can possibly only add some pruning techniques. |
…int information Mitigate #62348 The root cause for the above issue is that we used a textbook dataflow analysis for the cross suspend point information. The analysis is powerful but not scaling. It is not easy to improve the current algorithm and the patch tries to prune some branches to mitigate the problems. Before the patch: ``` n: 20000 real 0m11.081s user 0m10.597s sys 0m0.320s n: 40000 real 0m32.927s user 0m31.403s sys 0m1.043s n: 60000 real 1m2.145s user 0m58.903s sys 0m2.268s n: 80000 real 1m47.143s user 1m41.630s sys 0m3.857s n: 100000 real 2m34.758s user 2m26.587s sys 0m5.922s ``` After the patch: ``` n: 20000 real 0m10.418s user 0m9.945s sys 0m0.311s n: 40000 real 0m27.884s user 0m26.430s sys 0m1.036s n: 60000 real 0m52.420s user 0m49.321s sys 0m2.267s n: 80000 real 1m25.389s user 1m20.247s sys 0m3.856s n: 100000 real 2m4.275s user 1m56.405s sys 0m5.975s ``` This patch intended to be a NFC patch.
I tried to mitigate the issue. Now the numbers are: Before:
After:
It is slightly better now. But I don't have an idea to fix the true issue really. |
@ChuanqiXu9 I add a patch for this issue, please help to review it. |
information. Fixed #62348 Propagate cross suspend point information by visiting CFG. Just only go through two times at most, you can get all the cross suspend point information. Before the patch: ``` n: 20000 4.31user 0.11system 0:04.44elapsed 99%CPU (0avgtext+0avgdata 552352maxresident)k 0inputs+8848outputs (0major+126254minor)pagefaults 0swaps n: 40000 11.24user 0.40system 0:11.66elapsed 99%CPU (0avgtext+0avgdata 1788404maxresident)k 0inputs+17600outputs (0major+431105minor)pagefaults 0swaps n: 60000 21.65user 0.96system 0:22.62elapsed 99%CPU (0avgtext+0avgdata 3809836maxresident)k 0inputs+26352outputs (0major+934749minor)pagefaults 0swaps n: 80000 37.05user 1.53system 0:38.58elapsed 99%CPU (0avgtext+0avgdata 6602396maxresident)k 0inputs+35096outputs (0major+1622584minor)pagefaults 0swaps n: 100000 51.87user 2.67system 0:54.54elapsed 99%CPU (0avgtext+0avgdata 10210736maxresident)k 0inputs+43848outputs (0major+2518945minor)pagefaults 0swaps ``` After the patch: ``` n: 20000 3.17user 0.16system 0:03.33elapsed 100%CPU (0avgtext+0avgdata 551736maxresident)k 0inputs+8848outputs (0major+126192minor)pagefaults 0swaps n: 40000 6.10user 0.42system 0:06.54elapsed 99%CPU (0avgtext+0avgdata 1787848maxresident)k 0inputs+17600outputs (0major+432212minor)pagefaults 0swaps n: 60000 9.13user 0.89system 0:10.03elapsed 99%CPU (0avgtext+0avgdata 3809108maxresident)k 0inputs+26352outputs (0major+931280minor)pagefaults 0swaps n: 80000 12.44user 1.57system 0:14.02elapsed 99%CPU (0avgtext+0avgdata 6603432maxresident)k 0inputs+35096outputs (0major+1624635minor)pagefaults 0swaps n: 100000 16.29user 2.28system 0:18.59elapsed 99%CPU (0avgtext+0avgdata 10212808maxresident)k 0inputs+43848outputs (0major+2522200minor)pagefaults 0swaps ``` Reviewed By: ChuanqiXu Differential Revision: https://reviews.llvm.org/D154695
information. Fixed llvm#62348 Propagate cross suspend point information by visiting CFG. Just only go through two times at most, you can get all the cross suspend point information. Before the patch: ``` n: 20000 4.31user 0.11system 0:04.44elapsed 99%CPU (0avgtext+0avgdata 552352maxresident)k 0inputs+8848outputs (0major+126254minor)pagefaults 0swaps n: 40000 11.24user 0.40system 0:11.66elapsed 99%CPU (0avgtext+0avgdata 1788404maxresident)k 0inputs+17600outputs (0major+431105minor)pagefaults 0swaps n: 60000 21.65user 0.96system 0:22.62elapsed 99%CPU (0avgtext+0avgdata 3809836maxresident)k 0inputs+26352outputs (0major+934749minor)pagefaults 0swaps n: 80000 37.05user 1.53system 0:38.58elapsed 99%CPU (0avgtext+0avgdata 6602396maxresident)k 0inputs+35096outputs (0major+1622584minor)pagefaults 0swaps n: 100000 51.87user 2.67system 0:54.54elapsed 99%CPU (0avgtext+0avgdata 10210736maxresident)k 0inputs+43848outputs (0major+2518945minor)pagefaults 0swaps ``` After the patch: ``` n: 20000 3.17user 0.16system 0:03.33elapsed 100%CPU (0avgtext+0avgdata 551736maxresident)k 0inputs+8848outputs (0major+126192minor)pagefaults 0swaps n: 40000 6.10user 0.42system 0:06.54elapsed 99%CPU (0avgtext+0avgdata 1787848maxresident)k 0inputs+17600outputs (0major+432212minor)pagefaults 0swaps n: 60000 9.13user 0.89system 0:10.03elapsed 99%CPU (0avgtext+0avgdata 3809108maxresident)k 0inputs+26352outputs (0major+931280minor)pagefaults 0swaps n: 80000 12.44user 1.57system 0:14.02elapsed 99%CPU (0avgtext+0avgdata 6603432maxresident)k 0inputs+35096outputs (0major+1624635minor)pagefaults 0swaps n: 100000 16.29user 2.28system 0:18.59elapsed 99%CPU (0avgtext+0avgdata 10212808maxresident)k 0inputs+43848outputs (0major+2522200minor)pagefaults 0swaps ```
information. Fixed llvm#62348 Propagate cross suspend point information by visiting CFG. Just only go through two times at most, you can get all the cross suspend point information. Before the patch: ``` n: 20000 4.31user 0.11system 0:04.44elapsed 99%CPU (0avgtext+0avgdata 552352maxresident)k 0inputs+8848outputs (0major+126254minor)pagefaults 0swaps n: 40000 11.24user 0.40system 0:11.66elapsed 99%CPU (0avgtext+0avgdata 1788404maxresident)k 0inputs+17600outputs (0major+431105minor)pagefaults 0swaps n: 60000 21.65user 0.96system 0:22.62elapsed 99%CPU (0avgtext+0avgdata 3809836maxresident)k 0inputs+26352outputs (0major+934749minor)pagefaults 0swaps n: 80000 37.05user 1.53system 0:38.58elapsed 99%CPU (0avgtext+0avgdata 6602396maxresident)k 0inputs+35096outputs (0major+1622584minor)pagefaults 0swaps n: 100000 51.87user 2.67system 0:54.54elapsed 99%CPU (0avgtext+0avgdata 10210736maxresident)k 0inputs+43848outputs (0major+2518945minor)pagefaults 0swaps ``` After the patch: ``` n: 20000 3.17user 0.16system 0:03.33elapsed 100%CPU (0avgtext+0avgdata 551736maxresident)k 0inputs+8848outputs (0major+126192minor)pagefaults 0swaps n: 40000 6.10user 0.42system 0:06.54elapsed 99%CPU (0avgtext+0avgdata 1787848maxresident)k 0inputs+17600outputs (0major+432212minor)pagefaults 0swaps n: 60000 9.13user 0.89system 0:10.03elapsed 99%CPU (0avgtext+0avgdata 3809108maxresident)k 0inputs+26352outputs (0major+931280minor)pagefaults 0swaps n: 80000 12.44user 1.57system 0:14.02elapsed 99%CPU (0avgtext+0avgdata 6603432maxresident)k 0inputs+35096outputs (0major+1624635minor)pagefaults 0swaps n: 100000 16.29user 2.28system 0:18.59elapsed 99%CPU (0avgtext+0avgdata 10212808maxresident)k 0inputs+43848outputs (0major+2522200minor)pagefaults 0swaps ``` Reviewed By: ChuanqiXu Differential Revision: https://reviews.llvm.org/D154695
…bout cross suspend infomation to reach a fixed point faster. Fixed #62348 Propagate cross suspend point information along reverse post-order. It does not modify the original function, just selects a better traversal order. Before the patch: ``` n: 20000 4.31user 0.11system 0:04.44elapsed 99%CPU (0avgtext+0avgdata 552352maxresident)k 0inputs+8848outputs (0major+126254minor)pagefaults 0swaps n: 40000 11.24user 0.40system 0:11.66elapsed 99%CPU (0avgtext+0avgdata 1788404maxresident)k 0inputs+17600outputs (0major+431105minor)pagefaults 0swaps n: 60000 21.65user 0.96system 0:22.62elapsed 99%CPU (0avgtext+0avgdata 3809836maxresident)k 0inputs+26352outputs (0major+934749minor)pagefaults 0swaps n: 80000 37.05user 1.53system 0:38.58elapsed 99%CPU (0avgtext+0avgdata 6602396maxresident)k 0inputs+35096outputs (0major+1622584minor)pagefaults 0swaps n: 100000 51.87user 2.67system 0:54.54elapsed 99%CPU (0avgtext+0avgdata 10210736maxresident)k 0inputs+43848outputs (0major+2518945minor)pagefaults 0swaps ``` After the patch: ``` n: 20000 3.08user 0.12system 0:03.21elapsed 99%CPU (0avgtext+0avgdata 551012maxresident)k 0inputs+8848outputs (0major+129349minor)pagefaults 0swaps n: 40000 5.88user 0.33system 0:06.22elapsed 99%CPU (0avgtext+0avgdata 1789248maxresident)k 0inputs+17600outputs (0major+435096minor)pagefaults 0swaps n: 60000 8.84user 0.77system 0:09.63elapsed 99%CPU (0avgtext+0avgdata 3807800maxresident)k 0inputs+26352outputs (0major+939119minor)pagefaults 0swaps n: 80000 11.64user 1.58system 0:13.23elapsed 99%CPU (0avgtext+0avgdata 6604708maxresident)k 0inputs+35096outputs (0major+1629566minor)pagefaults 0swaps n: 100000 15.21user 2.56system 0:17.79elapsed 99%CPU (0avgtext+0avgdata 10208828maxresident)k 8inputs+43848outputs (0major+2526611minor)pagefaults 0swaps ``` Reviewed By: MatzeB, ChuanqiXu Differential Revision: https://reviews.llvm.org/D156850
information. Fixed llvm#62348 Propagate cross suspend point information by visiting CFG. Just only go through two times at most, you can get all the cross suspend point information. Before the patch: ``` n: 20000 4.31user 0.11system 0:04.44elapsed 99%CPU (0avgtext+0avgdata 552352maxresident)k 0inputs+8848outputs (0major+126254minor)pagefaults 0swaps n: 40000 11.24user 0.40system 0:11.66elapsed 99%CPU (0avgtext+0avgdata 1788404maxresident)k 0inputs+17600outputs (0major+431105minor)pagefaults 0swaps n: 60000 21.65user 0.96system 0:22.62elapsed 99%CPU (0avgtext+0avgdata 3809836maxresident)k 0inputs+26352outputs (0major+934749minor)pagefaults 0swaps n: 80000 37.05user 1.53system 0:38.58elapsed 99%CPU (0avgtext+0avgdata 6602396maxresident)k 0inputs+35096outputs (0major+1622584minor)pagefaults 0swaps n: 100000 51.87user 2.67system 0:54.54elapsed 99%CPU (0avgtext+0avgdata 10210736maxresident)k 0inputs+43848outputs (0major+2518945minor)pagefaults 0swaps ``` After the patch: ``` n: 20000 3.17user 0.16system 0:03.33elapsed 100%CPU (0avgtext+0avgdata 551736maxresident)k 0inputs+8848outputs (0major+126192minor)pagefaults 0swaps n: 40000 6.10user 0.42system 0:06.54elapsed 99%CPU (0avgtext+0avgdata 1787848maxresident)k 0inputs+17600outputs (0major+432212minor)pagefaults 0swaps n: 60000 9.13user 0.89system 0:10.03elapsed 99%CPU (0avgtext+0avgdata 3809108maxresident)k 0inputs+26352outputs (0major+931280minor)pagefaults 0swaps n: 80000 12.44user 1.57system 0:14.02elapsed 99%CPU (0avgtext+0avgdata 6603432maxresident)k 0inputs+35096outputs (0major+1624635minor)pagefaults 0swaps n: 100000 16.29user 2.28system 0:18.59elapsed 99%CPU (0avgtext+0avgdata 10212808maxresident)k 0inputs+43848outputs (0major+2522200minor)pagefaults 0swaps ```
information. Fixed llvm#62348 Propagate cross suspend point information by visiting CFG. Just only go through two times at most, you can get all the cross suspend point information. Before the patch: ``` n: 20000 4.31user 0.11system 0:04.44elapsed 99%CPU (0avgtext+0avgdata 552352maxresident)k 0inputs+8848outputs (0major+126254minor)pagefaults 0swaps n: 40000 11.24user 0.40system 0:11.66elapsed 99%CPU (0avgtext+0avgdata 1788404maxresident)k 0inputs+17600outputs (0major+431105minor)pagefaults 0swaps n: 60000 21.65user 0.96system 0:22.62elapsed 99%CPU (0avgtext+0avgdata 3809836maxresident)k 0inputs+26352outputs (0major+934749minor)pagefaults 0swaps n: 80000 37.05user 1.53system 0:38.58elapsed 99%CPU (0avgtext+0avgdata 6602396maxresident)k 0inputs+35096outputs (0major+1622584minor)pagefaults 0swaps n: 100000 51.87user 2.67system 0:54.54elapsed 99%CPU (0avgtext+0avgdata 10210736maxresident)k 0inputs+43848outputs (0major+2518945minor)pagefaults 0swaps ``` After the patch: ``` n: 20000 3.17user 0.16system 0:03.33elapsed 100%CPU (0avgtext+0avgdata 551736maxresident)k 0inputs+8848outputs (0major+126192minor)pagefaults 0swaps n: 40000 6.10user 0.42system 0:06.54elapsed 99%CPU (0avgtext+0avgdata 1787848maxresident)k 0inputs+17600outputs (0major+432212minor)pagefaults 0swaps n: 60000 9.13user 0.89system 0:10.03elapsed 99%CPU (0avgtext+0avgdata 3809108maxresident)k 0inputs+26352outputs (0major+931280minor)pagefaults 0swaps n: 80000 12.44user 1.57system 0:14.02elapsed 99%CPU (0avgtext+0avgdata 6603432maxresident)k 0inputs+35096outputs (0major+1624635minor)pagefaults 0swaps n: 100000 16.29user 2.28system 0:18.59elapsed 99%CPU (0avgtext+0avgdata 10212808maxresident)k 0inputs+43848outputs (0major+2522200minor)pagefaults 0swaps ``` Reviewed By: ChuanqiXu Differential Revision: https://reviews.llvm.org/D154695
The compilation time problem of C++20 coroutine still exists in Clang 16.0.2, after the fix to #58650.
Here shows the comparison of 2 scenarios (
a2.cpp
anda3.app
).a2.cpp
is like:a3.cpp
is like:Generation and test scripts:
gen2.cpp
generates use cases that possibly enable bounds checking.gen3.cpp
generates use cases that try to avoid bounds checking.test2.sh
test3.sh
Compilation time:
The text was updated successfully, but these errors were encountered: