Custom thread pool support
Vladimir Ogorodnikov
vog at activeviam.com
Tue Jun 7 09:52:44 UTC 2022
Hello,
My name is Vladimir Ogorodnikov, I am an R&D intern at ActiveViam. In my
internship, I explore the possibilities of the Loom project.
One of the tasks I solve is NUMA (Non-Uniform Memory Access) support. The
essence of this architecture is that each processor has its own block of
memory (processors and memory blocks connected to each other are called
NUMA nodes). If the application is organized in such a way that each
processor works with its own part of the data, then the performance grows
by a multiple of the number of processors (or memory blocks). Processors
can also access remote memory blocks, but this requires additional time
spent on data transfer.
An important part of NUMA support is the ability to specify for each thread
which processors it can run on. To do this (on Linux) one need to make a
native call to numa_run_on_node(). On other OSes, the procedure may be
different. This cannot be done from the code of a virtual thread: firstly,
virtual threads are invisible for the OS, and this call will change the
properties of the carrier thread, and secondly, the virtual thread can be
moved to another carrier thread at any time.
Thus, full support for NUMA requires the ability to create several
different pools of carrier threads with the ability to configure them. This
is not possible in the current version of the API. I prepared a demo
project in which the required functionality is implemented using reflection
and changing the visibility of methods. In addition, I prepared a virtual
machine image for QEMU on which you can run this project. The project is
available on GitHub:
https://github.com/activeviam/NumaAwareVirtualThreadsDemo. The files are
available at:
https://drive.google.com/drive/folders/1v7xn8NEELfzR9TCn5hrV52n03hfOHeAh?usp=sharing
.
I would like to ask if there are any plans to add support for this
functionality in Loom, and if my code breaks any internal invariants
related to virtual threads. Thanks in advance.
Sincerely,
Vladimir Ogorodnikov
*R&D Intern*
[image: Mobile] 0778300738 [image: ActiveViam]
<https://www.activeviam.com/>
[image: Linkedin] <https://www.linkedin.com/company/activeviam/> [image:
YouTube] <https://www.youtube.com/c/ActiveViam/videos> [image: Blog]
<https://www.activeviam.com/blog/> [image: Twitter]
<https://twitter.com/activeviam>
46 rue de l'Arbre Sec, 75001 Paris
<https://maps.google.com/?q=46+rue+de+l+Arbre+Sec,+75001+Paris,+France>
www.activeviam.com
More information about the loom-dev
mailing list