-
Notifications
You must be signed in to change notification settings - Fork 296
Add Memory Usage Tracker For Programs and Update Tests #174
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
base: main
Are you sure you want to change the base?
Add Memory Usage Tracker For Programs and Update Tests #174
Conversation
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.
Summary of Changes
Hello @Abhinav-Prajapati, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request adds a crucial feature to track and report the memory usage of executed programs using /usr/bin/time. It also enhances the test suite with new memory-specific tests for C and adds memory validation checks for existing language tests, ensuring better monitoring and control over program resource consumption.
Highlights
- Memory Usage Tracking: Implemented memory usage tracking for program executions by leveraging the
/usr/bin/timecommand to capture the maximum resident set size (memory usage) and store it in a temporary file (/tmp/memory_report.txt). This data is then read and included in the API response. - New C Memory Tests: Added two new C test cases specifically designed to validate memory usage: one for allocating and touching 50MB on the heap, and another for recursive stack allocation up to 6MB.
- Memory Validation in Tests: Introduced an
approxMemoryUsesfield in test cases to specify expected memory ranges. The test suite now includes assertions to check the actual memory reported by the service against these expected values within a defined tolerance (20%). - Code Readability: Refactored test case scripts in
testJson.jsto use template literals instead of string concatenation, improving readability and maintainability.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configureGemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
/gemini review |
qodo-free-for-open-source-projects
bot
commented
Jun 16, 2025
•
edited by qodo-code-review
bot
Loading
edited by qodo-code-review
bot
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||
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.
Code Review
This pull request introduces memory tracking for programs using /usr/bin/time and updates test cases to validate memory usage. The changes include integrating memory monitoring into the code execution service, adding new C test cases for heap and stack allocation, and updating test assertions with memory tolerance validation. The code has been improved by converting test scripts to template literals for better readability.
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.
Code Review
This pull request introduces memory tracking for programs and updates tests to validate memory usage. The changes include integrating /usr/bin/time for memory monitoring, adding memory validation to test cases, and converting test scripts to template literals. The addition of memory tolerance validation and new C test cases for heap and stack memory allocation enhances the testing suite.
| script: ` | ||
| process.stdin.setEncoding('utf8'); | ||
| process.stdin.on('data', (input) => { | ||
| console.log(input.trim()); | ||
| });`, |
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.
|
You are above your monthly Qodo Merge usage quota. For more information, please visit here. |
2 similar comments
|
You are above your monthly Qodo Merge usage quota. For more information, please visit here. |
|
You are above your monthly Qodo Merge usage quota. For more information, please visit here. |
singodiyashubham87
left a comment
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.
Please resolve the requested changes.
|
After making the changes, Please make sure to test everything. |
singodiyashubham87
left a comment
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.
LGTM!
Please wait for approval from @shashanksingh2002 before merging.
User description
Overview
This PR introduces a memory tracking feature for all programs by leveraging the /usr/bin/time command. The goal is to monitor and validate how much memory each programming language is using during execution, and to align memory usage reporting across languages (C, Python, Node.js, etc.).
Changes
Memory Tracking Feature
/usr/bin/timefor accurate and consistent memory measurement across languages.Expanded Test Cases
testJson.jsto cover:approxMemoryUsesfield for test cases to define expected memory ranges.Code Improvements
PR Type
Enhancement, Tests
Description
• Add memory usage tracking using
/usr/bin/timecommand• Implement memory validation in test cases with tolerance checks
• Convert test scripts to template literals for better readability
• Add new C test cases for heap and stack memory allocation
Changes walkthrough 📝
code.service.js
Add memory tracking to code executionservices/code.service.js
• Integrate
/usr/bin/timecommand for memory monitoring during codeexecution
• Parse memory report from
/tmp/memory_report.txtand adjustfor Alpine Linux
• Add memory field to response object with KB to
adjusted units conversion
• Minor code formatting improvements
(spacing and function declarations)
testJson.js
Update test cases with memory expectationstests/data/testJson.js
• Convert all test script strings from concatenation to template
literals
• Add
approxMemoryUsesfield to existing test cases withexpected memory values
• Add two new C test cases for heap allocation
(50MB) and stack allocation (6MB)
• Update stdin handling and script
formatting across all language tests
test.js
Add memory validation to test assertionstests/test.js
• Add memory tolerance validation with 20% tolerance threshold
•
Implement memory usage assertions comparing actual vs expected values
• Add
MEMORY_TOLERANCE_PERCENTconstant for configurable tolerance