Skip to content

Instantly share code, notes, and snippets.

View gnzlbg's full-sized avatar

gnzlbg gnzlbg

View GitHub Profile
valgrind -v target/release/jemalloc_repro
==19715== Memcheck, a memory error detector
==19715== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==19715== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
==19715== Command: target/release/jemalloc_repro
==19715==
--19715-- Valgrind options:
--19715-- -v
--19715-- Contents of /proc/version:
--19715-- Linux version 4.4.120-45-default (geeko@buildhost) (gcc version 4.8.5 (SUSE Linux) ) #1 SMP Wed Mar 14 20:51:49 UTC 2018 (623211f)
@gnzlbg
gnzlbg / msa.py
Created May 24, 2018 17:04
Scans the msa c gcc docs and formats the intrinsics for a github issue list
#!/usr/bin/env python
def fmt_type(x):
if 'void*' in x:
return '*mut c_void'
if 'void' in x:
return '()'
if x[0] == 'v':
xv = x.replace('v', '')
if 'i' in x:
PowerPC 601_v1 PVR 00010001
PowerPC 601_v0 PVR 00010001
PowerPC 601_v2 PVR 00010002
PowerPC 601 (alias for 601_v2)
PowerPC 601v (alias for 601_v2)
PowerPC 603 PVR 00030100
PowerPC mpc8240 (alias for 603)
PowerPC vanilla (alias for 603)
PowerPC 604 PVR 00040103
PowerPC ppc32 (alias for 604)
@gnzlbg
gnzlbg / config.toml
Created May 14, 2018 16:28
config.toml rustc
# Sample TOML configuration file for building Rust.
#
# To configure rustbuild, copy this file to the directory from which you will be
# running the build, and name it config.toml.
#
# All options are commented out by default in this file, and they're commented
# out with their default values. The build system by default looks for
# `config.toml` in the current directory of a build for build configuration, but
# a custom configuration file can also be specified with `--config` to the build
# system.
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::_print
at libstd/sys_common/backtrace.rs:71
2: std::panicking::default_hook::{{closure}}
at libstd/sys_common/backtrace.rs:59
at libstd/panicking.rs:380
3: std::panicking::default_hook
at libstd/panicking.rs:396
4: std::panicking::begin_panic
@gnzlbg
gnzlbg / input_after_opt.ll
Last active March 13, 2018 14:20
LLVM fails to optimize IR ?
define zeroext i1 @_ZN6anyall16stdsimd_all_8x1617h182b8422e73ca2f8E(<16 x i8>* noalias nocapture readonly dereferenceable(16) %b) unnamed_addr #0 {
start:
%0 = load <16 x i8>, <16 x i8>* %b, align 16
%1 = and <16 x i8> %0, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
%2 = icmp ne <16 x i8> %1, zeroinitializer
%3 = tail call i1 @llvm.experimental.vector.reduce.and.i1.v16i1(<16 x i1> %2) #2
ret i1 %3
}
@gnzlbg
gnzlbg / intrinsics.rs
Last active March 11, 2018 14:27
generic simd intrinsic
if name == "simd_boolean_vector" {
// the intrinsic takes and returns the same type, a simd vector of length in_len:
// <{i,u,f}W x in_len>
require_simd!(ret_ty, "return");
require!(in_ty == ret_ty, "return type {} must match input type {}", in_ty, ret_ty);
// creates a vector of <i1 x in_len>:
let i1_ty = Type::i1(bx.cx);
let bool_vec_ty = Type::vector(i1_ty, in_len);
// truncates the vector of <{i,u,f}W x in_len> into a vector of <i1 x in_len>
let bool_vec = bx.trunc(args[0].immediate(), bool_vec_ty);
@gnzlbg
gnzlbg / gbenchutils.rs
Last active February 1, 2018 10:19
clobber and do_not_optimize (black_box) from Google Benchmark in Rust
//! Google Benchmark clobber and do_not_optimize in Rust
//!
//! Play with them and test::black_box live in rust.godbolt.org
//! https://godbolt.org/g/hpS9tp
#![feature(asm)]
/// Prevents a value or the result of an expression from being optimized away by
/// the compiler adding as little overhead as possible.
///
/// It does not prevent optimizations on the expression generating `x` in any way:
@gnzlbg
gnzlbg / improvements.txt
Created November 28, 2017 13:43
likely jemallocator improvements/regressions
name results_master ns/iter results_likely ns/iter diff ns/iter diff % speedup
rt_even_1000000bytes_16align_alloc_layout_checked 223 223 0 0.00% x 1.00
rt_even_1000000bytes_16align_alloc_layout_unchecked 223 223 0 0.00% x 1.00
rt_even_1000000bytes_16align_mallocx_nallocx 238 237 -1 -0.42% x 1.00
rt_even_1000000bytes_16align_mallocx_zeroed 1,744 1,708 -36 -2.06% x 1.02
rt_even_1000000bytes_16align_realloc_excess_used 659 642 -17 -2.58% x 1.03
rt_even_1000000bytes_16align_realloc_naive 62,364 61,662 -702 -1.13% x 1.01
rt_even_1000000bytes_1align_alloc_layout_checked 223
@gnzlbg
gnzlbg / gist:c23123dcb5e781d653416b259f70c779
Created November 16, 2017 19:22
benchmark mallocx, smallocx, nallocx (flags = 5 = 32byte alignment)
test rt_even_1000000bytes_mallocx ... bench: 215 ns/iter (+/- 16)
test rt_even_1000000bytes_nallocx ... bench: 245 ns/iter (+/- 71)
test rt_even_1000000bytes_smallocx ... bench: 235 ns/iter (+/- 103)
test rt_even_100000bytes_mallocx ... bench: 229 ns/iter (+/- 149)
test rt_even_100000bytes_nallocx ... bench: 257 ns/iter (+/- 237)
test rt_even_100000bytes_smallocx ... bench: 233 ns/iter (+/- 183)
test rt_even_10000bytes_mallocx ... bench: 39 ns/iter (+/- 10)
test rt_even_10000bytes_nallocx ... bench: 47 ns/iter (+/- 42)
test rt_even_10000bytes_smallocx ... bench: 39 ns/iter (+/- 10)
test rt_even_1000bytes_mallocx ... bench: 33 ns/iter (+/- 28)