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

ci(release): switch to performance profile for cargo build #2608

Merged
merged 1 commit into from
Nov 1, 2024
Merged

Conversation

steebchen
Copy link
Contributor

@steebchen steebchen commented Nov 1, 2024

Description

Updated the GitHub Actions release workflow to use the 'performance'
profile instead of 'release' for building binaries.

Tests

  • Yes
  • No, because they aren't needed
  • No, because I need help

Added to documentation?

  • README.md
  • Dojo Book
  • No documentation needed

Checklist

  • I've formatted my code (scripts/prettier.sh, scripts/rust_fmt.sh, scripts/cairo_fmt.sh)
  • I've linted my code (scripts/clippy.sh, scripts/docs.sh)
  • I've commented my code
  • I've requested a review after addressing the comments

Summary by CodeRabbit

  • Chores
    • Updated the build command to improve performance during the release process.
    • Refined file naming conventions for consistent artifact handling across platforms.
    • Enhanced visibility into downloaded file structures during the release process.

@steebchen steebchen changed the title perf(profile): improve code size optimization ci(release): switch to performance profile in CI build Nov 1, 2024
Copy link

coderabbitai bot commented Nov 1, 2024

Walkthrough

Ohayo! The pull request introduces updates to the .github/workflows/release.yml file, altering the build and release processes. The build command has shifted from cargo build --release to cargo build --profile performance. The archiving step has been refined for consistent file naming across platforms, specifically using .tar.gz for all. A new step in the create-draft-release job enhances visibility into the structure of downloaded files, while the docker-build-and-push job remains unchanged.

Changes

File Path Change Summary
.github/workflows/release.yml - Changed build command to cargo build --profile performance.
- Refined archive step for consistent .tar.gz naming across platforms.
- Added step in create-draft-release job to display structure of downloaded files.
- No significant changes to docker-build-and-push job structure.

Possibly related PRs

  • ci(docker): streamline file permissions handling #2604: The changes in this PR focus on streamlining file permissions handling in CI workflows, which is directly related to the modifications in the .github/workflows/release.yml file that enhance the handling of binary permissions during the release process.

Suggested reviewers

  • glihm

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9fa2805 and 84240fe.

📒 Files selected for processing (1)
  • .github/workflows/release.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/release.yml

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 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.

Copy link

@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

🧹 Outside diff range and nitpick comments (3)
.github/workflows/release.yml (2)

Line range hint 126-134: Fix Windows archive filename inconsistency.

Ohayo! There's an issue in the Windows archive handling where the output filename doesn't match the actual file format:

  • The archive is created as .zip but the output reports .tar.gz
  • This mismatch could cause issues in downstream processes
-            echo "file_name=dojo_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" >> $GITHUB_OUTPUT
+            echo "file_name=dojo_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" >> $GITHUB_OUTPUT

Line range hint 107-134: Add binary size verification step.

Ohayo sensei! Since this PR focuses on binary size optimization, we should add a step to verify and log the size improvements.

Add this step after the build:

      - name: Verify binary sizes
        run: |
          echo "Binary sizes:"
          if [ "$PLATFORM_NAME" == "win32" ]; then
            ls -l ./target/${TARGET}/release/*.exe
          else
            ls -l ./target/${TARGET}/release/{katana,sozo,torii,dojo-language-server}
          fi

This will help track size optimization progress across releases.

Cargo.toml (1)

Ohayo! Consider updating slot dependency to latest stable version v0.21.0

The slot dependency is currently pinned to git revision 1298a30, but there are stable releases available. The latest version is v0.21.0. Using a stable version instead of a git revision would:

  • Provide better dependency tracking
  • Make updates more predictable
  • Follow Rust ecosystem best practices

Replace:

slot = { git = "https://github.com/cartridge-gg/slot", rev = "1298a30" }

with:

slot = { git = "https://github.com/cartridge-gg/slot", tag = "v0.21.0" }
🔗 Analysis chain

Line range hint 284-284: Consider pinning slot dependency to a stable version.

The slot integration is currently pinned to a specific git revision (1298a30). While this works, it might be better to:

  1. Wait for a stable release and use version numbers
  2. Document why this specific revision was chosen

Let's check if there are any stable releases available:


Note: The previous script failed to fetch GitHub releases information. Let's first verify the actual content of Cargo.toml to understand the context better, as the review comment snippet was empty. This will help us determine our next steps for verification.


Note: Since the GitHub releases API call failed earlier, let's try checking for tags instead to see if there are any stable versions available for the slot dependency.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check slot repository for releases
gh api repos/cartridge-gg/slot/releases --jq '.[].tag_name' || echo "No releases found"

Length of output: 163


Script:

#!/bin/bash
# Let's check the actual content of Cargo.toml to verify the slot dependency
cat Cargo.toml

Length of output: 8700


Script:

#!/bin/bash
# Let's check if there are any tags in the slot repository
gh api repos/cartridge-gg/slot/tags --jq '.[].name' || echo "No tags found"

Length of output: 275

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 712422f and 9fa2805.

📒 Files selected for processing (2)
  • .github/workflows/release.yml (1 hunks)
  • Cargo.toml (1 hunks)
🔇 Additional comments (3)
.github/workflows/release.yml (1)

107-107: Ohayo sensei! Verify the performance profile configuration.

The change from --release to --profile performance aligns with the size optimization goal. However, let's ensure the profile is properly configured.

✅ Verification successful

Ohayo sensei! The performance profile is properly configured! ٩(◕‿◕。)۶

The performance profile in Cargo.toml is correctly set up with opt-level = "z" for maximum size optimization, which perfectly aligns with the build command change in the workflow.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify performance profile configuration in Cargo.toml
rg -U '\[profile\.performance\][\s\S]*?opt-level.*?=.*?"z"' || echo "Performance profile with opt-level 'z' not found"

Length of output: 150

Cargo.toml (2)

Line range hint 1-2: Workspace resolver configuration is appropriate.

Using resolver = "2" is the recommended choice for modern Rust workspaces, providing better dependency resolution.


Line range hint 61-65: Ohayo sensei! Performance profile configuration looks solid!

The optimization settings are well-configured for maximum binary size reduction:

  • opt-level = "z" prioritizes size over speed
  • lto = "fat" enables aggressive cross-module optimization
  • codegen-units = 1 maximizes optimization potential
  • incremental = false is appropriate for release builds

Let's verify the impact on binary size:

#!/bin/bash
# Description: Compare binary sizes before and after optimization
# Note: This requires the PR branch to be checked out

# Get the current binary sizes
echo "Current binary sizes:"
fd -t f -e exe . target/performance/ -x ls -lh {} \; 2>/dev/null || echo "No binaries found yet"

Updated the GitHub Actions release workflow to use the 'performance'
profile instead of 'release' for building binaries.
@steebchen steebchen changed the title ci(release): switch to performance profile in CI build ci(release): switch to performance profile for cargo build Nov 1, 2024
Copy link
Member

@kariy kariy left a comment

Choose a reason for hiding this comment

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

look f good to me

Copy link

codecov bot commented Nov 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 54.92%. Comparing base (712422f) to head (84240fe).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2608      +/-   ##
==========================================
- Coverage   55.11%   54.92%   -0.19%     
==========================================
  Files         385      393       +8     
  Lines       47775    48328     +553     
==========================================
+ Hits        26332    26546     +214     
- Misses      21443    21782     +339     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kariy kariy merged commit 0f3f796 into main Nov 1, 2024
13 of 14 checks passed
@kariy kariy deleted the perf/build branch November 1, 2024 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants