+
Skip to content

Conversation

siketyan
Copy link
Member

@siketyan siketyan commented Aug 5, 2025

Summary

Performed some minor performance tweaks.
In my private repo, this reduced ~700ms of the execution time.

Test Plan

N/A

Docs

N/A

@siketyan siketyan self-assigned this Aug 5, 2025
Copy link

changeset-bot bot commented Aug 5, 2025

⚠️ No Changeset found

Latest commit: 17ca35e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Aug 5, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. 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.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 explain this code block.
  • 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 explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this 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.

@github-actions github-actions bot added A-CLI Area: CLI A-Core Area: core A-Project Area: project A-Linter Area: linter labels Aug 5, 2025
Comment on lines -57 to -61
let kind = if path.is_dir() {
FileKinds::Directory
} else {
path.file_name().map(Self::priority).unwrap_or_default()
};
Copy link
Member Author

Choose a reason for hiding this comment

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

This is introduced in 4309234, but it seems not used. Utf8Path::is_dir() requires an I/O syscall, that is relatively heavy when it's called many times.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've been bothered by that one for a while, and wished to remove it too. Glad you did!

Comment on lines -861 to -866
let ignore_directory = if gitignore.path().is_file() {
// SAFETY: if it's a file, it always has a parent
gitignore.path().parent().unwrap()
} else {
gitignore.path()
};
Copy link
Member Author

Choose a reason for hiding this comment

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

Based on doc comments, gitignore.path() is always a directory path where contains the .gitignore file.

Copy link
Contributor

Choose a reason for hiding this comment

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

I hope you're right 😅 This may be something @ematipico can say better than I can.

Copy link
Member

Choose a reason for hiding this comment

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

It's a good change. I initially added this because I didn't understand completely how the library works. But now we always store folders, so this piece of code can go away ☺️

Vec::new()
},
});
let (diagnostics, errors, skipped_diagnostics) = if categories.is_lint()
Copy link
Member Author

Choose a reason for hiding this comment

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

format_with_guard() calls Workspace::pull_diagnostics to collect parse diagnostics, but it also lead calling lint(), which is not necessary and takes some time.

@siketyan siketyan force-pushed the perf/minor-tweaks branch from 431fbd6 to 420fdcf Compare August 5, 2025 18:35
i Example of suppression: // biome-ignore lint: reason
```
Copy link
Member Author

Choose a reason for hiding this comment

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

This was duplicated diagnostic!

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch!

@siketyan siketyan requested review from a team August 5, 2025 18:38
@siketyan siketyan marked this pull request as ready for review August 5, 2025 18:38
Copy link

codspeed-hq bot commented Aug 5, 2025

CodSpeed Performance Report

Merging #7122 will not alter performance

Comparing siketyan:perf/minor-tweaks (17ca35e) with next (85b1128)1

Summary

✅ 128 untouched benchmarks

Footnotes

  1. No successful run was found on next (76df523) during the generation of this report, so 85b1128 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copy link
Contributor

@arendjr arendjr left a comment

Choose a reason for hiding this comment

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

LGTM, but I would recommend to check the gitignore thing with Ema.

i Example of suppression: // biome-ignore lint: reason
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch!

Comment on lines -57 to -61
let kind = if path.is_dir() {
FileKinds::Directory
} else {
path.file_name().map(Self::priority).unwrap_or_default()
};
Copy link
Contributor

Choose a reason for hiding this comment

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

I've been bothered by that one for a while, and wished to remove it too. Glad you did!

Comment on lines -861 to -866
let ignore_directory = if gitignore.path().is_file() {
// SAFETY: if it's a file, it always has a parent
gitignore.path().parent().unwrap()
} else {
gitignore.path()
};
Copy link
Contributor

Choose a reason for hiding this comment

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

I hope you're right 😅 This may be something @ematipico can say better than I can.

Comment on lines +1230 to +1231
let (diagnostics, errors, skipped_diagnostics) = if (categories.is_lint()
|| categories.is_assist())
Copy link
Contributor

Choose a reason for hiding this comment

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

When do we call pull_diagnostics() when the category is not either lint or assist? I suppose this change is what fixed the duplicate diagnostic, so it seems a good change, but I'm curious at why this works...

Copy link
Member Author

Choose a reason for hiding this comment

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

@arendjr format_with_guard() calls pull_diagnostics() with RuleCategories::Syntax.

let diagnostics_result = workspace_file
.guard()
.pull_diagnostics(
RuleCategoriesBuilder::default().with_syntax().build(),
Vec::new(),
Vec::new(),
false, // NOTE: probably to revisit
)
.with_file_path_and_code(workspace_file.path.to_string(), category!("format"))?;

Copy link
Member

Choose a reason for hiding this comment

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

Can you add a test that tries to format a code that violates a syntax rule? Ideally it shouldn't format it, and it should emit the diagnostic

Copy link
Member Author

Choose a reason for hiding this comment

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

Added here: 17ca35e

@siketyan siketyan requested a review from ematipico August 6, 2025 07:26
@siketyan siketyan merged commit d4e0e64 into biomejs:next Aug 6, 2025
28 checks passed
ematipico pushed a commit that referenced this pull request Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Core Area: core A-Linter Area: linter A-Project Area: project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载