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

Update impls.html #56

Merged
merged 1 commit into from
Mar 5, 2020
Merged

Update impls.html #56

merged 1 commit into from
Mar 5, 2020

Conversation

rumpelsepp
Copy link
Contributor

Add https://github.com/fxamacker/cbor and remove incomplete implementation

Add https://github.com/fxamacker/cbor and remove incomplete implementation
@cabo
Copy link
Contributor

cabo commented Aug 12, 2019

So what is the state of 2tvenom's implementation?

@rumpelsepp
Copy link
Contributor Author

According to github, it seems unmaintained for the last 2 years and has at least these known issues (from the readme):

  • Not support tags. 6 major type (in future)
  • Not support 16 floats encoding
  • Not decode nil (null) vars
  • Encode does't support indefinite-length values.

@cabo
Copy link
Contributor

cabo commented Aug 12, 2019

According to github, it seems unmaintained for the last 2 years

Yes, I saw that. Is the other implementation you are referencing compatible (at least vaguely)?
Or are they completely unrelated?

and has at least these known issues (from the readme):

  • Not support tags. 6 major type (in future)

Neither does the fxamacker one, AFACS.

  • Not support 16 floats encoding

OK

  • Not decode nil (null) vars

That is a limitation.

  • Encode does't support indefinite-length values.

Does the fxamacker one?

Just trying to find out if the 2tvenom one should stay in or is wholeheartedly replaced. Maybe I should contact 2tvenom.

@cabo cabo mentioned this pull request Aug 12, 2019
@rumpelsepp
Copy link
Contributor Author

rumpelsepp commented Aug 12, 2019

Yes, I saw that. Is the other implementation you are referencing compatible (at least vaguely)?

Would say so. Same API design.

Does the fxamacker one?

I'll ask him.

@fxamacker
Copy link
Contributor

Hi,

I maintain fxamacker/cbor. Thanks for considering it.

Not support tags. 6 major type

My decoder ignores tags but decodes tagged data. Encoder does not support tags yet.

Encode does't support indefinite-length values.

My decoder supports indefinite-length values for bytes/strings/arrays/maps. Encoder doesn't support it yet.

By comparison, 2tvenom/cbor doesn't appear to support decoding indefinite-length values, based on a quick look at 2tvenom/cbor/cbor.go.

Thanks again,

Faye

@rumpelsepp
Copy link
Contributor Author

Encode does't support indefinite-length values.

Does the fxamacker one?

Since the last release it does.

https://github.com/fxamacker/cbor/releases/tag/v0.2.0

@rumpelsepp
Copy link
Contributor Author

@cabo Do you expect me to change this pull request in any way? I am happy to incorporate any feedback.

@fxamacker
Copy link
Contributor

I released fxamacker/cbor v1.0. Changes are summarized here.

Please let me know if you have any questions or suggestions. Thanks.

@rumpelsepp
Copy link
Contributor Author

@cabo The mentioned cbor implementation evolved rapidly and is now in a state that I recommend adding to the website. The README now covers information to all limitations and there is a roadmap as well.

@fxamacker
Copy link
Contributor

@cabo Hello! I released fxamacker/cbor 2.1. It is a fast, safe, and full-featured generic CBOR encoder and decoder in Go.

Compared to the best Go impl listed on cbor.io, it is more full-featured, faster, uses less memory, produces smaller data, and produces smaller apps (see comparisons below).

Please let me know if there's anything that's preventing fxamacker/cbor from being listed. I can provide a PR if you prefer not to replace an existing Go impl. Thanks!

fxamacker/cbor 2.1 supports:

  • CBOR tags (API supports built-in and user-defined tags).
  • Preferred serialization, including IEEE 754 binary16.
  • Duplicate map key detection (option to enforce or ignore).
  • Indefinite length data for encoding and decoding.
  • Sort options: unsorted, length-first and bytewise-lexicographic.
  • Encoder options for floating-point shortest form, NaN, and Infinity.
  • Decoder checks for well-formedness and validates data.
  • Decoder doesn't crash and avoids resource exhaustion from malformed/malicious CBOR data.

More info at: Encoder and Decoder Options, and Standards

Here's how fxamacker/cbor compares to the best Go library currently listed on cbor.io using using test data from RFC 8392 A.1 for speed and memory comparisons.

Safety Comparison

fxamacker/cbor 2.1 ugorji/go 1.1.7
Bad data 1 57.4 ns/op, 32 B/op, 1 allocs/op ⚠️ fatal error: out of memory
Bad data 2 67.7 ns/op, 32 B/op, 1 allocs/op ⚠️ runtime: out of memory: cannot allocate

Compiled Program Size Comparison

fxamacker/cbor 2.1 ugorji/go 1.1.7
Custom app 2.7 MB 11.9 MB
cisco/senml 7.6 MB 12 MB

Speed Comparison (lower ns/op is better)

fxamacker/cbor 2.1 ugorji/go 1.1.7
Encode CWT 457 ns/op 995 ns/op
Decode CWT 796 ns/op 1105 ns/op

Memory Comparison (lower numbers are better)

fxamacker/cbor 2.1 ugorji/go 1.1.7
Encode CWT 176 B/op, 2 allocs/op 1424 B/op, 4 allocs/op
Decode CWT 176 B/op, 6 allocs/op 568 B/op, 6 allocs/op

@cabo cabo merged commit d7eb676 into cbor:master Mar 5, 2020
@cabo
Copy link
Contributor

cabo commented Mar 5, 2020

Thank you for this interesting implementation, and apologies for my glacial speed merging the pointer to this.

@rumpelsepp rumpelsepp deleted the patch-1 branch March 5, 2020 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants