rust/library/core/src
bors e244e840f2 Auto merge of #84725 - sebpop:arm64-isb, r=joshtriplett
[Arm64] use isb instruction instead of yield in spin loops

On arm64 we have seen on several databases that ISB (instruction synchronization
barrier) is better to use than yield in a spin loop.  The yield instruction is a
nop.  The isb instruction puts the processor to sleep for some short time.  isb
is a good equivalent to the pause instruction on x86.

Below is an experiment that shows the effects of yield and isb on Arm64 and the
time of a pause instruction on x86 Intel processors.  The micro-benchmarks use
https://github.com/google/benchmark.git

```
$ cat a.cc
static void BM_scalar_increment(benchmark::State& state) {
  int i = 0;
  for (auto _ : state)
    benchmark::DoNotOptimize(i++);
}
BENCHMARK(BM_scalar_increment);
static void BM_yield(benchmark::State& state) {
  for (auto _ : state)
    asm volatile("yield"::);
}
BENCHMARK(BM_yield);
static void BM_isb(benchmark::State& state) {
  for (auto _ : state)
    asm volatile("isb"::);
}
BENCHMARK(BM_isb);
BENCHMARK_MAIN();

$ g++ -o run a.cc -O2 -lbenchmark -lpthread
$ ./run

--------------------------------------------------------------
Benchmark                    Time             CPU   Iterations
--------------------------------------------------------------

AWS Graviton2 (Neoverse-N1) processor:
BM_scalar_increment      0.485 ns        0.485 ns   1000000000
BM_yield                 0.400 ns        0.400 ns   1000000000
BM_isb                    13.2 ns         13.2 ns     52993304

AWS Graviton (A-72) processor:
BM_scalar_increment      0.897 ns        0.874 ns    801558633
BM_yield                 0.877 ns        0.875 ns    800002377
BM_isb                    13.0 ns         12.7 ns     55169412

Apple Arm64 M1 processor:
BM_scalar_increment      0.315 ns        0.315 ns   1000000000
BM_yield                 0.313 ns        0.313 ns   1000000000
BM_isb                    9.06 ns         9.06 ns     77259282
```

```
static void BM_pause(benchmark::State& state) {
  for (auto _ : state)
    asm volatile("pause"::);
}
BENCHMARK(BM_pause);

Intel Skylake processor:
BM_scalar_increment      0.295 ns        0.295 ns   1000000000
BM_pause                  41.7 ns         41.7 ns     16780553
```

Tested on Graviton2 aarch64-linux with `./x.py test`.
2021-05-02 04:54:31 +00:00
..
alloc Fix const stability since versions. 2021-03-15 14:39:18 +00:00
array Auto merge of #84147 - cuviper:array-method-dispatch, r=nikomatsakis,m-ou-se 2021-04-25 07:26:49 +00:00
char Update char::escape_debug_ext to handle different escapes in strings vs. chars 2021-03-26 11:23:51 +03:00
convert Get rid of "[+] show undocumented items" toggle on numeric From impls 2021-04-22 11:51:05 -07:00
fmt Rollup merge of #84390 - m-ou-se:make-debug-non-exhaustive-without-fields-a-little-bit-less-verbose, r=kennytm 2021-04-21 23:06:21 +02:00
future Rename #[doc(spotlight)] to #[doc(notable_trait)] 2021-03-15 13:59:54 -07:00
hash Auto merge of #83390 - clarfonthey:hasher_docs, r=Amanieu 2021-04-26 08:21:55 +00:00
iter Drop alias reduce for fold - we have a reduce function 2021-04-29 12:05:08 -07:00
macros Bump cfgs 2021-04-04 14:57:05 -04:00
mem Remove delete alias from mem::drop. 2021-04-21 21:54:39 +02:00
num Fix 'const-stable since' of reverse_bits 2021-04-25 11:58:59 +02:00
ops Auto merge of #84092 - scottmcm:try_trait_initial, r=yaahc,m-ou-se 2021-04-26 23:17:31 +00:00
prelude Bump cfgs 2021-04-04 14:57:05 -04:00
ptr Auto merge of #84061 - AngelicosPhosphoros:issue-75598-add-inline-always-arithmetic, r=nagisa 2021-04-17 23:31:10 +00:00
slice Auto merge of #77704 - AnthonyMikh:slice_index_with_ops_bound_pair, r=m-ou-se 2021-04-22 15:36:27 +00:00
str Auto merge of #82585 - TrolledWoods:master, r=dtolnay 2021-04-23 02:48:13 +00:00
stream Remove Stream::next 2021-01-23 16:54:56 +01:00
sync Stabilize atomic_fetch_update methods on AtomicBool and AtomicPtr. 2021-04-11 11:45:46 +02:00
task Add the try_trait_v2 library basics 2021-04-17 11:58:18 -07:00
unicode Add a check for ASCII characters in to_upper and to_lower 2021-02-26 11:39:36 -06:00
any.rs Change the Debug impl of Any and UnsafeCell to use finish_non_exhaustive 2021-04-21 14:51:04 +02:00
ascii.rs Replace all fmt.pad with debug_struct 2021-04-21 14:38:24 +02:00
bool.rs
borrow.rs Fix borrow and deref 2021-03-03 11:23:29 +01:00
cell.rs Use #[inline(always)] on trivial UnsafeCell methods 2021-04-04 11:55:13 -07:00
clone.rs Fix core tests 2021-03-03 11:22:49 +01:00
cmp.rs adds feature gating of no_coverage at either crate- or function-level 2021-04-27 17:12:51 -07:00
default.rs Add diagnostic item to Default trait 2021-03-04 10:14:48 -08:00
ffi.rs Replace all fmt.pad with debug_struct 2021-04-21 14:38:24 +02:00
hint.rs Auto merge of #84725 - sebpop:arm64-isb, r=joshtriplett 2021-05-02 04:54:31 +00:00
internal_macros.rs
intrinsics.rs stabilize const_cttz 2021-04-11 19:13:27 +02:00
lazy.rs
lib.rs Auto merge of #84310 - RalfJung:const-fn-feature-flags, r=oli-obk 2021-04-24 23:16:03 +00:00
marker.rs Always mention Box::pin when dealing with !Unpin 2021-04-06 19:55:45 -07:00
option.rs Reorder the parameter descriptions of map_or and map_or_else 2021-04-27 18:00:30 +08:00
panic.rs Implement new panic!() behaviour for Rust 2021. 2021-01-25 13:48:11 +01:00
panicking.rs Fix panic message of assert_failed_inner 2021-03-13 18:50:43 +08:00
pin.rs Fix overlength lines in core::pin. 2021-01-05 20:14:02 +01:00
primitive.rs
raw.rs Deprecate the core::raw / std::raw module 2021-04-15 02:32:33 +02:00
result.rs Reorder the parameter descriptions of map_or and map_or_else 2021-04-27 18:00:30 +08:00
time.rs Rollup merge of #84120 - workingjubilee:stabilize-duration-max, r=m-ou-se 2021-04-26 21:06:46 +02:00
tuple.rs
unit.rs