-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[pytorch] In torch::save() avoid zip compressing small header records. #28180
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
Closed
Conversation
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
ScriptModuleSerializer::writeCode() is the only place during torch::save()
serialization where we attempt to zip compress records.
This change avoids compressing these string records if they are
sufficiently small - e.g. in the example I looked at:
- the strings were 123 and 28 bytes, respectively.
- the cost in the compression routines was 16.5% of the torch::save() cost.
(we're building a huffman table for a 28 byte string).
We'd save time and not significantly affect the space if we add these
1-line conditional compressions, rather than making it unconditional.
Differential Revision: [D17967995](https://our.internmc.facebook.com/intern/diff/D17967995/)
[ghstack-poisoned]
jjlilley
pushed a commit
that referenced
this pull request
Oct 16, 2019
ScriptModuleSerializer::writeCode() is the only place during torch::save()
serialization where we attempt to zip compress records.
This change avoids compressing these string records if they are
sufficiently small - e.g. in the example I looked at:
- the strings were 123 and 28 bytes, respectively.
- the cost in the compression routines was 16.5% of the torch::save() cost.
(we're building a huffman table for a 28 byte string).
We'd save time and not significantly affect the space if we add these
1-line conditional compressions, rather than making it unconditional.
Differential Revision: [D17967995](https://our.internmc.facebook.com/intern/diff/D17967995/)
ghstack-source-id: 92065904
Pull Request resolved: #28180
Author
|
fwiw, there's a pdf of the profile under D17967995... |
…der records."
ScriptModuleSerializer::writeCode() is the only place during torch::save()
serialization where we attempt to zip compress records.
This change avoids compressing these string records if they are
sufficiently small - e.g. in the example I looked at:
- the strings were 123 and 28 bytes, respectively.
- the cost in the compression routines was 16.5% of the torch::save() cost.
(we're building a huffman table for a 28 byte string).
We'd save time and not significantly affect the space if we add these
1-line conditional compressions, rather than making it unconditional.
Differential Revision: [D17967995](https://our.internmc.facebook.com/intern/diff/D17967995/)
[ghstack-poisoned]
jjlilley
pushed a commit
that referenced
this pull request
Oct 17, 2019
Pull Request resolved: #28180 ScriptModuleSerializer::writeCode() is the only place during torch::save() serialization where we attempt to zip compress records. This change avoids compressing these string records if they are sufficiently small - e.g. in the example I looked at: - the strings were 123 and 28 bytes, respectively. - the cost in the compression routines was 16.5% of the torch::save() cost. (we're building a huffman table for a 28 byte string). We'd save time and not significantly affect the space if we add these 1-line conditional compressions, rather than making it unconditional. ghstack-source-id: 92104517 Differential Revision: [D17967995](https://our.internmc.facebook.com/intern/diff/D17967995/)
Author
|
needed to rebase, to resolve merge conflicts. |
zdevito
approved these changes
Oct 18, 2019
Contributor
|
This pull request has been merged in d7ff34c. |
thiagocrepaldi
pushed a commit
to thiagocrepaldi/pytorch
that referenced
this pull request
Feb 4, 2020
…#28180) Summary: Pull Request resolved: pytorch#28180 ScriptModuleSerializer::writeCode() is the only place during torch::save() serialization where we attempt to zip compress records. This change avoids compressing these string records if they are sufficiently small - e.g. in the example I looked at: - the strings were 123 and 28 bytes, respectively. - the cost in the compression routines was 16.5% of the torch::save() cost. (we're building a huffman table for a 28 byte string). We'd save time and not significantly affect the space if we add these 1-line conditional compressions, rather than making it unconditional. ghstack-source-id: 92104517 Test Plan: Benchmark: experimental/jeremyl/c2:SerializationBench Correctness: normal buck mode/dev-nosan caffe2/test/... Differential Revision: D17967995 fbshipit-source-id: 7ff934388533645dc987e105c814ffe6324f4596
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:
ScriptModuleSerializer::writeCode() is the only place during torch::save()
serialization where we attempt to zip compress records.
This change avoids compressing these string records if they are
sufficiently small - e.g. in the example I looked at:
(we're building a huffman table for a 28 byte string).
We'd save time and not significantly affect the space if we add these
1-line conditional compressions, rather than making it unconditional.
Differential Revision: D17967995