Skip to content

Instantly share code, notes, and snippets.

View lemire's full-sized avatar
🚀
working hard and fast

Daniel Lemire lemire

🚀
working hard and fast
View GitHub Profile
@lemire
lemire / funproblem.c
Created September 3, 2018 15:57
another mystery
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include "roaring.c"
int main() {
size_t bitmapcount = 2;
size_t size = 1000000;
struct timeval st, et;
@lemire
lemire / cachetest.cpp
Last active September 12, 2018 03:50
If you have M array accesses, how many cache misses can you have? What about 1.8 M cache misses...?
//
// $ g++ -O3 -o cachetest cachetest.cpp
// $ ./cachetest
// cycles = 349189333 (cycles per key 34.919) instructions = 190000063 (ins/key 19.000,ins/cycles 0.544) cache misses = 17385995 (misses per keys 1.739) branch misses = 6 (misses per keys 0.000)
//
// start helper header
// https://github.com/WojciechMula/toys/blob/master/000helpers/linux-perf-events.h
#ifdef __linux__
#include <asm/unistd.h> // for __NR_perf_event_open
.section __TEXT,__text,regular,pure_instructions
.macosx_version_min 10, 13
.section __TEXT,__literal16,16byte_literals
.p2align 4 ## -- Begin function _Z9timestampv
LCPI0_0:
.long 1127219200 ## 0x43300000
.long 1160773632 ## 0x45300000
.long 0 ## 0x0
.long 0 ## 0x0
LCPI0_1:
@lemire
lemire / nestedjson.py
Created November 23, 2018 19:02
Nested JSON generator (in Python)
import sys
depth = int(sys.argv[1])
s=""
for j in range(depth):
s+="["
s+="true"
for j in range(depth):
s+="]"
print(s)
rawdata = [["age","workclass","capital_loss"],["age","capital_gain","capital_loss"],["age","workclass","capital_loss","x"],["age","capital_gain","capital_loss","x"],["workclass","hours_per_week","native_country"],["age","capital_loss","native_country"],["workclass","hours_per_week","native_country","x"],["age","capital_loss","native_country","x"],["age","capital_loss","x"],["age","capital_gain","native_country"],["age","workclass","capital_gain"],["age","workclass","capital_gain","x"],["age","capital_gain","native_country","x"],["age","capital_gain","x"]]
print("how many sets", len(rawdata))
sdata = map(set,rawdata)
#print(len(sdata))
total = len(sdata)
allkeys = reduce(lambda x,y :x.union(y),sdata)
print("how many attributes ", len(allkeys))
l = set()
d = []
/***
result:
152ca78d
027c6003
cb07bbf3
f98befee
1cd777e3
a4e29590
661e4b6d
@lemire
lemire / Basic.java
Last active February 25, 2019 22:13
Some RoaringBitmap issue
import org.roaringbitmap.*;
import java.io.*;
import java.util.*;
public class Basic {
public static void main(String[] args) throws IOException {
DataInputStream in;
in = new DataInputStream(new FileInputStream(args[0]));
import org.roaringbitmap.RoaringBitmap;
import org.roaringbitmap.buffer.*;
import java.io.*;
import java.nio.*;
public class Issue319 {
@lemire
lemire / straceresults.txt
Created March 29, 2019 13:01
strace results with and without jemalloc
// with jemalloc
$ strace ./lemirebenchmark
execve("./lemirebenchmark", ["./lemirebenchmark"], [/* 28 vars */]) = 0
brk(NULL) = 0x79d0000
openat(AT_FDCWD, "/usr/local/lib/libjemalloc.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\340b\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=4887824, ...}) = 0
mmap(NULL, 1113224, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xffffaa020000
mmap(0xffffaa090000, 131072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x60000) = 0xffffaa090000
@lemire
lemire / straceresults.txt
Created March 29, 2019 13:01
strace results with and without jemalloc
// with jemalloc
$ strace ./lemirebenchmark
execve("./lemirebenchmark", ["./lemirebenchmark"], [/* 28 vars */]) = 0
brk(NULL) = 0x79d0000
openat(AT_FDCWD, "/usr/local/lib/libjemalloc.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\340b\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=4887824, ...}) = 0
mmap(NULL, 1113224, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xffffaa020000
mmap(0xffffaa090000, 131072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x60000) = 0xffffaa090000