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

refactor(dojo-lang): output debug info conditionally #2411

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

kariy
Copy link
Member

@kariy kariy commented Sep 10, 2024

related #2333

this PR adds a flag in the sozo cli and dojo compiler to determine whether to output the Sierra program debug information or not.

the debug artifacts have no use outside of the Walnut debugger integration, which they (the walnut team) are only using it internally. currently we're outputting it every time, which takes a huge chunk of the build time.

Imo, this is not something that we should maintain on our end but this is the path of least resistance for us.

Copy link

coderabbitai bot commented Sep 10, 2024

Walkthrough

Ohayo, sensei! The changes introduce a new boolean field, output_debug_info, to the BuildArgs struct, allowing users to specify whether to output debug information during the build process. This modification is reflected in the DojoCompiler, which now accepts this parameter during instantiation. The cli_main function is updated to handle the new argument based on the command type, enhancing the control flow. Additionally, the build_test_config function is modified to instantiate DojoCompiler with its default configuration.

Changes

Files Change Summary
bin/sozo/src/commands/build.rs Added output_debug_info field to BuildArgs struct and updated its default implementation.
bin/sozo/src/main.rs Modified cli_main to instantiate DojoCompiler with output_debug_info for the Build command.
crates/dojo-lang/src/compiler.rs Added output_debug_info field to DojoCompiler struct and updated its constructor and trait implementation.
crates/dojo-test-utils/src/compiler.rs Changed build_test_config to instantiate DojoCompiler using Box::new(DojoCompiler::default()).

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant DojoCompiler

    User->>CLI: Invoke Build Command with output_debug_info
    CLI->>DojoCompiler: Instantiate with output_debug_info
    DojoCompiler-->>CLI: Compiler ready
    CLI->>User: Build process initiated
Loading

Tip

Announcements
  • The review status is no longer posted as a separate comment when there are no actionable or nitpick comments. In such cases, the review status is included in the walkthrough comment.
  • We have updated our review workflow to use the Anthropic's Claude family of models. Please share any feedback in the discussion post on our Discord.
  • Possibly related PRs: Walkthrough comment now includes a list of potentially related PRs to help you recall past context. Please share any feedback in the discussion post on our Discord.
  • Suggested labels: CodeRabbit can now suggest labels by learning from your past PRs in the walkthrough comment. You can also provide custom labeling instructions in the UI or configuration file.
  • Possibly related PRs, automatic label suggestions based on past PRs, learnings, and possibly related issues require data opt-in (enabled by default).

Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d4401e3 and 604f552.

Files selected for processing (4)
  • bin/sozo/src/commands/build.rs (2 hunks)
  • bin/sozo/src/main.rs (1 hunks)
  • crates/dojo-lang/src/compiler.rs (2 hunks)
  • crates/dojo-test-utils/src/compiler.rs (1 hunks)
Additional comments not posted (7)
bin/sozo/src/main.rs (1)

36-45: Ohayo, sensei! The conditional instantiation of DojoCompiler looks great!

The changes enhance the functionality by allowing more tailored behavior of the DojoCompiler based on the command type, improving the usability of the commands. The control flow remains intact, and the initialization logic for the DojoCompiler has been correctly altered.

bin/sozo/src/commands/build.rs (2)

50-53: Ohayo, sensei! The new output_debug_info field in BuildArgs is a great addition!

The new boolean field allows users to specify whether to output debug information for the compiled contracts, enhancing the functionality of the command. It is correctly defined with appropriate attributes and default value, improving the usability and configurability of the build process.


174-174: Ohayo, sensei! The Default implementation for BuildArgs looks perfect!

The Default implementation is correctly updated to initialize the new output_debug_info field to false, which is a sensible default value.

crates/dojo-test-utils/src/compiler.rs (1)

274-274: Ohayo, sensei! The change to instantiate DojoCompiler using its default constructor is a wise move!

Using DojoCompiler::default() ensures that the compiler is initialized with a standard set of parameters, potentially improving consistency and reducing the likelihood of misconfiguration. The overall control flow remains intact, and the initialization logic for the DojoCompiler has been appropriately altered.

crates/dojo-lang/src/compiler.rs (3)

66-74: Ohayo sensei! The new DojoCompiler struct with output_debug_info field looks great.

The code changes are approved. The struct and field are properly defined and documented.


76-80: Ohayo sensei! The new constructor for DojoCompiler is implemented correctly.

The code changes are approved. The constructor accepts the output_debug_info parameter and initializes the struct as expected.


Line range hint 159-168: Ohayo sensei! The conditional compilation of debug information based on self.output_debug_info is implemented correctly.

The code changes are approved. The code segment correctly compiles the debug information if self.output_debug_info is true, and creates a vector of None values otherwise.


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

@kariy kariy requested a review from glihm September 10, 2024 21:14
Copy link

codecov bot commented Sep 10, 2024

Codecov Report

Attention: Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.

Project coverage is 67.94%. Comparing base (d4401e3) to head (604f552).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
bin/sozo/src/commands/build.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2411      +/-   ##
==========================================
- Coverage   68.14%   67.94%   -0.21%     
==========================================
  Files         364      364              
  Lines       47760    47767       +7     
==========================================
- Hits        32548    32456      -92     
- Misses      15212    15311      +99     

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

Copy link
Collaborator

@glihm glihm left a comment

Choose a reason for hiding this comment

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

Agree, thanks for taking the time by adding this runtime flag, almost x10 compilation time, which is crazy actually.

@glihm glihm merged commit dbe8ca8 into main Sep 10, 2024
14 of 15 checks passed
@glihm glihm deleted the dojo-lang/output-debug-info-flag branch September 10, 2024 22:31
@kariy kariy mentioned this pull request Sep 19, 2024
@coderabbitai coderabbitai bot mentioned this pull request Oct 30, 2024
2 tasks
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