Skip to content

Commit 149a567

Browse files
committed
Fix benchmarks, parse bin, parse dependencies_meta, and parse quoted deps
--wip-- [skip ci] --wip-- [skip ci] fix bug with quoted deps in subdebs
1 parent 5345409 commit 149a567

13 files changed

Lines changed: 752 additions & 3059 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ cargo fmt --workspace
131131

132132
**Production Ready**
133133

134-
- All tests passing (22/22)
134+
- All tests passing (23/23)
135135
- Zero clippy warnings
136136
- Zero compilation errors
137137
- Zero-allocation parsing pipeline

crates/berry-bench-bin/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,16 @@ fn benchmark_fixture(
7272
let start = Instant::now();
7373
let result = parse_lockfile(&fixture);
7474
let duration = start.elapsed();
75+
assert!(result.is_ok(), "Should parse {fixture_name} successfully");
7576

7677
if verbose {
7778
println!(
78-
" Warmup {}: {:.3}ms",
79+
" Warmup {}: {:.3}ms - {} packages parsed",
7980
i + 1,
80-
duration.as_secs_f64() * 1000.0
81+
duration.as_secs_f64() * 1000.0,
82+
result.unwrap().1.entries.len()
8183
);
8284
}
83-
84-
assert!(result.is_ok(), "Should parse {fixture_name} successfully");
8585
}
8686

8787
// Measure heap usage with a single run

crates/berry-bench/benches/parser_benchmarks.rs

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,31 @@ fn benchmark_fixtures(c: &mut Criterion) {
4444
});
4545
});
4646

47-
// Very large fixture benchmark - disabled due to parsing issues
48-
// group.bench_function("duplicate_packages", |b| {
49-
// let fixture = load_fixture("duplicate-packages.yarn.lock");
50-
// b.iter(|| {
51-
// let result = parse_lockfile(black_box(&fixture));
52-
// assert!(result.is_ok(), "Should parse duplicate packages fixture successfully");
53-
// result.unwrap().1
54-
// });
55-
// });
47+
// Large fixture benchmark
48+
group.bench_function("duplicate_packages", |b| {
49+
let fixture = load_fixture("berry.lock");
50+
b.iter(|| {
51+
let result = parse_lockfile(black_box(&fixture));
52+
assert!(
53+
result.is_ok(),
54+
"Should parse duplicate packages fixture successfully"
55+
);
56+
result.unwrap().1
57+
});
58+
});
59+
60+
// Extra large fixture benchmark
61+
group.bench_function("resolutions_patches", |b| {
62+
let fixture = load_fixture("resolutions-patches.yarn.lock");
63+
b.iter(|| {
64+
let result = parse_lockfile(black_box(&fixture));
65+
assert!(
66+
result.is_ok(),
67+
"Should parse resolutions patches fixture successfully"
68+
);
69+
result.unwrap().1
70+
});
71+
});
5672

5773
group.finish();
5874
}
@@ -66,7 +82,8 @@ fn benchmark_parsing_speed_vs_size(c: &mut Criterion) {
6682
("workspaces.yarn.lock", "small-medium"),
6783
("yarn4-mixed-protocol.lock", "medium"),
6884
("auxiliary-packages.yarn.lock", "large"),
69-
// ("duplicate-packages.yarn.lock", "very-large"), // Disabled due to parsing issues
85+
("berry.lock", "extra-large"), // Large Berry lockfile (~112KB)
86+
("resolutions-patches.yarn.lock", "extra-extra-large"), // Very large lockfile (~2MB)
7087
];
7188

7289
for (fixture_name, size_label) in fixtures {
@@ -94,6 +111,8 @@ fn benchmark_memory_usage(c: &mut Criterion) {
94111
"minimal-berry.lock",
95112
"workspaces.yarn.lock",
96113
"auxiliary-packages.yarn.lock",
114+
"berry.lock",
115+
"resolutions-patches.yarn.lock",
97116
];
98117

99118
for fixture_name in fixtures {
@@ -157,6 +176,8 @@ fn benchmark_heap_usage(c: &mut Criterion) {
157176
("minimal-berry.lock", "small"),
158177
("workspaces.yarn.lock", "medium"),
159178
("auxiliary-packages.yarn.lock", "large"),
179+
("berry.lock", "extra-large"),
180+
("resolutions-patches.yarn.lock", "extra-extra-large"),
160181
];
161182

162183
for (fixture_name, size_label) in fixtures {

crates/berry-core/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@ version = "0.1.0"
1010
[dependencies]
1111
nom = "8.0.0"
1212

13+
[dev-dependencies]
14+
berry-test = { path = "../berry-test" }
15+
1316
[lints]
1417
workspace = true

crates/berry-core/src/metadata.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#[derive(Debug, Clone, PartialEq, Eq)]
44
#[allow(dead_code)]
55
pub struct PeerDependencyMeta {
6-
optional: bool,
6+
pub optional: bool,
77
}
88

99
// https://github.com/yarnpkg/berry/blob/master/packages/yarnpkg-core/sources/Manifest.ts#L19
@@ -12,7 +12,7 @@ pub struct PeerDependencyMeta {
1212
#[derive(Debug, Clone, PartialEq, Eq)]
1313
#[allow(dead_code)]
1414
pub struct DependencyMeta {
15-
built: Option<bool>,
16-
optional: Option<bool>,
17-
unplugged: Option<bool>,
15+
pub built: Option<bool>,
16+
pub optional: Option<bool>,
17+
pub unplugged: Option<bool>,
1818
}

crates/berry-core/src/package.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,27 +83,27 @@ pub struct Package {
8383
pub checksum: Option<String>,
8484

8585
/// A set of constraints indicating whether the package supports the host environments
86-
conditions: Option<String>,
86+
pub conditions: Option<String>,
8787

8888
/// A map of the package's dependencies. There's no distinction between prod
8989
/// dependencies and dev dependencies, because those have already been merged
9090
/// during the resolution process
9191
pub dependencies: HashMap<Ident, Descriptor>,
9292

9393
/// Map with additional information about direct dependencies
94-
dependencies_meta: HashMap<Ident, Option<DependencyMeta>>,
94+
pub dependencies_meta: HashMap<Ident, Option<DependencyMeta>>,
9595

9696
/// Map of pacakges peer dependencies
9797
pub peer_dependencies: HashMap<Ident, Descriptor>,
9898

9999
/// Map with additional information about peer dependencies
100-
peer_dependencies_meta: HashMap<Ident, PeerDependencyMeta>,
100+
pub peer_dependencies_meta: HashMap<Ident, PeerDependencyMeta>,
101101

102102
/// all bin entries for the package
103103
///
104104
/// We don't need binaries in resolution, but we do neeed them to keep `yarn run` fast
105105
/// else we have to parse and read all of the zipfiles
106-
bin: HashMap<BinaryName, PortablePath>,
106+
pub bin: HashMap<String, String>,
107107
}
108108

109109
impl Package {

0 commit comments

Comments
 (0)