Skip to content

Instantly share code, notes, and snippets.

View nickva's full-sized avatar

Nick Vatamaniuc nickva

  • USA
View GitHub Profile
@nickva
nickva / dist_perf.erl
Last active April 13, 2022 20:59
Erlang Distribution Protocol Benchmark
%
% $ erl -name [email protected]
%
% $ erl -name [email protected]
% ([email protected])2> dist_perf:go('[email protected]').
% started
% Sent:953MB/s, Hist:{6,0,0,12,0,0,0,0,0,0,0} RHist:{0,0,0,0,0,0,0,0,0,97,0}
% Sent:961MB/s, Hist:{1,0,0,12,0,0,0,0,0,0,0} RHist:{0,0,0,0,0,0,0,0,0,155,0}
% Sent:953MB/s, Hist:{6,0,0,12,0,0,0,0,0,0,0} RHist:{0,0,0,0,0,0,0,0,0,202,0}
%
@nickva
nickva / perfparams.py
Last active June 26, 2024 10:27
perfparams - convert a simple .conf file to couchdb .ini and vm.args files
#!/usr/bin/env python3
import optparse
from dataclasses import dataclass
from collections import defaultdict
@dataclass
class Param:
name: str
@nickva
nickva / sorting.sh
Created June 10, 2022 19:56
Sorting an already sorted list in Erlang
% ./erlperf \
'runner(Unsorted) -> lists:sort(Unsorted).' \
--init_runner '[{rand:uniform(), I} || I <- lists:seq(1,500)].' \
'runner(Sorted) -> lists:sort(Sorted).' \
--init_runner 'lists:sort([{rand:uniform(), I} || I <- lists:seq(1,500)]).'
Code || QPS Time Rel
runner(Sorted) -> lists:sort(Sorted). 1 69223 14446 ns 100%
runner(Unsorted) -> lists:sort(Unsorted). 1 7158 140 us 10%
@nickva
nickva / purgesh.sh
Created June 22, 2022 05:16
Add some views and docs then purge files
#!/bin/sh
http delete $DB/db
http put $DB/db'?q=4'
http put $DB/db/_design/d views:='{"v": {"map":"function(doc){emit(doc._id, 42);}"}}'
http put $DB/db/x a=b
http put $DB/db/y a=b
http put $DB/db/z a=b
@nickva
nickva / large_doc_compact.sh
Created November 11, 2022 20:04
couchdb smoosh doesn't trigger compaction
#!/bin/bash
set -e
URL=http://adm:pass@localhost:15984
DB=${URL}/dbx
CFG=${URL}/_node/_local/_config
DOC=doc1
TMPFILE=/tmp/couch_largehex
@nickva
nickva / large_doc_compact_multiple_updates.sh
Created November 13, 2022 04:00
CouchDB doc update and delete script
#!/bin/bash
set -e
URL=http://adm:pass@localhost:15984
DB=${URL}/dbx
CFG=${URL}/_node/_local/_config
TMPFILE=/tmp/couch_largehex
DOCSIZE=100
@nickva
nickva / dbcreate.py
Created November 28, 2022 18:08
Apache CouchDB DB Stampede
#!/usr/bin/env python
# Uses CouchDB (pip install CouchDB)
import sys, couchdb, time, os, uuid, argparse, random, traceback
from multiprocessing.dummy import Pool as ThreadPool
DB_URLS = [
'http://adm:pass@localhost:15984',
'http://adm:pass@localhost:25984',
@nickva
nickva / viewsize.py
Last active December 7, 2022 18:37
CouchDB View Benchmark
#!/usr/bin/env python
# still python2, sorry, old script
# pip install CouchDB
# ./viewsize.py
# file active external dtavg
# 18080120 17607050 14984706 45.973
import argparse
import sys
@nickva
nickva / playing_around.erl
Created December 23, 2022 19:35
Luerl for CouchDB Views
1> application:start(luerl),
1> F1 = "function(doc) emit('key1', doc) \n emit('key2', 'val2') end",
1> F2 = "function(doc) emit('key3', 'val3') end",
1> S0 = luerl_sandbox:init(),
1> {_, S1} = luerl:do("emits = {} \n function emit(k, v) \n table.insert(emits, {k, v}) end", S0),
1> {ok, C1, S2} = luerl:load("f = " ++ F1 ++ " \n f(...) \n return emits", S1),
1> {ok, C2, S3} = luerl:load("f = " ++ F2 ++ " \n f(...) \n return emits", S2),
1> {R1, _} = luerl:call_chunk(C1, [#{<<"_id">> => <<"1">>, <<"a">> => <<"b">>}], S3),
1> {R2, _} = luerl:call_chunk(C2, [#{<<"_id">> => <<"1">>, <<"a">> => <<"b">>}], S3),
1> #{<<"r1">> => R1, <<"r2">> => R2}.
@nickva
nickva / xref_custom.erl
Created January 5, 2023 20:03
Run Erlang XRef Ignoring Some Modules
xref:stop(s).
xref:start(s).
xref:set_default(s, [{verbose, false}, {warnings, false}]).
xref:add_release(s, "./src").
xref:add_release(s, code:lib_dir(), {name, otp}).
f().
IgnorePrefixes = [
"hipe", "ibrowse", "hyper", "meck", "metrics", "parse_trans", "eunit_test", "hackney",