capnproto-rust icon indicating copy to clipboard operation
capnproto-rust copied to clipboard

Move to standard Allocator interface?

Open aneeshusa opened this issue 9 years ago • 3 comments

The Rust team yesterday accepted this RFC on a standard Allocator interface. It hasn't been implemented yet, but I was taking a look and it seems like it would cover the needs of the current Allocator trait in capnproto-rust - we can use the Layout struct to provide the same size + alignment properties that Word currently has.

When this becomes implemented in the stdlib, would you be interested in using it instead of/to back the current Allocator scheme in this crate? I'd be interested in working on a PR for this in the future.

aneeshusa avatar Apr 10 '16 00:04 aneeshusa

Cool! Thanks for bringing this to my attention. It does sound like it would be a good idea to try to use the stdlib Allocator once it exists. Your contribution would be welcome. Let me know if you hit any trouble along the way.

dwrensha avatar Apr 10 '16 00:04 dwrensha

I suppose this might simplify doing things like garbage collecting a message after making changes.

burdges avatar Apr 10 '16 09:04 burdges

@burdges: As far as I understand, I don't think so. I imagine the stdlib allocator trait would be a replacement for capnp::message::Allocator, which handles allocation of entire segments. Within individual segments we carry out a form of arena allocation that needs to do a fair amount of capnproto-specific bookkeeping; I doubt we would be able to take advantage of a stdlib allocator trait there.

dwrensha avatar Apr 10 '16 11:04 dwrensha