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

NUMA affinity #29

Open
gz opened this issue Oct 14, 2019 · 8 comments
Open

NUMA affinity #29

gz opened this issue Oct 14, 2019 · 8 comments

Comments

@gz
Copy link

gz commented Oct 14, 2019

Not sure this is the right place to ask, but given the already expansive API in the Alloc trait, would specifying a NUMA affinity for allocations also be something that the API could offer? Or is this out of scope?

@TimDiekmann
Copy link
Member

TimDiekmann commented Oct 14, 2019 via email

@Avi-D-coder
Copy link

@gz
Copy link
Author

gz commented Oct 14, 2019

Sorry for being unspecific with acronyms. I'm talking about non-uniform memory accesses (NUMA).

(Briefly: Server system are often multi-socket machines where the memory access latency is better when a thread on a NUMA node accesses memory that is local to that node)

There are libraries like libnuma that offer the application writer a more explicit interface to control memory allocation by setting the affinity (i.e., which node you want to allocate from) because sometimes default policies like first-touch in Linux may lead to sub-optimal allocations. My question was about if something like this could be part of the Alloc traits too (i.e., as an optional NUMA affinity parameter or separate functions).

@Amanieu
Copy link
Member

Amanieu commented Oct 14, 2019

Is it really necessary to make this part of the AllocRef trait though? If you want to allocate from a specific node in a NUMA-aware allocate, couldn't you just use some sort of builder API to create an AllocRef which only allocates from a particular node?

@gz
Copy link
Author

gz commented Oct 14, 2019

@Amanieu No, I don't think there is anything that prevents to do it the way you describe it. This is just about ergonomics and whether APIs in style of libnuma should be part of the language/Alloc traits.

Please close if this is deemed out of scope.

@gnzlbg
Copy link

gnzlbg commented Oct 15, 2019

@gz I tend to think of the first iteration of the AllocRef trait as something that would be useful for the std::collections and Box and it is unclear to me how these collections would be able to use a more complex allocation API portably.

OTOH what @Amanieu suggests allows you to build your own libnuma crate that you can use to create an alloc handle that you can pas to Vec to allocate however you want, and the advantage is that Vec doesn't need any specific code for this.

If you have a particular API in mind for something that the AllocRef trait should expose on all platforms that Rust supports, maybe you could sketch what those APIs would look like ?

@vertexclique
Copy link
Member

vertexclique commented Nov 8, 2019

Would like to mention that I've worked on NUMA affinity and created a NUMA-based allocator already.
https://github.com/bastion-rs/numanji
On top of that I've did quite a lot of work to organize existing context-allocator crate and fixed some possible unsafe problems in it and released as:
https://github.com/bastion-rs/allocator-suite


Bastion runtime uses these as unstable API but I am going to work on numanji to take various numa settings.

@alexpyattaev
Copy link

NUMA affinity is a must-have on multi-socket server platforms. For a performance-oriented language it is very important to support this. It would enable rust to just outright demolish go on such platforms in memory intensive applications such as databases.

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

No branches or pull requests

7 participants