Skip to content

Switch to FixedCapacityVec from crates.io

Ian Jackson requested to merge Diziet/arti:fixed-capacity-vec into main

This MR switches to the new separate fixed-capacity-vec crate.

Benchmark results

While working on tidying that up, I noticed that I had accidentally omitted the memory allocation failure check: the GlobalAlloc trait's alloc method can return a null pointer, so this is true of std::alloc::alloc. That seems to involve a 0.4% penalty in instruction count, which was disappointing. However, (i) I was able to claw much of that back and (ii) also weirdly, now, changing NonNull::new to NonNull::new_unchecked doesn't improve matters significantly?

I tried diffing the results of rustc --bench hashx_bench -- --emit asm but I found interpreting the results very difficult. In particular, this change, which I made as a canary:

-                    NonNull::new(data).unwrap_or_else(|| handle_alloc_error(Self::LAYOUT));
+                    NonNull::new_unchecked(data);

changed the iai results but not the results of --emit asm.

I'm hoping you will have some idea what's going on and tell me what I should do next.

Crate status, and code review

Currently I have published 0.1.0, and that's what this MR uses. I'm not sure how you want to approach the review of what's there now. It certainly ought to have someone else look it over.

I would also like to cargo owner add but I probably ought to get you to tell me whether you're happy with the crate contents first. (And I would need to know your github username, since that's what crates.io hangs its authorisation off.)

Merge request reports