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
Remove internal Cstruct.t #65
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great if this library actually had any tests :D
A notable change is RExec.Client_flow
uses bytes and is now even further away from Mirage_flow.S
. However, the signature did not match Mirage_flow.S
already so it's perhaps not a big loss. I recall qrexec being somewhat difficult to expose as a Mirage_flow.S
as it is really two in-channels (stdout and stderr) and one out-channel (stdin) plus the possibility of EOF with and without exit code.
As you note there could be done less copying. Some of the functions could also take string over bytes. I'm fine with doing that in another PR.
I think we would need cstruct (or bigarray) at the edge due to xen/vchan details - but that's maybe okay. It seems we already copy cstructs around.
I have not done a thorough review and just skimmed some parts.
Did you do any tests to see if there's any difference in performance or memory usage?
Indeed a test suite would be great but I'm not sure to be able to write that :( So far the only tests I've done are based on qubes-mirage-firewall usage and I didn't saw drop in performance (here the interface usage is quite limited and qubes-mirage-firewall bottleneck is more with Xen buffers for net packets than communication from/to using rExec, gUI, od dB).
becomes:
Here I suspect 0B, 4B and 8B to be some About the cstruct I've kept it for the |
And thanks for the comments :) And a last note is to me, even if there is no memory nor bandwidth improvement, it would help regarding the GC job as |
Hmm, maybe ohex should in pp if the data is < 16 bytes not emit any newlines, and no addresses and no byte representation? |
So with the last commit I now have only Strings and less copies. let of_int32_le i =
assert(i < Int32.max_int);
let i = Int32.to_int i in
String.init 4 (fun p -> Char.chr ((i lsr (p*8)) land 0xff)) There is probably something better to create strings as 4B from a int32? About |
Oh :( A second point is now I have in |
Oh :( String.get_int32_le only exists since 4.13. I'm not sure what's the
best move bump lower to 4.13 (this is what I'd do but so far it was 4.06,
the step is to big?) / stick with the Bytes / any intermediate solution?
You can use `Bytes.get_int32_le` with `Bytes.unsafe_of_string` as an
intermediate solution.
… |
Co-authored-by: Hannes Menhert <hannes@mehnert.org>
Co-authored-by: Reynir Björnsson <reynir@reynir.dk>
So far I think it's ready for review. EDIT: The original code used The remaining thing I worried about it the last Using small strings in |
I appreciate this work, and would like to spend some time reviewing it. About the ocaml-vchan "move to string" line of work -- this is best done as a separate step since it is quite involved. I suggest to review & merge this first (and cut a release), and once we're cstruct-free in mirage-flow etc., we can adapt the remaining occurences here. |
I took the liberty to cleanup whitespaces, rename String.t to string, and remove Lwt.fail_with usage. IMHO fine to merge & release. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏾
Thank you for your review and the modifications! |
CHANGES: - Remove internal Cstruct.t (mirage/mirage-qubes#65, @reynir @hannesm @palainp)
CHANGES: - Remove internal Cstruct.t (mirage/mirage-qubes#65, @reynir @hannesm @palainp) - Add lower bound for Lwt to 5.7.0
Dear devs,
This PR wants to remove most of the
Cstruct.t
uses (the remaining is kept for ocaml-vchan and probably it can be difficult to change the API as it uses io-pages with Xen, but there is some ppx_cstruct that couldn't be changed anyway).So as this was one of the first un-ppx_cstruct-ion for me, there is probably a lot of improvement to be done (
I have a lot of).Bytes.t
/String
conversion, andBytes.blit
that might be unwanted copies...) + I still have some missingCstruct.hexdump
-like that would be great to print out (those are limited togUI.ml
but qubes-mirage-firewall, that I use for testing the PR, doesn't usegUI.ml
at allAny review / comments are welcome :)
Best,