Skip to content

Instantly share code, notes, and snippets.

Simon Hardy-Francis simonhf

Block or report user

Report or block simonhf

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
simonhf /
Last active Jul 26, 2019
C vs Golang in the context of run time performance considering compile time optimization ability with constant folding for debugging

Let's say you know C and are thinking about learning Golang. Let's also say that you prefer not to use a debugger [1]. This probably means you need to create a debug version of your Golang code. A way to do that is with constant folding [2], for example:

const constDebug = 0

if (1 == constDebug) { debugCode() } // if() compiled away due to constant folding
simonhf /
Last active May 21, 2019
C versus CPP versus Java; the performance failings of naive OO
//package com.dnene.josephus;
// $ javac && java Chain
public class Chain
private Person first = null;
public Chain(int size)
simonhf / cache-line-example.c
Last active Apr 21, 2018
Experiment with __builtin_prefetch()
View cache-line-example.c
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/time.h>
#include <locale.h>
#define NUMBYTES (1024*1024*1024)
char bytes[NUMBYTES];
simonhf / 1-cache-line.c
Last active Oct 26, 2016
1 cache line fetch per hash table read simulation experimentation lab
View 1-cache-line.c
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <sys/mman.h>
#include <sys/time.h>
#include <unistd.h>
#include <murmurhash3.h>
// gcc -O3 -I. -o 1-cache-line 1-cache-line.c murmurhash3.c && ./1-cache-line
simonhf / hardest.c
Last active Jan 2, 2018
experiments with tarantool transactions, fibers, and C box_insert (because Lua string performance sucks)
View hardest.c
#include "module.h"
#define MP_SOURCE 1 /* define in a single .c/.cc file */
#include "msgpuck.h"
// CPATH=/usr/include/tarantool/:/usr/include/ gcc -shared -o -fPIC hardest.c
char * key_format = "the quick brown fox jumped over the lazy dog the qu %07u ick brown fox ";
char * field_2 = "'{\"0\":{\"1234567890\": 320, \"1234567890\": 1303}}'";
simonhf /
Last active Sep 10, 2015 — forked from CAFxX/
Persistent pipes/circular buffers for Linux

Persistent "pipes" in Linux

In a project I'm working on I ran into the requirement of having some sort of persistent FIFO buffer or pipe in Linux, i.e. something file-like that could accept writes from a process and persist it to disk until a second process reads (and acknowledges) it. The persistence should be both across process restarts as well as OS restarts.

AFAICT unfortunately in the Linux world such a primitive does not exist (named pipes/FIFOs do not persist

simonhf / -
Last active Aug 29, 2015 — forked from anonymous/-
View -
MongoDB shell version: 2.6.5
connecting to: lichess
"_id" : "rynNl407",
"p1" : {
"ai" : 8
"s" : 31,
simonhf / main.c
Created Aug 12, 2014
How to use macros to name unique variables?
View main.c
#include <stdio.h>
#define TOKENPASTE2(x, y) x ## y
#define TOKENPASTE(x, y) TOKENPASTE2(x, y)
#define FOO TOKENPASTE(var_, __LINE__)
#define BAR __LINE__
simonhf / lmdb-perf-test.txt
Created Mar 21, 2014
Performance testing lmdb with 16 concurrent processes & 70 million keys
View lmdb-perf-test.txt
# # ssh to Rackspace 16 vCPU box to perf test lmdb
# # try to do a similar multi-process test to the one at
# # note: could not figure out how to insert more that 70 million keys; other test inserts 100 million keys
# # note: created lmdb hash file on /dev/shm to make it a fairer test
# # note: as you can see below, inserting is extremely slow but lmdb only claims that reading is lighting fast :-)
# # note: the 'mix' 2% update, 98% read test shows that read performance gets bogged down if reading & writing :-(
# # note: not sure if I am using the lmdb API is the optimum way so please forgive me & suggest changes!
# # note: comments to please
# apt-get update
# apt-get install build-essential
You can’t perform that action at this time.