libuv: uv_get_constrained_memory does not seem to work? (checked under cgroup2)
- Version: 1.29.1
- Platform:
Linux yoga 5.1.5-arch1-2-ARCH #1 SMP PREEMPT Mon May 27 03:37:39 UTC 2019 x86_64 GNU/Linux
Running on Node.js master (libuv 1.29.1).
uv_get_constrained_memory() does not seem to work, it returns 0 when there was a limit set via cgroups.
To clarify — this does not work under unified cgroup hierarchy, i.e. when /sys/fs/cgroup has been mounted with type=cgroup2.
I do not know if this works under legacy or hybrid hierarchies (I have not tested those), but those two are deprecated and upstream is migrating off them. And they don’t allow controlling resource limits from user, that requires root access.
To test:
- Boot the system with
systemd.unified_cgroup_hierarchy=1option - Run node (from user) with
systemd-run --user --scope --property=MemoryMax=100M ./node - Observe the return value of
uv_get_constrained_memory(), which is 0. It shouldn’t be zero. E.g.,Buffer.alloc(100e6).fill(0),0fails.
Refs:
- https://github.com/libuv/libuv/pull/2289
- https://github.com/nodejs/node/pull/27508
- https://github.com/nodejs/node/pull/27805
- https://github.com/systemd/systemd/blob/master/docs/CGROUP_DELEGATION.md#three-different-tree-setups-
- https://fedoraproject.org/wiki/Changes/CGroupsV2
/cc @kjin @evanlucas
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 20 (10 by maintainers)
Commits related to this issue
- linux: teach uv_get_constrained_memory() cgroupsv2 Fixes: https://github.com/libuv/libuv/issues/2315 — committed to bnoordhuis/libuv by bnoordhuis 2 years ago
- linux: teach uv_get_constrained_memory() cgroupsv2 Fixes: https://github.com/libuv/libuv/issues/2315 — committed to JuliaLang/libuv by bnoordhuis 2 years ago
- linux: teach uv_get_constrained_memory() cgroupsv2 Fixes: https://github.com/libuv/libuv/issues/2315 — committed to JuliaLang/libuv by bnoordhuis 2 years ago
- linux: teach uv_get_constrained_memory() cgroupsv2 Fixes: https://github.com/libuv/libuv/issues/2315 — committed to bnoordhuis/libuv by bnoordhuis 2 years ago
- linux: teach uv_get_constrained_memory() cgroupsv2 Fixes: https://github.com/libuv/libuv/issues/2315 — committed to bnoordhuis/libuv by bnoordhuis 2 years ago
- linux: teach uv_get_constrained_memory() cgroupsv2 Fixes: https://github.com/libuv/libuv/issues/2315 — committed to JuliaLang/libuv by bnoordhuis 2 years ago
- linux: teach uv_get_constrained_memory() cgroupsv2 (#3744) Fixes: https://github.com/libuv/libuv/issues/2315 — committed to libuv/libuv by bnoordhuis 2 years ago
I am not exactly sure what uv_get_constrained_memory should report on v2, but my guess would be that it should be the minimum of those two (if not
"max")? What do you think?