Skip to content

Instantly share code, notes, and snippets.

View Amanieu's full-sized avatar

Amanieu d'Antras Amanieu

View GitHub Profile
00002988 0000000000000014 0000295c FDE cie=00000030 pc=0000000000032210..0000000000032216
DW_CFA_def_cfa: r3 (rbx) ofs 0
DW_CFA_offset: r6 (rbp) at cfa-16
DW_CFA_nop
DW_CFA_nop
000029a0 0000000000000014 00002974 FDE cie=00000030 pc=0000000000032220..0000000000032225
DW_CFA_def_cfa_offset: 24
DW_CFA_offset: r16 (rip) at cfa-24
DW_CFA_offset: r3 (rbx) at cfa+0
mem::transmute_copy(&(*(dst as *const AtomicU8)).swap(mem::transmute_copy(&val), order))
-----
let atomic = &*(dst as *const AtomicU8);
let new = mem::transmute_copy(&val);
let old = atomic.swap(new);
mem::transmute_copy(&old)
ptr::read(&(*(dst as *const AtomicU8)).swap(ptr::read(&val as *const _ as *const u8), order) as *const _ as *const u8)
-----
let atomic = &*(dst as *const AtomicU8);
#include <utility>
#include <iostream>
#include <dlfcn.h>
int foo(char*, int*);
void* dl_handle;
void* get_sym(const char* name)
{
void* s = dlsym(dl_handle, name);
#[macro_export]
macro_rules! offset_of_unsafe {
($container:path, $field:ident) => {{
// Make sure the field actually exists. This line ensures that a
// compile-time error is generated if $field is accessed through a
// Deref impl.
let $container { $field : _, .. };
// Create an instance of the container and calculate the offset to its
// field. Although we are creating references to uninitialized data this
@Amanieu
Amanieu / mutex.txt
Created May 27, 2016 17:28
parking_lot benchmark results on AArch64 Linux
- Running with 1 threads
- 1 iterations inside lock, 0 iterations outside lock
- 1 seconds per test
parking_lot::Mutex - 10253.095 kHz
std::sync::Mutex - 9483.620 kHz
pthread_mutex_t - 15784.474 kHz
- Running with 2 threads
parking_lot::Mutex - 9169.484 kHz
std::sync::Mutex - 2147.602 kHz
pthread_mutex_t - 5768.177 kHz
@Amanieu
Amanieu / mutex.txt
Created May 27, 2016 16:59
parking_lot benchmark results on x86_64 Windows
- Running with 1 threads
- 1 iterations inside lock, 0 iterations outside lock
- 1 seconds per test
parking_lot::Mutex - 38503.948 kHz
std::sync::Mutex - 33418.185 kHz
- Running with 2 threads
parking_lot::Mutex - 37202.976 kHz
std::sync::Mutex - 34696.846 kHz
- Running with 3 threads
parking_lot::Mutex - 36790.601 kHz
@Amanieu
Amanieu / mutex.txt
Created May 27, 2016 16:55
parking_lot benchmark results on x86_64 Linux
- Running with 1 threads
- 1 iterations inside lock, 0 iterations outside lock
- 1 seconds per test
parking_lot::Mutex - 55070.265 kHz
std::sync::Mutex - 41046.788 kHz
pthread_mutex_t - 42379.765 kHz
- Running with 2 threads
parking_lot::Mutex - 51957.167 kHz
std::sync::Mutex - 14006.237 kHz
pthread_mutex_t - 11683.600 kHz
- Running with 1 threads
- 1 iterations inside lock, 0 iterations outside lock
- 1 seconds per test
parking_lot::Mutex - 66765.574 kHz
std::sync::Mutex - 41126.109 kHz
pthread_mutex_t - 41779.734 kHz
- Running with 2 threads
parking_lot::Mutex - 63127.369 kHz
std::sync::Mutex - 14047.084 kHz
pthread_mutex_t - 10434.312 kHz
Running `target/release/mutex 0:8 1 0 3`
- Running with 1 threads
- 1 iterations inside lock, 0 iterations outside lock
- 3 seconds per test
parking_lot::Mutex - 68005.066 kHz
std::sync::Mutex - 41318.656 kHz
pthread_mutex_t - 42837.574 kHz
- Running with 2 threads
parking_lot::Mutex - 41934.774 kHz
std::sync::Mutex - 13579.001 kHz
- Running with 1 threads
- 1 iterations inside lock, 0 iterations outside lock
- 2 seconds per test
parking_lot::Mutex - 65219.523 kHz
std::sync::Mutex - 40738.619 kHz
pthread_mutex_t - 41253.795 kHz
- Running with 2 threads
parking_lot::Mutex - 33900.933 kHz
std::sync::Mutex - 12205.602 kHz
pthread_mutex_t - 14393.240 kHz