Repository navigation
Conversation
I see from bolt_profiles/libc10_cuda.yaml that the comparator is the hottest function in libc10_cuda.so. Using a function ptr based comparator hinders inlining by the compiler. Replacing it with a struct based comparator should help.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/195129
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 4fa98e5 with merge base 4380f31 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
| static bool BlockComparatorSizeCounterAddress(const Block* a, const Block* b); | ||
| static bool BlockComparatorAddress(const Block* a, const Block* b); | ||
|
|
||
| struct BlockComparatorSizeCounterAddress { |
There was a problem hiding this comment.
Since these are hot paths shouldn't they be marked as noexcept too?
There was a problem hiding this comment.
Or would this also hurt inlining perhaps?
There was a problem hiding this comment.
Regarding noexcept, since there's nothing that can throw in here, hopefully the compiler won't generate anything exception related. I don't know if it will make a difference to performance.
Regarding inlining, I would assume it's more amenable to inlining now since we don't have to call through a function pointer.
Let me know if you would like me to change anything here!
|
@claude review this PR |
|
Claude finished @Skylion007's task in 19m 6s —— View job PR Review: #195129A clean, correct refactor that turns the indirect function-pointer comparator into a statically-known functor; the only real gap is that a performance-motivated PR ships without a before/after number, and the answer to @Skylion007's Full reviewSummaryReplaces the Performance
Answer to @Skylion007's review comment (
|
|
Could you fix the XPU identical caching allocator too to solve the same issue as well? |
|
@Skylion007 is it okay if I do that in a follow up PR so it's easy to revert if there are any issues on either side. |
|
@pytorchmergebot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
In `CUDACachingAllocator` the `Block` comparator is a hot function. #195129 optimizes it so that the compiler can inline it. This PR brings the same change to XPUCachingAllocator. Pull Request resolved: #195176 Approved by: https://github.com/Skylion007
…95374) Follow up to #195176 #195129 . Similarly this allows the inlining of a very hot function Pull Request resolved: #195374 Approved by: https://github.com/lakshayg, https://github.com/malfet
I see from `build/bolt_profiles/libc10_cuda.yaml` that the block comparator is the hottest function in libc10_cuda.so. Using a function ptr based comparator hinders inlining. Replacing it with a struct based comparator should help. Pull Request resolved: pytorch#195129 Approved by: https://github.com/Skylion007
…h#195176) In `CUDACachingAllocator` the `Block` comparator is a hot function. pytorch#195129 optimizes it so that the compiler can inline it. This PR brings the same change to XPUCachingAllocator. Pull Request resolved: pytorch#195176 Approved by: https://github.com/Skylion007
…torch#195374) Follow up to pytorch#195176 pytorch#195129 . Similarly this allows the inlining of a very hot function Pull Request resolved: pytorch#195374 Approved by: https://github.com/lakshayg, https://github.com/malfet
I see from `build/bolt_profiles/libc10_cuda.yaml` that the block comparator is the hottest function in libc10_cuda.so. Using a function ptr based comparator hinders inlining. Replacing it with a struct based comparator should help. Pull Request resolved: pytorch#195129 Approved by: https://github.com/Skylion007
…h#195176) In `CUDACachingAllocator` the `Block` comparator is a hot function. pytorch#195129 optimizes it so that the compiler can inline it. This PR brings the same change to XPUCachingAllocator. Pull Request resolved: pytorch#195176 Approved by: https://github.com/Skylion007
…torch#195374) Follow up to pytorch#195176 pytorch#195129 . Similarly this allows the inlining of a very hot function Pull Request resolved: pytorch#195374 Approved by: https://github.com/lakshayg, https://github.com/malfet
I see from
build/bolt_profiles/libc10_cuda.yamlthat the block comparator is the hottest function in libc10_cuda.so. Using a function ptr based comparator hinders inlining. Replacing it with a struct based comparator should help.