Sexp conversions: ignore extra bytes#44
Conversation
|
Does this remove the dependency to camlp4? if yes, that's nice and it would be good to update |
|
Hmmm. I don't think it does.
Undecided if dropping |
|
Is any use of this performance sensitive? The to/from Bigarray operations are slow, but this is convenient and so bearable from my perspective... |
|
I'm not sure why we expose |
|
in TLS we use our own |
|
To be clear, I think this PR is a very good idea as well. |
|
Aaaaand before noticing @avsm's spot-on objection, I re-did the code to avoid Obviously, great minds think alike. I think this is as fast as it can get. Converting buffers into strings (and then those strings into buffers if the network is involved) isn't the fastest way to transfer a large sequence of bytes somewhere, but it comes in handy in |
* avoids `Array1.sub` * our blits are much faster
|
this is tested in production -- running on the pinata :) and #45 would be nice to have merged as well! |
Sexp conversions: ignore extra bytes
|
test case for this please |
The current sexp conversions marshal the entire structure, including the full underlying buffer.
This is desirable if
Cstruct.tis understood as achar bigarraywith a handy offset and a limit. If it's understood as a view into the underlying array, then its meaning are exactly the bytes in the array betweenoffsetandoffset + length. Marshaling the entire array then leaks the details on how the view was originally obtained.I would argue that since it's impossible to expand a cstruct, the latter is a better description of what cstructs are. Bytes beyond the stored range are not accessible through the functions in
Cstruct, and should not be serialized either. If this is desired, one can easily store the buffer directly, as the type is not opaque.This bit me when I tried to remove the custom
from/to_sexproutines from tls and use the ones here; we end up storing large amounts of data, as various bits of internal state are cut-up slices of larger buffers.