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

Document of memory_lock #12

Open
2 tasks
Zard-C opened this issue Oct 19, 2023 · 2 comments
Open
2 tasks

Document of memory_lock #12

Zard-C opened this issue Oct 19, 2023 · 2 comments

Comments

@Zard-C
Copy link

Zard-C commented Oct 19, 2023

use lock memory as non-root users (sshd_config: UsePAM yes)

Required Info:

  • Operating System:
    • Ubuntu: focal
  • Installation type:
    • from source
  • Version or commit hash:
    • humble
  • DDS implementation:
    • fastrtps
  • Client library (if applicable):
    • rclcpp

Steps to reproduce issue

Before setting memlock limits:

ulimit -l
65536

Do as

- Adjust permissions for memory locking. Add to `/etc/security/limits.conf`
said to adjust memlock limits.

run minimal_memory_lock with "--allocate-in-node 50 --lock-memory"

Expected behavior

Process memory before node creation:  5 MB
Sleeping here so all the middleware threads are created
Process memory before locking:  20 MB
Process memory locked
Process memory after locking:  106 MB
Process memory before spin:  106 MB
Total page faults before spin [Minor: 22671, Major: 0]
[WARN] [1697725046.436525305] [minimal_publisher]: New page faults during spin: [minor: 12822, major: 0]
[INFO] [1697725046.907732793] [minimal_publisher]: New page faults during spin: [minor: 0, major: 0]
[INFO] [1697725047.407619649] [minimal_publisher]: New page faults during spin: [minor: 0, major: 0]
[INFO] [1697725047.907790732] [minimal_publisher]: New page faults during spin: [minor: 0, major: 0]
[INFO] [1697725048.407655468] [minimal_publisher]: New page faults during spin: [minor: 0, major: 0]
...

Actual behavior

Process memory before node creation:  5 MB
Sleeping here so all the middleware threads are created
Process memory before locking:  20 MB
terminate called after throwing an instance of 'std::runtime_error'
  what():  mlockall failed. Error code Cannot allocate memory
[1]    3244501 abort     

and check the memlock limits with

ulimit -l
65536

It remains unchanged, and it's fewer than --allocate-in-node 50 --lock-memory need. I believe that's the reason why mlockall() failed.

Additional information

Since I was logging with ssh, so there's an additional step to take:

Add to /etc/ssh/sshd_config (as sudo)

UsePAM yes

Then check the limits

ulimit -l       
266144

Then it works!

Feature request

Feature description

  • Maybe we should add the additional step above to README.md for other developers use ssh to login 😄
  • In addition to using stress-ng to evaluate the entire system, we can also use perf to monitor the CPU usage of individual process minimal_memory_lock:
    perf stat -e cpu-clock,context-switches,branches,branch-misses,cache-references,cache-misses,instructions,cycles -D 30 -p $pid
@Zard-C
Copy link
Author

Zard-C commented Oct 19, 2023

CC @christophebedard

@christophebedard
Copy link
Member

This should probably be directed towards @carlossvg instead.

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

2 participants