fitzgen / bumpalo

A fast bump allocation arena for Rust
https://docs.rs/bumpalo
Apache License 2.0
1.34k stars 109 forks source link

Add a quickcheck for growing or shrinking existing allocations #233

Closed fitzgen closed 4 months ago

fitzgen commented 4 months ago

cc @overlookmotel: just an FYI in case you were interested in how I ended up doing this.

overlookmotel commented 4 months ago

I am interested. Thanks for pinging me.

Right, so the actual logic around grow/shrink and alignment had to change a bit, not just the test.

fitzgen commented 4 months ago

That or alternatively the test could have accepted Err(_) in the case where requested new alignment was greater than the old alignment, but I figured I'd loosen things up a little while I was here.

overlookmotel commented 4 months ago

Nice. Yes, I guess no reason to refuse to increase alignment, if the address is already aligned.

Can I ask you one random question that has nothing to do with this issue? (just don't want to open an issue/discussion just for 1 simple question)

Is the reason for filling the buffers backwards (start at the back, and move towards the front) to make alignment calculations more efficient?

fitzgen commented 4 months ago

Is the reason for filling the buffers backwards (start at the back, and move towards the front) to make alignment calculations more efficient?

I wrote a whole blog post about this :)

https://fitzgeraldnick.com/2019/11/01/always-bump-downwards.html

overlookmotel commented 4 months ago

Haha oops! Well I guess that answers my question (in spades). Thank you, will digest.