-
Notifications
You must be signed in to change notification settings - Fork 295
Add Memory Usage Tracker For Programs and Update Tests #173
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
Draft
Abhinav-Prajapati
wants to merge
8
commits into
kalviumcommunity:main
Choose a base branch
from
Abhinav-Prajapati:feat/track-memory
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ec7316a
feat: add memory monitoring during code execution
Abhinav-Prajapati b4d06f8
feat: add approximate memory usage to test cases
Abhinav-Prajapati 6989d89
feat: add memory usage validation with tolerance to test cases
Abhinav-Prajapati 0a86224
chore: update changelog for v0.4.3 with memory uses tracker addition
Abhinav-Prajapati 116c4e5
refactor: format code snippets in testJson.js for improved readability
Abhinav-Prajapati d311efa
add documentation comparing memory usage measurement methods: Valgrin…
Abhinav-Prajapati ccf12bf
fix: update command to use -f flag in time to get memory usage directly
Abhinav-Prajapati b3568dc
refactor test cases
Abhinav-Prajapati File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,10 @@ | ||
| ## Changelog | ||
|
|
||
| ### v0.4.3 | ||
|
|
||
| #### Improved | ||
| Added memory uses tracker | ||
|
|
||
| ### v0.4.2 | ||
|
|
||
| #### Improved | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # Memory Usage Measurement: `valgrind` vs `/usr/bin/time` | ||
|
|
||
| ## Overview | ||
|
|
||
| This document compares two common methods: **Valgrind (Massif)** and **`/usr/bin/time`**, highlighting their strengths and limitations. | ||
|
|
||
| ## Comparison Table | ||
|
|
||
| | Feature | Valgrind (Massif) | `/usr/bin/time` | | ||
| | --------------------- | -------------------- | --------------------- | | ||
| | Heap Memory Tracking | ✅ Yes | ✅ Yes | | ||
| | Stack Memory Tracking | ⚠️ Incomplete | ✅ Yes | | ||
| | Standard Tool | ❌ No (needs install) | ✅ Yes (pre-installed) | | ||
| | Ease of Use | Moderate | Easy | | ||
| | Output Integration | Complex | Simple (shell output) | | ||
|
|
||
| --- | ||
|
|
||
| ## Use Case Analysis | ||
|
|
||
| ### Using Valgrind: | ||
|
|
||
| **Variables Used / Memory Used:** | ||
|
|
||
| * Method: `valgrind` | ||
| * Stack: 5 MB | ||
| * Heap: 30 MB | ||
|
|
||
| **Estimated Usage:** \~31 MB | ||
| **Expected Usage:** \~35 MB | ||
|
|
||
| > Observation: Underestimates stack usage due to limited stack tracking capabilities. | ||
|
|
||
| --- | ||
|
|
||
| ### Using `/usr/bin/time`: | ||
|
|
||
| **Variables Used / Memory Used:** | ||
|
|
||
| * Method: `/usr/bin/time` | ||
| * Stack: 5 MB | ||
| * Heap: 30 MB | ||
|
|
||
| **Estimated Usage:** \~36.5 MB | ||
| **Expected Usage:** \~35 MB | ||
|
|
||
| > Observation: Much closer to actual usage. Accurately reflects both stack and heap usage. | ||
|
|
||
| --- | ||
|
|
||
| ## Conclusion | ||
|
|
||
| * Use **`/usr/bin/time`** for **accurate total memory measurement**, especially when stack usage is involved. | ||
| * Use **Valgrind (Massif)** when you need **detailed heap allocation breakdowns**, such as per function or call stack. | ||
|
|
||
| > **Recommendation**: For a code judging system where total memory consumption matters more than internal profiling, prefer `/usr/bin/time`. | ||
|
|
||
| --- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 comment suggests dividing the memory usage by 4 if running on Alpine. However,
/usr/bin/time -f "%M"is documented to report the maximum resident set size in Kilobytes on Linux systems. Dividing by 4 implies the output is in 4KB pages, which is not the standard behavior of%M. Relying on this division is fragile and could lead to incorrect memory reporting if the execution environment changes or if/usr/bin/timebehaves as documented (reporting in KB). It's best to remove this division unless there's a specific, confirmed reason for it on the target platform that overrides the standard documentation.