Skip to content

Remove dashmap usage#4408

Open
xacrimon wants to merge 12 commits intoleptos-rs:mainfrom
xacrimon:no-dashmap
Open

Remove dashmap usage#4408
xacrimon wants to merge 12 commits intoleptos-rs:mainfrom
xacrimon:no-dashmap

Conversation

@xacrimon
Copy link

@xacrimon xacrimon commented Oct 25, 2025

I'm the dashmap author and recently while working on a leptos project, I discovered dashmap in the deptree and got curious as to why it was there. Upon inspecting the usage of it in leptos, I've arrived the the conclusion that it's not appropriate in any of the places it's used.

The reason for this in all cases is that generally, you need to have very significant contention on the map across multiple cores for it to be worth it at all, after observing it's usage in the wild across a few years I like to say that most people that use it probably shouldn't. Dashmap is a very specialized tool and due to internal overheads necessary for a concurrent datastructure, it's generally doesn't provide any performance benefit (usually the opposite) unless you're hammering it with 1M+ lookups per second across cores, which is exceedingly unlikely in the places it's used.

Therefore, I've removed every usage of it across leptos that I found so far, and replaced them with the far simpler Mutex<HashMap> or RwLock<HashMap> depending on the spot.

@xacrimon xacrimon marked this pull request as ready for review October 25, 2025 17:40
use std::path::Path;
#[cfg(feature = "default")]
use std::sync::LazyLock;
#[cfg(feature = "default")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is causing cargo check --no-default-features to fail, because all of these imports are used with or without default features

gbj added a commit that referenced this pull request Jan 2, 2026
@gbj gbj mentioned this pull request Jan 2, 2026
gbj added a commit that referenced this pull request Feb 11, 2026
* chore: remove `dashmap` (cf. #4408)

* chore: remove conditional code for wasm32 from stores

* fix merge issue

* merge issues

* clippy

* remove dashmap in example
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.

2 participants