Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ produced:

| Fixture | Benchmarked files | Codescythe | Knip |
| --- | ---: | ---: | ---: |
| `microsoft/vscode` | 9,537 | 738.0ms | 5.76s |
| `grafana/grafana` | 8,701 | 771.0ms | 9.29s |
| `elastic/kibana` | 86,056 | 11.64s | 45.35s |
| `renovatebot/renovate` | 2,488 | 118.5ms | 846.1ms |
| `microsoft/vscode` | 9,398 | 1.11s | 4.22s |
| `grafana/grafana` | 8,358 | 833.2ms | 9.51s |
| `elastic/kibana` | 85,928 | 12.96s | 53.33s |
| `renovatebot/renovate` | 2,456 | 154.5ms | 900.5ms |

Counts reflect each fixture's generated benchmark config after excludes. Run
`pnpm benchmark` to measure the same fixtures locally.
Expand Down
18 changes: 9 additions & 9 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ unset.

## Current Numbers

Local run on May 20, 2026 with the checked-in fixture configs:
Local run on May 22, 2026 with the checked-in fixture configs:

```sh
bazel build -c opt //crates/codescythe_cli:codescythe
Expand All @@ -73,14 +73,14 @@ node --experimental-transform-types benchmarks/run.ts --samples 3 --warmups 1 --
```text
fixture tool mean rme samples ops/sec
--------- ---------- --------- --------- ------- -------
vscode codescythe 1468.2ms +/-4.42% 4 0.68
vscode knip 4669.8ms +/-27.79% 3 0.21
grafana codescythe 1031.1ms +/-3.69% 5 0.97
grafana knip 10302.1ms +/-28.43% 3 0.10
kibana codescythe 15932.2ms +/-10.85% 3 0.06
kibana knip 61479.6ms +/-14.43% 3 0.02
renovate codescythe 176.3ms +/-2.92% 17 5.67
renovate knip 954.5ms +/-18.01% 5 1.05
vscode codescythe 1111.9ms +/-1.36% 5 0.90
vscode knip 4223.1ms +/-4.89% 3 0.24
grafana codescythe 833.2ms +/-4.11% 5 1.20
grafana knip 9513.4ms +/-56.75% 3 0.11
kibana codescythe 12963.8ms +/-25.85% 3 0.08
kibana knip 53327.5ms +/-33.69% 3 0.02
renovate codescythe 154.5ms +/-4.79% 18 6.47
renovate knip 900.5ms +/-6.09% 5 1.11
```

## Vendored Conformance
Expand Down
18 changes: 18 additions & 0 deletions crates/codescythe/analyze/resolver.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use super::*;

use std::cell::RefCell;

pub(super) struct ModuleResolver {
resolver: ResolverGeneric<IgnoredResolverMetadataFileSystem>,
index_by_path: HashMap<PathBuf, usize>,
resolution_cache: RefCell<HashMap<(String, String), ImportResolution>>,
}

struct IgnoredResolverMetadataFileSystem {
Expand Down Expand Up @@ -94,6 +97,7 @@ impl FileSystem for IgnoredResolverMetadataFileSystem {
}
}

#[derive(Clone, Copy)]
pub(super) enum ImportResolution {
Project(usize),
External,
Expand Down Expand Up @@ -149,10 +153,24 @@ impl ModuleResolver {
Ok(Self {
resolver,
index_by_path,
resolution_cache: RefCell::new(HashMap::new()),
})
}

pub(super) fn resolve(&self, from: &FileData, specifier: &str) -> Result<ImportResolution> {
let cache_key = (from.relative.clone(), specifier.to_string());
if let Some(resolution) = self.resolution_cache.borrow().get(&cache_key) {
return Ok(*resolution);
}

let resolution = self.resolve_uncached(from, specifier)?;
self.resolution_cache
.borrow_mut()
.insert(cache_key, resolution);
Ok(resolution)
}

fn resolve_uncached(&self, from: &FileData, specifier: &str) -> Result<ImportResolution> {
match self.resolver.resolve_file(&from.path, specifier) {
Ok(resolution) => {
let path = normalize_path(resolution.path());
Expand Down
Loading