Comments (4)
Rust added core::sync::atomic::spin_loop_hint
in 1.24. It would probably make sense to use that.
from spin-rs.
It appears @tmccombs's suggestion has been adopted in 481c913 (thanks!). This issue can be closed.
from spin-rs.
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.
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)
- Inconsistent feature name HOT 2
- `lock_api` feature is not available in version 0.7.1 and 0.8.0. HOT 4
- Cannot borrow `lazy::Lazy<T>` mutably? HOT 5
- Remove `panicked` field from Once's Finish guard HOT 2
- Implement Once::get_mut_unchecked and Once::into_inner_unchecked HOT 4
- unwrap function in MutexGuard? HOT 4
- Request: Add support for atomic-polyfill HOT 7
- `Once::call_once` doesn't guarantee that the given closure is called only if this is the first time `call_once` has been called. HOT 2
- RwLock::try_read is unsound HOT 2
- MIRI build in CI is failing HOT 4
- portable_atomic feature does not compile HOT 2
- CI: Set minimal permissions on GitHub Workflow HOT 3
- Why was spin 0.9.6 yanked? HOT 2
- Unsoundness in `Once::try_call_once()`
- Are `rwlock` and `spin_mutex` compatible with `portable_atomic`? HOT 11
- `Lazy` panics under bare metal environment HOT 10
- Implement a ticket lock for greater fairness HOT 2
- Add `std` feature with support for thread yielding HOT 1
- Switching to GitHub actions HOT 1
- Need a spinlock that never uses std::thread::yield_now HOT 9
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 spin-rs.