Skip to content
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

Use papaya instead of dashmap #356

Merged
merged 1 commit into from
Jan 18, 2025
Merged

Use papaya instead of dashmap #356

merged 1 commit into from
Jan 18, 2025

Conversation

arendjr
Copy link
Contributor

@arendjr arendjr commented Jan 10, 2025

This PR replaces uses of dashmap in the Cache with papaya: https://github.com/ibraheemdev/papaya/
papaya is designed for read-heavy workloads, which seems quite fitting for your caching use case. We've also switched to it in Biome and are getting good results.

Note this PR currently depends on an unmerged feature I proposed, so I'm leaving it in Draft until this is merged: ibraheemdev/papaya#45

Performance results on my machine:

Benchmarking resolver/single-thread: Collecting 100 samples in estimated 5.0029 s (91k iteresolver/single-thread  time:   [53.564 µs 53.785 µs 54.015 µs]
                        change: [−13.249% −11.794% −10.385%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 8 outliers among 100 measurements (8.00%)
  2 (2.00%) high mild
  6 (6.00%) high severe
Benchmarking resolver/multi-thread: Collecting 100 samples in estimated 5.0311 s (152k iteresolver/multi-thread   time:   [37.287 µs 39.436 µs 41.322 µs]
                        change: [−14.069% −10.050% −5.5926%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 19 outliers among 100 measurements (19.00%)
  19 (19.00%) high severe
Benchmarking resolver/resolve from symlinks: Collecting 100 samples in estimated 5.2374 s resolver/resolve from symlinks
                        time:   [14.284 ms 14.309 ms 14.334 ms]
                        change: [−7.1326% −6.8864% −6.6154%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 2 outliers among 100 measurements (2.00%)
  2 (2.00%) high mild

So a roughly 10~11% speedup on the first two benchmarks, and almost 7% on the one involving symlinks.

Copy link

codspeed-hq bot commented Jan 10, 2025

CodSpeed Performance Report

Merging #356 will not alter performance

Comparing arendjr:papaya (8fab261) with main (2bc5173)

Summary

✅ 3 untouched benchmarks

src/cache.rs Outdated Show resolved Hide resolved
@ibraheemdev
Copy link

ibraheemdev commented Jan 12, 2025

Out of curiosity, are the benchmark results any better if you create the HashMap with the following configuration?

papaya::HashMap::builder()
    .resize_mode(papaya::ResizeMode::Blocking)
    .collector(seize::Collector::new().epoch_frequency(None))
    .build()

By default, papaya is configured to avoid tail latency spikes and prevent memory usage spikes caused by stalled threads. This is useful for server workloads but maybe less so for short-lived CLI applications (see ibraheemdev/papaya#46). Although it's possible that this project is used in LSP servers, so it might something you also care about :)

@arendjr
Copy link
Contributor Author

arendjr commented Jan 12, 2025

@ibraheemdev Trying out the throughput-optimized configuration too. Just to clarify: Can the memory spikes be caused by stalled threads, even if they're not holding on to a pin?

@ibraheemdev
Copy link

@arendjr No, the issue would be a thread holding on to a guard without dropping it. Epochs detect stalled threads and allow finer-grained reclamation of objects that they haven't accessed yet. This would be useful when holding a guard on an iterator, for example.

src/cache.rs Outdated Show resolved Hide resolved
@Boshen
Copy link
Member

Boshen commented Jan 15, 2025

This PR can be merged after a new papaya release.

Up to @arendjr to decide which PR to merge first - this or #358

@arendjr
Copy link
Contributor Author

arendjr commented Jan 15, 2025

No hurries on my end, so whenever @ibraheemdev feels ready for it! I'll can work on #358 independently.

@Boshen Boshen mentioned this pull request Jan 16, 2025
@ibraheemdev
Copy link

This should be good to go now with papaya 0.1.8.

@arendjr
Copy link
Contributor Author

arendjr commented Jan 17, 2025

I've rebased on main and bumped papaya to 0.1.8. Should be good to go now 👍

@arendjr arendjr marked this pull request as ready for review January 17, 2025 15:42
@Boshen Boshen merged commit 2098f8a into oxc-project:main Jan 18, 2025
14 checks passed
Boshen pushed a commit that referenced this pull request Jan 20, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
## 🤖 New release
* `oxc_resolver`: 3.0.3 -> 4.0.0 (⚠️ API breaking changes)

### ⚠️ `oxc_resolver` breaking changes

```
--- failure inherent_method_missing: pub method removed or renamed ---

Description:
A publicly-visible method or associated fn is no longer available under its prior name. It may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.37.0/src/lints/inherent_method_missing.ron

Failed in:
  ResolverGeneric::new_with_file_system, previously in file /tmp/.tmpKVx03E/oxc_resolver/src/lib.rs:138

--- failure struct_missing: pub struct removed or renamed ---

Description:
A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.37.0/src/lints/struct_missing.ron

Failed in:
  struct oxc_resolver::PackageJson, previously in file /tmp/.tmpKVx03E/oxc_resolver/src/package_json.rs:14
```

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[4.0.0](oxc_resolver-v3.0.3...oxc_resolver-v4.0.0)
- 2025-01-20

### <!-- 0 -->Features

- [**breaking**] generic fs cache `type Resolver =
ResolverGeneric<FsCache<FileSystemOs>>` (#358)

### <!-- 2 -->Performance

- use papaya instead of dashmap (#356)
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
This was referenced Feb 10, 2025
Boshen pushed a commit that referenced this pull request Feb 10, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
## 🤖 New release

* `oxc_resolver`: 4.0.0 -> 4.0.1 (✓ API compatible changes)

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[4.0.0](oxc_resolver-v3.0.3...oxc_resolver-v4.0.0)
- 2025-01-20

### <!-- 0 -->Features

- [**breaking**] generic fs cache `type Resolver =
ResolverGeneric<FsCache<FileSystemOs>>` (#358)
- [**breaking**] `PackageJson` and `TsConfig` traits (#360)

### <!-- 2 -->Performance

- use papaya instead of dashmap (#356)
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants