Git Product home page Git Product logo

Comments (4)

tmccombs avatar tmccombs commented on August 18, 2024 1

Rust added core::sync::atomic::spin_loop_hint in 1.24. It would probably make sense to use that.

from spin-rs.

brandenburg avatar brandenburg commented on August 18, 2024 1

It appears @tmccombs's suggestion has been adopted in 481c913 (thanks!). This issue can be closed.

from spin-rs.

Dentosal avatar Dentosal commented on August 18, 2024

I don't know lot about other architectures, but it looks like Linux uses cpu_relax with ARM. Unlike me, they might know what they are doing.

Macros form https://android.googlesource.com/.../arm/include/asm/spinlock.h#67 look like this:

#define arch_spin_is_locked(x)		((x)->lock != 0)
#define arch_spin_unlock_wait(lock) \
    do { while (arch_spin_is_locked(lock)) cpu_relax(); } while (0)

from spin-rs.

Evrey avatar Evrey commented on August 18, 2024

This code snippet here and this ARM developer page suggest that asm!("yield" :::: "volatile"); would be the way to go on AArch64, i.e. 64-bit ARMv8. This read here might be of interest as well.

6. Conclusions

  • We propose to add onSpinWait() intrinsic and SpinPause implementation in (Linux) AArch64 port with yield instruction.
  • It is harmless for CPUs that implement the instruction as NOP.
  • It should be benefitial for CPUs that have SMT or are able to partially shut down or pause for a while.
  • It may be considered to emit several nop instead of yield where latter works as nop to decrease memory pressure without loosing throughput.
    • A concrete latency estimate for a potential implementation that should not cause any performance degradation for Java is around 16 cycles.

from spin-rs.

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.