Comments (3)
The compiler can't distinguish them.
Without the nightly
feature the likely,unlikely
functions do nothing and are simply the identify function as you observed.
But with the nightly feature...
#[cfg(feature = "nightly")]
use core::intrinsics::{likely, unlikely};
the actual intrinsics are used, which are still nightly only: https://doc.rust-lang.org/stable/core/intrinsics/fn.likely.html
from hashbrown.
Ok. I am looking for the implementation of the likely
and unlikely
in stable. Some other links said that hashbrown has a stable implementation of these two functions. I noticed the implementation has changed recently.
So in the current stable rust, the old implementation does not work and we can not achieve it now? @exrok
from hashbrown.
Correct that is the my current understanding. I am not aware of a stable implementation of the likely and unlikely. You could try the olds impls from hashbrown (removed here d677fd4) the logic behind seems sounds it is just a question of if they help LLVM consistently.
Sometimes even the unstable intrinsics don't help consistently: rust-lang/rust#88767
Also note, the current likely/unlikely intrinsics are currently marked "perma-unstable", so don't expect them to stabilize soon: rust-lang/rust#26179 (comment)
In terms of stable solutions I think the closest would be PGO: https://doc.rust-lang.org/rustc/profile-guided-optimization.html
But that only helps if your the one building the application and complicates the build procedure.
from hashbrown.
Related Issues (20)
- Bug in `RawIter::reflect_toggle_full`
- Properly document algorithm
- Returning / Accepting hash codes
- Support fallible eq and hasher in raw API HOT 8
- ahash shouldn't be the default Hasher HOT 3
- UB on aarch64_be-unknown-linux-gnu_ilp32 HOT 1
- latest/recent rev appears to break ahash/compile-time-rng usage HOT 2
- `hashbrown` fails to compile as a transitive dependency HOT 2
- allocator-api2 default-feature? HOT 2
- Compiling hashbrown 0.14.2 for aarch64-unknown-linux-gnu with "target-cpu=cortex-a53" generates illegal instructions HOT 2
- Switching to GxHash? HOT 9
- Feature: increase capacity according to the actual size returned by the allocator HOT 2
- Hashbrown crash due to bad malloc HOT 1
- 0.14.3 - no method named `clear` found for struct `HashMap` in the current scope HOT 5
- Benchmark biaised due to no fence around input
- assertion failed: buckets.is_power_of_two() HOT 8
- Build breaks on nightly due to use of `stdsimd` rust feature in ahash 0.8.6 HOT 2
- Was swap-remove behavior ever considered when removing entries? HOT 10
- Consider returning to 1.63.0 MSRV HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hashbrown.