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.
Currently, looking up an item in the slab requires dereferencing three to four
Box
es: the box around the shard slice: https://github.com/hawkw/sharded-slab/blob/b16043361ef5cb74750b69f91f9dace15a40ee60/src/lib.rs#L202 the box around the page data slice (or slices, depending on the operation): https://github.com/hawkw/sharded-slab/blob/b16043361ef5cb74750b69f91f9dace15a40ee60/src/lib.rs#L244-L249 and the box around each page's slot slice: https://github.com/hawkw/sharded-slab/blob/b16043361ef5cb74750b69f91f9dace15a40ee60/src/page/mod.rs#L73It 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.