-
Notifications
You must be signed in to change notification settings - Fork 13.3k
std: Add performance warnings to HashMap::get_disjoint_mut #139307
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
Conversation
To be honest I don't understand why, why not just sort the list of hashes and check neighbours (n log n)? |
I'm not sure. I think what you said seems reasonable.We can wait for the members of libs to discuss it. Maybe we can change the implementation. |
So, we can't do it with the hashes due to collisions, and However, I think it would be possible to do everything up to getting the raw pointer of each element to return, then use this technique there. The performance is worse in the case of an overlap, but I think that is irrelevant since it panics in that case. But honestly it's probably not worth it, most use cases are probably 2 or 3 keys where the perf would probably even be worse. So I would go ahead with documenting it. |
Actually |
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
r? libs |
Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
Thanks! |
std: Add performance warnings to HashMap::get_disjoint_mut Closes rust-lang#139296 The `get_disjoint_mut` in `HashMap` also performs a complexity O(n^2) check. So we need to be reminded of that as well. https://github.com/rust-lang/hashbrown/blob/b5b0655a37e156f9798ac8dd7e970d4adba9bf90/src/raw/mod.rs#L1216-L1220
Rollup of 23 pull requests Successful merges: - rust-lang#139261 (mitigate MSVC alignment issue on x86-32) - rust-lang#139307 (std: Add performance warnings to HashMap::get_disjoint_mut) - rust-lang#139700 (Autodiff flags) - rust-lang#139752 (set subsections_via_symbols for ld64 helper sections) - rust-lang#139809 (Don't warn about `v128` in wasm ABI transition) - rust-lang#139852 (StableMIR: Implement `CompilerInterface`) - rust-lang#139945 (Extend HIR to track the source and syntax of a lifetime) - rust-lang#140028 (`deref_patterns`: support string and byte string literals in explicit `deref!("...")` patterns) - rust-lang#140139 (rustc_target: Adjust RISC-V feature implication) - rust-lang#140143 (Move `sys::pal::os::Env` into `sys::env`) - rust-lang#140148 (CI: use aws codebuild for job dist-arm-linux) - rust-lang#140150 (fix MAX_EXP and MIN_EXP docs) - rust-lang#140172 (Make algebraic functions into `const fn` items.) - rust-lang#140177 ([compiletest] Parallelize test discovery) - rust-lang#140181 (Remove `synstructure::Structure::underscore_const` calls.) - rust-lang#140184 (Update doc of cygwin target) - rust-lang#140186 (Rename `compute_x` methods) - rust-lang#140187 ([AIX] Handle AIX dynamic library extensions within c-link-to-rust-dylib run-make test) - rust-lang#140191 (Remove git repository from git config) - rust-lang#140194 (minicore: Have `//@ add-core-stubs` also imply `-Cforce-unwind-tables=yes`) - rust-lang#140195 (triagebot: label minicore changes w/ `A-test-infra-minicore` and ping jieyouxu on changes) - rust-lang#140202 (Make #![feature(let_chains)] bootstrap conditional in compiler/) - rust-lang#140214 (Remove comment about handling non-global where bounds with corresponding projection) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#134446 (Stabilize the `cell_update` feature) - rust-lang#139307 (std: Add performance warnings to HashMap::get_disjoint_mut) - rust-lang#139450 (Impl new API `std::os::unix::fs::mkfifo` under feature `unix_fifo`) - rust-lang#139809 (Don't warn about `v128` in wasm ABI transition) - rust-lang#139852 (StableMIR: Implement `CompilerInterface`) - rust-lang#139945 (Extend HIR to track the source and syntax of a lifetime) - rust-lang#140028 (`deref_patterns`: support string and byte string literals in explicit `deref!("...")` patterns) - rust-lang#140181 (Remove `synstructure::Structure::underscore_const` calls.) - rust-lang#140232 (Remove unnecessary clones) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#139307 - xizheyin:issue-139296, r=joboet std: Add performance warnings to HashMap::get_disjoint_mut Closes rust-lang#139296 The `get_disjoint_mut` in `HashMap` also performs a complexity O(n^2) check. So we need to be reminded of that as well. https://github.com/rust-lang/hashbrown/blob/b5b0655a37e156f9798ac8dd7e970d4adba9bf90/src/raw/mod.rs#L1216-L1220
Closes #139296
The
get_disjoint_mut
inHashMap
also performs a complexity O(n^2) check. So we need to be reminded of that as well.https://github.com/rust-lang/hashbrown/blob/b5b0655a37e156f9798ac8dd7e970d4adba9bf90/src/raw/mod.rs#L1216-L1220