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

feat: Track and report peak memory usage for client build #38772

Open
wants to merge 5 commits into
base: release
Choose a base branch
from

Conversation

devin-ai-integration[bot]
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Jan 20, 2025

Memory Usage Tracking for Client Build

This PR adds memory usage tracking and reporting for the client build workflow. It helps monitor RAM consumption during builds to identify potential memory issues early.

Changes

  • Added memory tracking to install, type check, and build stages using /usr/bin/time -v
  • Implemented peak memory usage tracking for each stage and overall peak
  • Added automatic PR comments with memory usage statistics
  • Exclusive RAM tracking for client build workflow

Implementation Details

The implementation uses /usr/bin/time -v to track memory usage accurately for each build stage:

  1. Dependencies Installation
  2. Type Checking
  3. Build Process

Memory statistics are collected and posted as a PR comment, showing:

  • Peak memory usage for each stage
  • Overall peak memory usage
  • Formatted in a clear, readable format

Automation

/ok-to-test tags=""

🔍 Cypress test results

Warning

Tests have not run on the HEAD 591f23d yet


Mon, 27 Jan 2025 07:27:43 UTC

Created by Devin

Link to Devin run: https://app.devin.ai/sessions/9a905bef80d54148aa4f50ffe266cb4f

Summary by CodeRabbit

  • Chores
    • Enhanced GitHub Actions workflow to track and report memory usage during client build process
    • Added memory usage monitoring for installation, type checking, and build stages
    • Implemented automatic memory usage reporting on pull request comments

devin-ai-integration bot and others added 2 commits January 20, 2025 10:49
- Added memory tracking to install, type check, and build stages
- Added memory usage summary and PR comment generation
- Track peak memory usage for each stage and overall peak
- Exclusive RAM tracking for client build workflow

Link to Devin run: https://app.devin.ai/sessions/9a905bef80d54148aa4f50ffe266cb4f

Co-Authored-By: abhinav@appsmith.com <abhinav@appsmith.com>
- Added memory tracking to install, type check, and build stages
- Added memory usage summary and PR comment generation
- Track peak memory usage for each stage and overall peak
- Exclusive RAM tracking for client build workflow

Link to Devin run: https://app.devin.ai/sessions/9a905bef80d54148aa4f50ffe266cb4f

Co-Authored-By: abhinav@appsmith.com <abhinav@appsmith.com>
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add "(aside)" to your comment to have me ignore it.
  • Look at CI failures and help fix them

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Contributor

coderabbitai bot commented Jan 20, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request modifies the GitHub Actions workflow file .github/workflows/client-build.yml to introduce memory usage tracking during the client build process. The changes add new steps to collect and report peak memory consumption for installation, type checking, and build stages. These modifications enable detailed memory usage monitoring by capturing and summarizing resource utilization during different build phases.

Changes

File Change Summary
.github/workflows/client-build.yml - Added memory usage tracking steps
- Modified existing build commands to redirect memory stats
- Implemented PR commenting with memory usage summary

Sequence Diagram

sequenceDiagram
    participant Workflow as GitHub Actions
    participant Install as Dependency Install
    participant TypeCheck as Type Checking
    participant Build as Project Build
    participant Memory as Memory Tracker
    participant PR as Pull Request

    Workflow->>Install: Run with memory tracking
    Install-->>Memory: Capture peak memory
    Workflow->>TypeCheck: Run with memory tracking
    TypeCheck-->>Memory: Capture peak memory
    Workflow->>Build: Run with memory tracking
    Build-->>Memory: Capture peak memory
    Memory->>PR: Comment memory usage summary
Loading

Possibly related PRs

Suggested reviewers

  • dvj1988
  • nidhi-nair

Poem

🖥️ Bytes dancing, memory's tale unfolds
Workflow whispers secrets it holds
Tracking resources with gentle care
Build steps measured, performance laid bare
Code's heartbeat, in numbers we see! 📊


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the Enhancement New feature or request label Jan 20, 2025
@riodeuno
Copy link
Contributor

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jan 20, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
.github/workflows/client-build.yml (2)

232-256: Enhance memory usage reporting with formatted values and thresholds.

Consider these improvements:

  1. Format memory values in MB/GB for better readability
  2. Add configurable thresholds to alert on high memory usage
 # Function to extract peak memory
 get_peak_memory() {
-  grep "Maximum resident set size" "$1" | awk '{print $6}'
+  grep "Maximum resident set size" "$1" | awk '{
+    mem=$6/1024/1024;
+    if(mem >= 1024) {
+      printf "%.2f GB", mem/1024
+    } else {
+      printf "%.2f MB", mem
+    }
+  }'
 }

+# Define thresholds (in KB)
+MEMORY_THRESHOLD_WARNING=4194304  # 4GB
+MEMORY_THRESHOLD_CRITICAL=6291456 # 6GB
+
 # Create summary
 echo "Install Dependencies Peak: $PEAK_INSTALL kB" >> memory_summary.txt
 echo "Type Checking Peak: $PEAK_TYPECHECK kB" >> memory_summary.txt
 echo "Build Peak: $PEAK_BUILD kB" >> memory_summary.txt
 echo "Overall Peak: $OVERALL_PEAK kB" >> memory_summary.txt
+
+# Add threshold warnings
+if [ "$OVERALL_PEAK" -gt "$MEMORY_THRESHOLD_CRITICAL" ]; then
+  echo "⚠️ CRITICAL: Memory usage exceeded ${MEMORY_THRESHOLD_CRITICAL}KB threshold" >> memory_summary.txt
+elif [ "$OVERALL_PEAK" -gt "$MEMORY_THRESHOLD_WARNING" ]; then
+  echo "⚠️ WARNING: Memory usage exceeded ${MEMORY_THRESHOLD_WARNING}KB threshold" >> memory_summary.txt
+fi

231-259: Optimize multiple redirects to memory_summary.txt.

Consider using a single redirection for better efficiency, as suggested by shellcheck.

-echo "Memory usage summary:" > memory_summary.txt
-echo "===================" >> memory_summary.txt
-echo "Install Dependencies Peak: $PEAK_INSTALL kB" >> memory_summary.txt
-echo "Type Checking Peak: $PEAK_TYPECHECK kB" >> memory_summary.txt
-echo "Build Peak: $PEAK_BUILD kB" >> memory_summary.txt
-echo "Overall Peak: $OVERALL_PEAK kB" >> memory_summary.txt
+{
+  echo "Memory usage summary:"
+  echo "==================="
+  echo "Install Dependencies Peak: $PEAK_INSTALL kB"
+  echo "Type Checking Peak: $PEAK_TYPECHECK kB"
+  echo "Build Peak: $PEAK_BUILD kB"
+  echo "Overall Peak: $OVERALL_PEAK kB"
+} > memory_summary.txt
🧰 Tools
🪛 actionlint (1.7.4)

231-231: shellcheck reported issue in this script: SC2129:style:22:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0b830a5 and 1a3a220.

📒 Files selected for processing (1)
  • .github/workflows/client-build.yml (3 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/client-build.yml

231-231: shellcheck reported issue in this script: SC2129:style:22:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)

🔇 Additional comments (2)
.github/workflows/client-build.yml (2)

261-273: LGTM! Clean implementation of PR comment creation.

The GitHub API usage is correct, and the markdown formatting enhances readability.


138-139: Verify platform compatibility for memory tracking commands.

The /usr/bin/time -v command is Linux-specific and may not work on all GitHub runners. Consider adding a platform check or using a cross-platform alternative.

Run this script to verify the runner platform:

Also applies to: 144-145, 179-179

✅ Verification successful

Platform compatibility is managed via runner configuration

The workflow uses a configurable runner (${{ vars.RUNNER_CLIENT_BUILD }}), allowing the team to ensure compatibility with the /usr/bin/time -v command. No changes needed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the runner platform supports /usr/bin/time -v
echo "Runner platform: ${{ vars.RUNNER_CLIENT_BUILD }}"
which time && /usr/bin/time -v echo "test" || echo "time command not available or -v not supported"

Length of output: 349


Script:

#!/bin/bash
# Check workflow runner configuration and setup
rg "runs-on|container:" .github/workflows/client-build.yml

Length of output: 105

@riodeuno
Copy link
Contributor

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/12866753784.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 38772.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-38772.dp.appsmith.com

devin-ai-integration bot and others added 2 commits January 27, 2025 06:48
Co-Authored-By: abhinav@appsmith.com <abhinav@appsmith.com>
Co-Authored-By: abhinav@appsmith.com <abhinav@appsmith.com>
Copy link

📊 Client Build Memory Usage Report

Memory usage summary:
===================
Install Dependencies Peak: 824252 kB
Type Checking Peak: 2860436 kB
Build Peak: 12910672 kB
Overall Peak: 12910672 kB

…d workflow

Co-Authored-By: abhinav@appsmith.com <abhinav@appsmith.com>
Copy link

📊 Client Build Memory Usage Report

Memory usage summary:
===================
Install Dependencies Peak: .79 GB (831428 kB)
Type Checking Peak: 2.72 GB (2858980 kB)
Build Peak: 11.37 GB (11928264 kB)
Overall Peak: 11.37 GB (11928264 kB)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant