-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add minimal_memory_lock package #1
Conversation
9a2775c
to
26e92b2
Compare
FYI @shuhaowu @razr @christophebedard @LanderU @JanStaschulat I created a first PR with the memory lock example. Could you take a look and provide some feedback? Thanks. |
Just as a note, I have my memory locking example in my demo app: https://github.com/shuhaowu/rt-demo/blob/b33a8be/libs/rt/src/app.cc#L15-L16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks mostly good, but two main comment:
- Probably should use
RUSAGE_THREAD
instead ofRUSAGE_SELF
to avoid the need for the--sleep
. - I would consider just calling mlockall all the time and not be able to turn it off. It seems to me that any RT thread should always mlockall and configure malloc. Having an option to turn it off may make it confusing for people who want to implement this in their program, as they won't know when and why they should turn off
configure_memory_behavior
(which is never?). This also removes the need tomemset
during memory reservation.
|
||
print_process_memory("Process memory before spin: "); | ||
print_page_faults("Total page faults before spin"); | ||
get_new_page_faults(); // init page fault count |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this function called and the return value not consumed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just to initialize the static members from the functions. Since this is not obvious I will change this. I can create a MemoryPageFaultCount
class with reset and get functions to make this cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nitpick: Is it needed to store the pagefault as a state? I just store the page fault count in local variable (A) at one point in the code, do some stuff, and then get the counts again in another local variable (B). I then subtract B - A. Like https://github.com/shuhaowu/rt-demo/blob/7116d52/docs/prefault-experiments/prefault-test.cc#L80
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm checking the page faults inside the node callback so I need to save them either as part of the Node class or somewhere else. I started using the same approach as the rt wiki, so this is why I was using storing them inside the function itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah maybe what you have is fine. Maybe add a comment to call out the fact that you're initialization?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will create a class so it's easier to understand.
Sorry this PR review dragged out to 30 comments, didn't intend it to be like that 😅 .. That said, I want to pull this comment out of that thread to keep things a bit more clear (if that's possible):
In this other comment, you mentioned that if RT is needed for the DDS thread, then you need a sleep (which is kind of a bug from RMW..). There are some commonalities here: I think we should figure out who the target audience for this code is. Right now it feels like code that proves that memory locking is working (almost like unit-tests). Maybe, we should target RT app developers instead who are probably more interested in a "sample app framework" for ROS? Something with all the scheduling and memory setup. We can still put some logging about page faults, as that could be the "sample application code", if that makes sense. This way you don't need any of the options. We can quickly document all the things in the README. I also have a blogpost coming that explains all these options in hopefully a week. The "sample app approach" is also what my repo is trying to do for non-ROS apps. |
f9fe960
to
0073bc3
Compare
@shuhaowu @LanderU I updated the example. These are the main changes:
|
Signed-off-by: Carlos San Vicente <[email protected]>
0073bc3
to
d2e080f
Compare
d2e080f
to
d72751f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working this through!
@shuhaowu Thanks a lot for the review. I added some asciicenema recordings to show what the output looks like. It provides a nice visualization in github pages. See the result here: https://ros-realtime.github.io/ros2-realtime-examples/minimal_memory_lock/ |
f157096
to
3c1851e
Compare
No description provided.