-
Notifications
You must be signed in to change notification settings - Fork 177
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
Inefficient Lwt_io.NumberIO implementations (int32, int64, float read/write). #178
Comments
This issue is about basically throwing away the current Lwt now requires 4.02.0 (soon 4.02.3), so we don't have to worry about adding compatibility fallbacks. For each reading function, we want to wait until the channel buffer has enough bytes for the kind of number we are trying to read. We then want to apply the fast primitive to extract that number. For writing, we want to apply a primitive to write a number to the buffer, ideally without copying (not converting it into an intermediate buffer first). The Here's an example, from the compiler's test suite, of how to bind the bytes/number conversion primitives: https://github.com/ocaml/ocaml/blob/70d880a41a82aae1ebd428fd38100e8467f8535a/testsuite/tests/prim-bigstring/bigstring_access.ml#L5-L17 The same, for byte swaps: https://github.com/ocaml/ocaml/blob/70d880a41a82aae1ebd428fd38100e8467f8535a/testsuite/tests/prim-bswap/bswap.ml#L3-L5 And a link to ocplib-endian. I used the source of this library to help find the names of the primitives, etc. |
This is a pretty self-contained and relatively straightforward issue, but I marked it medium because it involves dealing with:
Ideally, one would also write a performance comparison (using |
4.01 introduced primitives for reading/writing such values efficiently.
ocplib-endian builds on them while providing fallback code for older compilers. Lwt_io could easily build on it, getting rid of ~100 LoCs and improving speed.
The text was updated successfully, but these errors were encountered: