Giter VIP home page Giter VIP logo

Comments (3)

exrok avatar exrok commented on June 27, 2024

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.

YjyJeff avatar YjyJeff commented on June 27, 2024

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.

exrok avatar exrok commented on June 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.