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

Improve decoding speed #47

Closed
fxamacker opened this issue Nov 24, 2019 · 1 comment · Fixed by #149
Closed

Improve decoding speed #47

fxamacker opened this issue Nov 24, 2019 · 1 comment · Fixed by #149
Milestone

Comments

@fxamacker
Copy link
Owner

fxamacker commented Nov 24, 2019

Spotted several optimizations while working on milestone v1.3.1.

Speedups should be around 4% or 5% faster for COSE and CWT decoding depending on other changes in the same release.

@fxamacker fxamacker added this to the v1.4.0 milestone Nov 24, 2019
@fxamacker fxamacker modified the milestones: v2.0.0, v2.1.0 Jan 30, 2020
@x448
Copy link
Contributor

x448 commented Jan 30, 2020

@fxamacker Thanks. v2.0 is going to be faster than v1.5, so it makes sense to move this to v2.1.

fxamacker added a commit that referenced this issue Feb 13, 2020
CBOR tag support includes:
- API to use TagSet to register user-defined Go type with CBOR tag number.
- API to encode Go value with CBOR tag number without registering.
- API to extract CBOR tag number with Tag or RawTag structs.
- API to use immutable TagSet or mutable shared TagSet (shared tag registry).
- EncOptions/DecOptions settings to tag or not tag time.Time values.

Improved decoding speed and memory for "keyasint" struct (COSE, CWT, etc.):
- speed is faster by 24% - 28%.
- mem allocs is reduced by 44% - 61%.
- mem bytes is reduced by 13% - 26%.

Encoding is a bit slower around 2% - 4% because of added features.  Optimization
of encoding can be tackled in future releases because it is still very fast.

TagSet is a Go interface to register tag support for user-defined Go types.

EncMode and DecMode are reusable interfaces that are safe for concurrency.
They export codec functions with identical signatures to encoding/json.

EncMode can be created by these functions:
	EncOptions{...}.EncMode()
	EncOptions{...}.EncModeWithTags(TagSet)
	EncOptions{...}.EncModeWithSharedTags(TagSet)

DecMode can be created by these functions:
	DecOptions{...}.DecMode()
	DecOptions{...}.DecModeWithTags(TagSet)
	DecOptions{...}.DecModeWithSharedTags(TagSet)

Tag and RawTag are structs used to encode/decode CBOR tag number with tag content.

See docs for more details.

Closed: #44
Closed: #47
Closed: #125
Closed: #147
fxamacker added a commit that referenced this issue Feb 15, 2020
CBOR tag support includes:
- API to use TagSet to register user-defined Go type with CBOR tag number.
- API to encode Go value with CBOR tag number without registering.
- API to extract CBOR tag number with Tag or RawTag structs.
- API to use immutable TagSet or mutable shared TagSet (shared tag registry).
- EncOptions/DecOptions settings to tag or not tag time.Time values.

Improved decoding speed and memory for "keyasint" struct (COSE, CWT, etc.):
- speed is faster by 24% - 28%.
- mem allocs is reduced by 44% - 61%.
- mem bytes is reduced by 13% - 26%.

Encoding is a bit slower around 2% - 4% because of added features.  Optimization
of encoding can be tackled in future releases because it is still very fast.

TagSet is a Go interface to register tag support for user-defined Go types.

EncMode and DecMode are reusable interfaces that are safe for concurrency.
They export codec functions with identical signatures to encoding/json.

EncMode can be created by these functions:
	EncOptions{...}.EncMode()
	EncOptions{...}.EncModeWithTags(TagSet)
	EncOptions{...}.EncModeWithSharedTags(TagSet)

DecMode can be created by these functions:
	DecOptions{...}.DecMode()
	DecOptions{...}.DecModeWithTags(TagSet)
	DecOptions{...}.DecModeWithSharedTags(TagSet)

Tag and RawTag are structs used to encode/decode CBOR tag number with tag content.

See docs and closed issues for more details.

Closed: #44
Closed: #47
Closed: #125
Closed: #147
Closed: #151
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants