-
-
Notifications
You must be signed in to change notification settings - Fork 602
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: unified use of rspack_glob #7556
Conversation
✅ Deploy Preview for rspack canceled.
|
!bench |
📝 Benchmark detail: Open
|
Perhaps we should directly compare their matching speed. use codspeed_criterion_compat::{criterion_group, criterion_main, Criterion};
const PATH: &str = "some/a/bigger/path/to/the/crazy/needle.txt";
const GLOB: &str = "some/**/needle.txt";
fn fast_glob_crate(b: &mut Criterion) {
b.bench_function("fast_glob", |b| {
b.iter(|| fast_glob::glob_match(GLOB, PATH))
});
}
fn rspack_glob_crate(b: &mut Criterion) {
b.bench_function("rspack_glob", |b| {
let pat = rspack_glob::Pattern::new(GLOB).unwrap(); // Break out of loop bench
b.iter(|| pat.matches(PATH))
});
}
criterion_group!(benches, fast_glob_crate, rspack_glob_crate);
criterion_main!(benches); |
@shulaoda I made some mistakes. I habitually thought that But unfortunately,
|
It's my pleasure. |
I'm sorry, due to some reasons, I may not be able to complete this task until this weekend. @SyMind |
That's totally fine, take your time 😄 |
@shulaoda In the end, we found we should not let Another point is that the performance of When this method matches a glob without internal braces, its performance is even lower than Here is my attempt: https://github.com/SyMind/glob-match/blob/main/src/lib.rs#L236 |
I will try to further optimize, thank you for your attempt. |
Summary
Background
In this PR, we unified the glob crate used in Rspack into a new crate named
rspack_glob
, which affects theSideEffectsFlagPlugin
andCopyRspackPlugin
.The code is copied from the
glob
crate with some modifications, some modifications following the approach from biome:https://github.com/biomejs/biome/blob/main/crates/biome_service/src/matcher/pattern.rs
{a,b}
syntax.**
with preceding and trailing/
. Instead of throwing an error, it now replaces**
with*
.Result
We do not need to unify the implementation of
glob
within Rspack:In
SideEffectsFlagPlugin
, theglob
library is used to match the expressions configured insideEffects
with the import filenames. There is no need to interact with the file system I/O. The requirements are fixed, such as case sensitivity and the necessity of delimiters.In
CopyRspackPlugin
, theglob
library uses user-configured expressions to traverse and find files matching the specified directory. To achieve this, it minimizes the I/O process as much as possible. In the JS ecosystem,fast-glob
determines whether aglob
expression is dynamic or static and performs partial matching of theglob
. The Rustglob
crate splits theglob
based on delimiters.In
CopyRspackPlugin
, it is expected to have more configuration options forglob
matching, and its requirements are not fixed.In summary, to ensure the best performance for
sideEffects
matching and to satisfy the flexible needs ofCopyRspackPlugin
, unification is unnecessary.Checklist