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

bsalloc: improve cache #171

Closed
wants to merge 4 commits into from
Closed

bsalloc: improve cache #171

wants to merge 4 commits into from

Conversation

teg
Copy link

@teg teg commented Mar 12, 2018

I noticed some minor things as I'm looking through the code.

@joshlf
Copy link
Collaborator

joshlf commented Mar 12, 2018

Hi @teg, thanks for the PR!

@ezrosent and I are pretty busy right now, so we probably won't be able to get to this for a bit, but we really appreciate the PR! In the meantime, if you're interested in contributing beyond this PR, feel free to check out the issues and let me know if you have any questions about anything.

@teg
Copy link
Author

teg commented Mar 12, 2018

Thanks @joshlf! Do you have a preferred communication channel for general questions? For now I thought I'd just file some PRs for stuff I notice as I try to wrap my head around the code, but take your time reviewing it.

teg added 3 commits March 12, 2018 18:10
The underlying MapAlloc allocator will round up the allocation
(to the nearest page), but the cache was only servicing requests
smaller than the allocation that was requested, rather than the
allocation actually given.

Use `usable_size()` to use the allocated size, rather than the
requested size. In practice (at least on Linux), this changes
small objects from 1k to 4k, and leaves the size of large objects
unchanged.
rng() is a multiple of the alignment of `usize` (in particular of the
memory address of an `usize`). When taking this modulo 4 (and 8, on
64 bit), the result is always 0. This means that at most two entries
in the caches are utilized.

Divide the output by the alignment of `usize`, which preserves the
overall entropy, but moves it into the lower bits (which are the ones
that are used).
Further to the previous patch, the address taken as `seed`, is a
fixed offset from the stack frame alignment. On OSX this is fixed
to 16 bytes, and on other systems 16 bytes is the default.

Divide `seed` by 16, rather than simply the alignment of `usize`.
As before, this does not reduce the overall entropy (assuming default
stack-frame alignment), but moves more entropy into the lower bits.
@joshlf
Copy link
Collaborator

joshlf commented Mar 12, 2018

Comments on issues/PRs are fine, and email works fine too (hello@joshlf.com) for longer-form or more open discussion.

@joshlf
Copy link
Collaborator

joshlf commented Mar 18, 2018

Hey, sorry for the delay. The code looks good! If you wouldn't mind squashing the last two commits (the ones about the rng) into one, we'll merge!

@teg
Copy link
Author

teg commented Mar 9, 2020

I won't be working on this.

@teg teg closed this Mar 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants