Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python3
import sys
import asyncio
import greenlet
class AsyncIoGreenlet(greenlet.greenlet):
def __init__(self, driver, fn):
greenlet.greenlet.__init__(self, fn, driver)
self.driver = driver
(ns jepsen.ydb.serializable
(:require [elle.core :as elle]
[elle.list-append :as a]
[jepsen.history :as h]
[jepsen.checker :as checker]
[jepsen.tests.cycle.append :as append]
[bifurcan-clj [core :as b]]
[elle.graph :as g]
[elle.rels :as rels :refer [ww wr rw process realtime]]
[dom-top.core :refer [loopr]])
#!/usr/bin/python
# -*- encoding: utf-8 -*-
from __future__ import print_function
import time
import threading
import multiprocessing
from Queue import Queue
from multiprocessing import Queue as MPQueue
messages = (
@snaury
snaury / broker.go
Created May 16, 2012 21:28
Non-blocking fan-out broker in go
package main
import (
"fmt"
"time"
)
type Message struct {
Timestamp time.Time
Client *Client
@snaury
snaury / Program.cs
Created May 18, 2017 21:12
Trying to measure coreclr gc pauses under extreme pressure
using System;
using System.Threading;
using System.Diagnostics;
using System.Collections.Generic;
namespace hello_memory
{
class MyObject
{
public int value;
@snaury
snaury / benchmark.txt
Created March 7, 2017 21:18
Sub-millisecond GC pauses... if you don't allocate
$ time GODEBUG=gctrace=1 ./go-mem-stress
gc 1 @0.003s 2%: 0.045+5.7+0.032 ms clock, 0.13+0/0.68/5.2+0.098 ms cpu, 4->4->0 MB, 5 MB goal, 4 P
gc 2 @0.010s 2%: 0.009+11+0.041 ms clock, 0.036+0/0.75/10+0.16 ms cpu, 5->5->1 MB, 6 MB goal, 4 P
gc 3 @0.022s 3%: 0.004+12+0.031 ms clock, 0.018+0.021/3.0/9.6+0.12 ms cpu, 4->4->2 MB, 5 MB goal, 4 P
gc 4 @0.035s 4%: 0.010+19+0.060 ms clock, 0.041+0/3.8/16+0.24 ms cpu, 5->5->2 MB, 6 MB goal, 4 P
gc 5 @0.056s 3%: 0.005+16+0.023 ms clock, 0.020+0/1.3/15+0.092 ms cpu, 6->6->3 MB, 7 MB goal, 4 P
gc 6 @0.075s 3%: 0.007+19+0.042 ms clock, 0.029+0/3.0/16+0.16 ms cpu, 8->8->4 MB, 9 MB goal, 4 P
gc 7 @0.095s 5%: 2.6+25+0.025 ms clock, 10+0.094/3.2/0.043+0.10 ms cpu, 10->10->10 MB, 11 MB goal, 4 P
gc 8 @0.127s 4%: 0.009+45+0.046 ms clock, 0.037+0/5.1/40+0.18 ms cpu, 16->17->6 MB, 20 MB goal, 4 P
gc 9 @0.175s 4%: 0.008+41+0.071 ms clock, 0.032+0/2.9/38+0.28 ms cpu, 15->15->8 MB, 16 MB goal, 4 P
@snaury
snaury / CrashSignal.java
Created December 15, 2012 16:43
Crash java using sun.misc.SignalHandler.
import sun.misc.*;
public class CrashSignal {
public static void main(String[] args) {
Signal signal = new Signal("INT");
SignalHandler signalHandler = SignalHandler.SIG_IGN;
signalHandler.handle(signal);
}
#include <greenlet/greenlet.h>
@snaury
snaury / dnstest.erl
Created October 31, 2012 06:36
Work in progress
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -smp enable
-module(dnstest).
-mode(compile).
-record(dnsmsg, {id, qr, opcode, aa, tc, rd, ra, z, rcode,
questions, answers, authorities, extras, packet}).
-record(dnsquestion, {name, type, class}).
@snaury
snaury / README
Created October 27, 2012 20:36
Tests MongoDB/PostgreSQL performance under different concurrency settings
For PostgreSQL you'd need to increase your kernel shared memory quotas. For Mac OS X to set it to 40MBs do:
sudo sysctl -w kern.sysv.shmmax=41943040
sudo sysctl -w kern.sysv.shmall=10240
Then in mydb/postgresql.conf change:
max_connections = 128
More info here: