vorner / bumpalo-herd

Trying to create Sync bump allocator
Apache License 2.0
26 stars 4 forks source link

Couple of ideas #13

Open AndreiPashkin opened 2 days ago

AndreiPashkin commented 2 days ago

First of all I'd like to say that it is a great crate and it is very relevant to my work.

While working with it I came a cross of several ideas, not sure if @vorner would find them adequate:

  1. Add get_by_id() method which would allow to get a Bump attached to some kind of resource - a thread for example. Members acquired in such a way would not be shared between different resources - only within one resource designated by some kind of user-provided ID (thread ID, worker ID, coroutine ID, whatever).
  2. Add reset_unsafe() method so that if user could reset an individual member if he really knows what he's doing. That is supposed to play together with the above method.
vorner commented 1 day ago

Hello

I probably don't understand your use case, or what the advantage is. And it looks like it would increasing the complexity of the API, which I'm reluctant to do without a good reason.

Can you explain more?

AndreiPashkin commented 1 day ago

@vorner, my use case is that I'm building a small component that is supposed to fetch data from the datastore, quickly process it and pass down the pipeline and eventually to the network. And I want the memory of the output data (which is immutable) to stay the same after my component returns until the same thread doesn't get a new task - so that the processing pipeline could work with the data returned by my component and it won't suddenly change. This is to avoid re-allocation.

AndreiPashkin commented 1 day ago

@vorner, I'm also a bit puzzled with how to deal with bumpalo::collections - they expect bumpalo::Bump for their allocation, but that makes lifetime extension magic in bumpalo_herd::Member not work. And therefore lifetime of bumpalo::collections becomes tied to bumpalo_herd::Member instance's lifetime instead of bumpalo_herd::Herd - I wonder if you could say if I'm doing something wrong here?