Uh oh!
There was an error while loading. Please reload this page.
syntax: Fix encoding and decoding spans - #31028
Conversation
rust-highfive
commented
Jan 19, 2016
r? @sfackler (rust_highfive has picked a reviewer for you, use r? to override) |
sfackler
commented
Jan 19, 2016
Large numbers are always somewhat sketchy to work with in JSON since they'll so often round trip through a double. Should we maybe encode with the packed number in a string? |
erickt
commented
Jan 19, 2016
@sfackler: True, although |
sfackler
commented
Jan 19, 2016
I've seen it hit in systems that use randomly generated 64 bit identifiers, for example. In this case, I think it'd require a high span index greater than 2^21, which is roughly 2 million. It seems not wildly unreasonable to have 2 megabytes of source code for a crate, but I'm not sure. |
michaelwoerister
commented
Jan 19, 2016
How bad would it be for JSON to encode spans as structs? Because for the binary encoding that is used for crate metadata, there's no more overhead for these. The main reason for encoding it as two separate values was to allow for the variable-length integer format to kick in properly. |
erickt
commented
Jan 19, 2016
@michaelwoerister: Yeah, serializing them into structs would work. We can save this for another time, but we could also optimize the rbml tuple encoding (and tuple structs) to match that of structs by leaving out the tag and the length encoding. We'd lose some safety, but it might shave some more bytes off our metadata. |
michaelwoerister
commented
Jan 19, 2016
erickt
commented
Jan 20, 2016
@sfackler / @michaelwoerister: I've updated the patch to serialize Spans as a struct. Tests passed locally, and the size of the libraries seems to be identical to before this patch. |
There was a problem hiding this comment.
The field index should be 1 here.
The protocol for `serialize::{En,De}code` doesn't allow for two
integers to be serialized next to each other. This switches the
protocol to serializing `Span`s as a struct. rbml structs don't
have any overhead, so the metadata shouldn't increase in size,
but it allows the json format to be properly generated, albeit
slightly more heavy than when it was just serializing a span as
a u64.
Closesrust-lang#31025.
smichaelwoerister
commented
Jan 20, 2016
r=me if you fix those two errors. |
erickt
commented
Jan 20, 2016
Thanks @michaelwoerister! |
michaelwoerister
commented
Jan 21, 2016
@bors: r+ |
bors
commented
Jan 21, 2016
📌 Commit 1dc7eb8 has been approved by |
bors
commented
Jan 21, 2016
The protocol for `serialize::{En,De}code` doesn't allow for two integers to be serialized next to each other.
Closes#31025.
cc @michaelwoerister
The protocol for
serialize::{En,De}codedoesn't allow for two integers to be serialized next to each other.Closes#31025.
cc @michaelwoerister