Better HN
topnewbestaskshowjobs
Log inSign up

dev_dwarf

9 karma · joined Aug 13, 2023 (3y ago) · 11 submissions

trying to get better..
Submissions

comment 3y ago · link · parent

You'll find by looking at their older posts that the author has actually written quite a lot of elisp.

comment 3y ago · link · parent

Your second paragraph doesn't make sense because the whole point of this type of allocation is to guarantee that you will reuse the same address space you just freed.

comment 3y ago · link · parent

Thats an interesting idea. I'm not sure I'm sold on it v.s. just having two seperate allocators and growing them seperately. The arena allocators I use take advantage of virtual memory to grow which might change my perception of the tradeoffs involved, as I wouldn't typically need to resize one of my allocators (you can just aggressively over-reserve memory and then only commit what is actually used).

comment 3y ago · link · parent

For the alignment parameter I agree.

comment 3y ago · link · parent

Agreed. The question really is if you should demand the user to enforce that constraint on the size they pass to you, or if the function itself should signal an error in that case.

comment 3y ago · link · parent

Nice. Seems to work for case you mentioned under my comment: https://godbolt.org/z/TYorcd8b6

comment 3y ago · link · parent

Interesting point. I modified my example to test what you described. I had to play with the compilation flags to get the allocs to not be optimized out and to not panic when the integer overflow happens, but otherwise I didn't change the logic. I'm pretty sure my implementation is correctly handling the case you mention, evidenced by it returning a null pointer.

Link: https://godbolt.org/z/f1jGW6Pa3

Update: NVM, definitely not being handled correctly. https://godbolt.org/z/cMTe1o979

comment 3y ago · link · parent

Ok, I get it now. It would add an extra ptr to the struct, but wouldn't be significant overhead.

I do wonder what benefit there is for you over just having two separate allocators, one for long term and one for short term. I imagine there could be benefits in very memory constrained scenarios.

comment 3y ago · link · parent

This sounds like it would make the alloc logic much more complicated and branch-y, defeating the purpose of bumping down anyway, unless your implying some compile-time way to do this.

comment 3y ago · link · parent

In the "bump up" version you could remove both the checked_add branches and replace them with a single check at the end, making the amount of branches the same.

Quick example: https://godbolt.org/z/rdv4qnrs8.

*edited to update the example, realized I messed up the comparison logic.