Skip to content
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

Reduce pointer indirections #14

Open
hawkw opened this issue Dec 8, 2019 · 0 comments
Open

Reduce pointer indirections #14

hawkw opened this issue Dec 8, 2019 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@hawkw
Copy link
Owner

hawkw commented Dec 8, 2019

Currently, looking up an item in the slab requires dereferencing three to four Boxes: the box around the shard slice:

shards: Box<[Shard<T, C>]>,

the box around the page data slice (or slices, depending on the operation):

sharded-slab/src/lib.rs

Lines 244 to 249 in b160433

local: Box<[page::Local]>,
/// The shared state for each page in this shard.
///
/// This consists of the page's metadata (size, previous size), remote free
/// list, and a pointer to the actual array backing that page.
shared: Box<[page::Shared<T, C>]>,

and the box around each page's slot slice:
type Slots<T, C> = Box<[Slot<T, C>]>;

It would be good to reduce the number of dereferences. Ideally, we could use fixed size arrays, since the slab is configured at compile time; however, doing this nicely would require const generics. Alternatively, we could consider using DSTs for at least some of our structs. However, this would require manually managing our allocations, and would still require some boxing — it would take careful design to actually reduce derefs with DSTs.

Since a slab is (almost) always in an Arc in most use-cases, we might want to make the entire slab a DST, reducing at least one box...this could have ergonomic disadvantages though.

@hawkw hawkw added the enhancement New feature or request label Dec 8, 2019
@hawkw hawkw self-assigned this Dec 8, 2019
@hawkw hawkw added this to the Nebulous Future milestone Mar 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant