Separate TLS for InferenceMode#55238
Closed
ailzhang wants to merge 3 commits intogh/ailzhang/58/basefrom
Closed
Conversation
I tried to avoid creating new TLS, but InferenceMode::is_enabeld() is in perf critical path (TensorImpl constructor) so it seems worth adding one for it. This PR reduces one sources of instruction count increased by #55008. ``` λ ~ python compare.py <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0x7f59097ef310> 100 0x0000000004854750 -100 0x0000000004854760 -4400 c10::impl::tls_is_dispatch_key_included(...) ``` [ghstack-poisoned]
Contributor
💊 CI failures summary and remediationsAs of commit 739fede (more details on the Dr. CI page):
🕵️ 1 new failure recognized by patternsThe following CI failures do not appear to be due to upstream breakages:
|
| Job | Step | Action |
|---|---|---|
| Build | 🔁 rerun |
This comment was automatically generated by Dr. CI (expand for details).
Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions to the (internal) Dr. CI Users group.
I tried to avoid creating new TLS, but InferenceMode::is_enabeld() is in perf critical path (TensorImpl constructor) so it seems worth adding one for it. This PR reduces one sources of instruction count increased by #55008. ``` λ ~ python compare.py <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0x7f59097ef310> 100 0x0000000004854750 -100 0x0000000004854760 -4400 c10::impl::tls_is_dispatch_key_included(...) ``` Differential Revision: [D27539230](https://our.internmc.facebook.com/intern/diff/D27539230) [ghstack-poisoned]
ailzhang
pushed a commit
that referenced
this pull request
Apr 2, 2021
I tried to avoid creating new TLS, but InferenceMode::is_enabeld() is in perf critical path (TensorImpl constructor) so it seems worth adding one for it. This PR reduces one sources of instruction count increased by #55008. ``` λ ~ python compare.py <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0x7f59097ef310> 100 0x0000000004854750 -100 0x0000000004854760 -4400 c10::impl::tls_is_dispatch_key_included(...) ``` ghstack-source-id: 96dd9d5 Pull Request resolved: #55238
ezyang
approved these changes
Apr 5, 2021
Contributor
ezyang
left a comment
There was a problem hiding this comment.
OK. Note that I probably would have worded the comment a little differently; saying instead that there is an invariant that set_enabled must uphold (this is NBD because it's private so you can enforce the invariant easily anyway)
I tried to avoid creating new TLS, but InferenceMode::is_enabeld() is in perf critical path (TensorImpl constructor) so it seems worth adding one for it. This PR reduces one sources of instruction count increased by #55008. ``` λ ~ python compare.py <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0x7f59097ef310> 100 0x0000000004854750 -100 0x0000000004854760 -4400 c10::impl::tls_is_dispatch_key_included(...) ``` Differential Revision: [D27539230](https://our.internmc.facebook.com/intern/diff/D27539230) [ghstack-poisoned]
ailzhang
pushed a commit
that referenced
this pull request
Apr 5, 2021
I tried to avoid creating new TLS, but InferenceMode::is_enabeld() is in perf critical path (TensorImpl constructor) so it seems worth adding one for it. This PR reduces one sources of instruction count increased by #55008. ``` λ ~ python compare.py <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0x7f59097ef310> 100 0x0000000004854750 -100 0x0000000004854760 -4400 c10::impl::tls_is_dispatch_key_included(...) ``` ghstack-source-id: 84dce14 Pull Request resolved: #55238
ailzhang
pushed a commit
to ailzhang/pytorch
that referenced
this pull request
Apr 6, 2021
Summary: Pull Request resolved: pytorch#55238 I tried to avoid creating new TLS, but InferenceMode::is_enabeld() is in perf critical path (TensorImpl constructor) so it seems worth adding one for it. This PR reduces one sources of instruction count increased by pytorch#55008. ``` λ ~ python compare.py <torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0x7f59097ef310> 100 0x0000000004854750 -100 0x0000000004854760 -4400 c10::impl::tls_is_dispatch_key_included(...) ``` Test Plan: Imported from OSS Reviewed By: ezyang Differential Revision: D27539230 Pulled By: ailzhang fbshipit-source-id: 54b0c141d59ac569a154a036b284001fca9fc560
Contributor
ailzhang
pushed a commit
that referenced
this pull request
Apr 12, 2021
Now that #55238 is landed for a week and no complains. It seems safe to say FEATURE_TORCH_MOBILE is always true and we can do some cleanup. [ghstack-poisoned]
facebook-github-bot
pushed a commit
that referenced
this pull request
Apr 14, 2021
Summary: Pull Request resolved: #55835 Now that #55238 is landed for a week and no complains. It seems safe to say FEATURE_TORCH_MOBILE is always true and we can do some cleanup. Test Plan: Imported from OSS Reviewed By: ezyang, walterddr Differential Revision: D27721284 Pulled By: ailzhang fbshipit-source-id: 4896bc5f736373d0922cfbe8eed0d16df62f0fa1
krshrimali
pushed a commit
to krshrimali/pytorch
that referenced
this pull request
May 19, 2021
Summary: Pull Request resolved: pytorch#55835 Now that pytorch#55238 is landed for a week and no complains. It seems safe to say FEATURE_TORCH_MOBILE is always true and we can do some cleanup. Test Plan: Imported from OSS Reviewed By: ezyang, walterddr Differential Revision: D27721284 Pulled By: ailzhang fbshipit-source-id: 4896bc5f736373d0922cfbe8eed0d16df62f0fa1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack from ghstack:
I tried to avoid creating new TLS, but InferenceMode::is_enabeld()
is in perf critical path (TensorImpl constructor) so it seems
worth adding one for it.
This PR reduces one sources of instruction count increased by
#55008.
Differential Revision: D27539230