DataDog / glommio

Glommio is a thread-per-core crate that makes writing highly parallel asynchronous applications in a thread-per-core architecture easier for rustaceans.
Other
3.06k stars 162 forks source link

Question: Why "at least 512 KiB of locked memory"? #606

Open dezyh opened 1 year ago

dezyh commented 1 year ago

Why is the following limit a requirement?

Please also note Glommio requires at least 512 KiB of locked memory for io_uring to work. You can increase the memlock resource limit (rlimit) as follows:

$ vi /etc/security/limits.conf
*    hard    memlock        512
*    soft    memlock        512

Please note that 512 KiB is the minimum needed to spawn a single executor. Spawning multiple executors may require you to raise the limit accordingly.

To make the new limits effective, you need to log in to the machine again. You can verify that the limits are updated by running the following:

$ ulimit -l
512

To add some context, a coworker of mine vendored and apparently reduced this limit to "at least 64/128 KiB" (I forgot which sorry) and it's now able to run on our GKE nodes, which by default have less than the required 512 KiB memlock configured.

While everything seems to work for now, I'm worried that this is something which could break glommio in a non-obvious way and introduce unintended and potentially hard to debug issues/side-effects in the future.

glommer commented 1 year ago

This is the amount of memory that is required for io_uring to allocate its internal data structures.

Was the executor created using standard configuration? If the default ring size was reduced, this could explain why it was created with less memory.

There should be no problems in this case, except potentially for performance ones. If there is not enough locked memory at startup, io_uring will fail to allocate and bail. If the executor was allocated, things should work.