Skip to content
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

Optimize storage format #797

Merged
merged 16 commits into from
Apr 13, 2021
Merged

Optimize storage format #797

merged 16 commits into from
Apr 13, 2021

Conversation

turbolent
Copy link
Member

Merge the implementation of #738

This is a merge of the feature branch consisting of previously reviewed PRs.

Kudos to @fxamacker for this fantastic work! 👏


  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

fxamacker and others added 15 commits March 30, 2021 19:49
Switch from CBOR map to CBOR array to improve speed and preserve
ordering.

Remove key strings from encoding.

Remove old backwards-compatibility decoding code.

Add tests, including round-trip for decoding old format and encoding new
format.

Closes #743
Add error handling to check decoded dictionary array length.

Incorporate feedback to replace append with direct assignment
for an additional speed gain of 0.5-0.7% for encoding large data.
Switch from CBOR map to CBOR array to improve speed and preserve
ordering.

Remove unnecessary field sorting when decoding.

Remove old backwards-compatibility decoding code (decoding type ID).

Add tests, including round-trip for decoding old format and encoding
new format.

Closes #744
Optimize encoding by switch from CBOR map to CBOR array for:
- StorageReferenceValue
- PathValue
- CapabilityValue
- common.AddressLocation
- LinkValue
- CompositeStaticType
- InterfaceStaticType
- ConstantSizedStaticType
- ReferenceStaticType
- DictionaryStaticType
- RestrictedStaticType
- TypeValue

Remove old backwards-compatibility decoding of type id in
decodeCompositeStaticType() and decodeInterfaceStaticType()

Add tests, including round-trip for decoding old format and encoding new
format.

Comparisons using LinkValue (that don't contain composites and
dictionaries) show:

name                        old time/op    new time/op    delta
EncodeLink/link_167bytes-4    18.7µs ± 0%     9.5µs ± 0%  -49.41%
(p=0.000 n=10+10)
EncodeLink/link_192bytes-4    19.1µs ± 0%     9.4µs ± 0%  -50.56%
(p=0.000 n=10+10)

name                        old time/op    new time/op    delta
DecodeLink/link_167bytes-4    10.6µs ± 0%     7.7µs ± 1%  -26.87%
(p=0.000 n=10+9)
DecodeLink/link_192bytes-4    10.5µs ± 0%     7.7µs ± 0%  -27.02%
(p=0.000 n=10+10)

Encoding comparisons using the same LinkValue show 57%-60% less memory
use.

Closes #764
Create benchmarks that use testdata/*.cbor.gz files.

Add initial 6 *.cbor.gz files using data from a mainnet snapshot.

For safety, limit number of files processed and use io.LimitReader to
limit the max bytes uncompressed from each file.

Closes #765
Use the current year for the copyright because it's a new file.
@turbolent turbolent merged commit d08a67d into master Apr 13, 2021
@turbolent turbolent deleted the feature/storage-optimizations branch April 13, 2021 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants