-
-
Notifications
You must be signed in to change notification settings - Fork 714
perf: minor performance tweaks #7122
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
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
let kind = if path.is_dir() { | ||
FileKinds::Directory | ||
} else { | ||
path.file_name().map(Self::priority).unwrap_or_default() | ||
}; |
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.
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.
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.
I've been bothered by that one for a while, and wished to remove it too. Glad you did!
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() | ||
}; |
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.
Based on doc comments, gitignore.path()
is always a directory path where contains the .gitignore
file.
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.
I hope you're right 😅 This may be something @ematipico can say better than I can.
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.
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() |
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.
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.
431fbd6
to
420fdcf
Compare
i Example of suppression: // biome-ignore lint: reason | ||
``` |
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.
This was duplicated diagnostic!
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.
Nice catch!
CodSpeed Performance ReportMerging #7122 will not alter performanceComparing Summary
Footnotes |
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, but I would recommend to check the gitignore thing with Ema.
i Example of suppression: // biome-ignore lint: reason | ||
``` |
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.
Nice catch!
let kind = if path.is_dir() { | ||
FileKinds::Directory | ||
} else { | ||
path.file_name().map(Self::priority).unwrap_or_default() | ||
}; |
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.
I've been bothered by that one for a while, and wished to remove it too. Glad you did!
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() | ||
}; |
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.
I hope you're right 😅 This may be something @ematipico can say better than I can.
let (diagnostics, errors, skipped_diagnostics) = if (categories.is_lint() | ||
|| categories.is_assist()) |
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.
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...
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.
@arendjr format_with_guard()
calls pull_diagnostics()
with RuleCategories::Syntax
.
biome/crates/biome_cli/src/execute/process_file/format.rs
Lines 37 to 45 in b9642ab
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"))?; |
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.
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
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.
Added here: 17ca35e
Summary
Performed some minor performance tweaks.
In my private repo, this reduced ~700ms of the execution time.
Test Plan
N/A
Docs
N/A