-
Notifications
You must be signed in to change notification settings - Fork 940
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
lxd-agent: Added RSS metrics + Simplified calculation for better scalability #15094
base: main
Are you sure you want to change the base?
Conversation
d22d255
to
dd0e072
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.
I only took a quick/cursory look at the code (not the tests) but it looks good to me. Thanks for including tests BTW, I'm looking forward to reviewing them!
Would you mind slicing you changes into multiple commits (one per file changed should do) like you had in the earlier PR you closed. BTW, you can force push to an existing PR to bring it into shape, no need to create fresh ones.
Please can you sign your commits and the CLA. |
I went to the website and signed it. Thank you. |
95d1ec9
to
308b8ae
Compare
Sorry for all the Git confusion. I've been wrestling with my Git setup lately and clearly still need to work out some kinks. Thank you for your patience with the commit signing and DCO issues. |
50e0285
to
36dbcf0
Compare
Please can you sign your commits. |
ec33b0f
to
b25ee40
Compare
I am trying to sign off my commits using git push --force-with-lease origin lxd-agent-metrics-add-rss-clean but it still does not seem to pass the DCO. Should I squash my commits and try again? |
The DCO check if failing due to a mismatch in your declared name ("Martin" vs "MrMartyK"):
|
b25ee40
to
4b98e96
Compare
That fixed it, thank you so much. I appreciate it. Should I squash all this? |
Looks like this was forgotten about or undone in some rebase. I know, git isn't intuitive :/ |
defa921
to
3ef7782
Compare
Yea I apologize for that. At my job its a whole proprietary way of doing things + I am running on a new system here so git is being annoying. I am more of a GUI git user (a sin I know) I am trying to use git through terminal for the first time in ages and it has been a pain. I am getting setup wth gitkraken right now. |
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.
The commit slicing is still not 100% there. Your last commit also has duplicated Signed-off-by
.
If that makes it easier for you, feel free to drop the Co-authored-by
tag. It's nice of you but that's the script is your own work ;)
I don't mind putting the Co-authored-by tag. If it wasn't for you catching the grep and awk filtering I wouldn't have seen it. I learned a new thing today which is great. |
3ef7782
to
62cd157
Compare
I don't know how it works with GUI but on the CLI, you can You will be left in your repo after the commit to |
62cd157
to
de7d956
Compare
Yea I just went through cherry picking and rebasing. This should be better now. Three separate commits for the initial implementation: Then Four refinement commits in sequence: |
Indeed, much better slicing now.
By convention, we require fixup commits like that be "folded" into their respective initial commit. So this PR should just have 3 commits, one per file. |
I could do that as well. I could put fixup/improvement commits into their initial commits. |
8f55098
to
d816542
Compare
@MrMartyK could you please rebase ( The |
This implements proper RSS memory metric calculation in lxd-agent using kernel memory accounting. The solution provides O(1) complexity with accuracy matching standard system tools. - Added efficient RSS calculation using the formula: RSS = MemTotal - (MemFree + Buffers + Cached - Shmem) - Added validation for required /proc/meminfo fields Signed-off-by: MrMartyK <martykareem@outlook.com>
d816542
to
059ffac
Compare
Sorry for the late reply. Busy work day, a lot of code reviews. I've rebased the branch onto the latest main and force-pushed the changes. This should fix the golangci-lint errors from the CI checks. |
I ran all the necessary formatting checks to ensure everything is clean and consistent. No issues detected:
Everything looks good, pushing it now! |
059ffac
to
c3428e9
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.
The Co-authored-by
flag if you keep it should be put right before your Signed-off-by
line otherwise GitHub doesn't recognize it as such.
As stated previously, I'm fine with your dropping it ;)
No worries and thanks for your persistence, that's really appreciated! |
Add comprehensive unit tests for the RSS memory calculation, including: - Test for correct formula implementation - Test for handling missing fields in /proc/meminfo - Validation of calculation against expected values Signed-off-by: MrMartyK <martykareem@outlook.com>
Add a validation script for RSS calculation that: - Compares RSS calculation with free command output - Uses awk with proper regex anchors for accurate parsing - Provides detailed calculation breakdown for debugging - Validates results are within 5% of standard tools Co-authored-by: Simon Deziel <simon.deziel@canonical.com> Signed-off-by: MrMartyK <martykareem@outlook.com>
c3428e9
to
a126598
Compare
I just fixed that, thank you for pointing that out. I made sure you show up. |
Previous PR Notice: I initially submitted this fix in #15093 but discovered after submission that my Git commit signatures weren't properly configured, causing CLA validation failures. This new PR contains:
Apologies for the earlier misconfiguration - this version passes all contribution checks.
Summary
This PR resolves the "FIXME: Missing RSS" comment in
metrics.go
by implementing proper RSS memory metric calculation in lxd-agent using kernel memory accounting. The solution provides O(1) complexity with accuracy matching standard system tools.Context
The original FIXME existed because:
Key realization:
/proc/meminfo
contains all required fields for system-wide RSS calculation without needing process enumeration.Changes
/proc/meminfo
fieldsPerformance
Testing
free -m
within 1%Benefits
Impact
This is my first contribution to the LXD project, implementing enhanced RSS metrics. As this is my initial PR, I am very open to feedback and committed to making any necessary adjustments to align with project guidelines.
Please do not hesitate to let me know if you require any further information before considering this for merge. To keep this initial PR focused, I have not included all the detailed testing scripts and container configurations I used, but I have these readily available and can provide them if they would be helpful for review. I have provided the metrics_test.go and the test_rss_calculation.sh, let me know if you want more. Thank you again.