Skip to content

Instantly share code, notes, and snippets.

View nickva's full-sized avatar

Nick Vatamaniuc nickva

  • USA
View GitHub Profile
@nickva
nickva / quickjs_vs_sm91.md
Created February 27, 2023 19:58
Overhead comparison QuickJS vs Spidermonkey 91. Measure process startup and context init

Spidermonkey (91), QuickJS (2021-03-27)

Intel MacOS SM91

% ./configure --dev --spidermonkey-version 91 && make
% TIMEFMT=$'Total (sec): \t%*E\nMax RSS(kb): \t%M\n'
% time ./couchjs
@nickva
nickva / fixalloc.erl
Last active August 29, 2024 12:24
Erlang 24 and 25 fix_alloc memory leak
%
% Run on Erlang 24+
%
% (MFatags true is to enable instrumentation for fix_alloc)
%
% $ erl -name [email protected] +MFatags true
% ([email protected])>
%
% $ erl -name [email protected] +MFatags true
% ([email protected])2> c(fixalloc), fixalloc:go('[email protected]').
@nickva
nickva / distbench.erl
Last active September 7, 2023 15:30
Ping-pong across dist with N parallel workers
%
% $ erl -name [email protected]
%
% $ erl -name [email protected]
% ([email protected])2> dist_perf:go('[email protected]').
-module(distbench).
-export([go/1, go/2, go/3, stop/0, gc/0, stats/1]).
@nickva
nickva / filebench.erl
Last active May 9, 2023 04:08
Silly benchmark reading a block in a loop and measuring the average across multiple runs
%> filebench:all("...data.../filebench.couch").
% * bsize: 65536 pread: 11 couch_file pread: 74 write: 465 couch_file append_bin: 477
% * bsize: 16384 pread: 8 couch_file pread: 49 write: 218 couch_file append_bin: 277
% * bsize: 4096 pread: 9 couch_file pread: 41 write: 197 couch_file append_bin: 236
% * bsize: 1024 pread: 11 couch_file pread: 37 write: 183 couch_file append_bin: 222
%
-module(filebench).
@nickva
nickva / fbench.erl
Last active May 9, 2023 04:00
Silly CouchDB fabric benchmark
-module(fbench).
% fbench:bench().
% * created db fbench-1683604564287312344 [{q,64},{n,3}] in 17869 usec
% * put 200 docs with 2823 usec per op
% * get doc 20000X with 1157 usec per op
% * get security 20000X with 225 usec per op
% ok
-export([
@nickva
nickva / estone.erl
Created May 4, 2023 04:20
Estone benchmark from Erlang/OTP source.
-module(estone).
% Copied form OTP erts/emulator/test/estone_SUITE.erl
% run with estone:estone(). May take a few minutes to run.
%
-export([estone/0]).
%% Internal exports for EStone tests
-export([
@nickva
nickva / ringbench.erl
Created June 16, 2023 20:55
Erlang Ring Benchmark
-module(ringbench).
-export([go/2]).
go(M, N) when is_integer(M), M > 1, is_integer(N), N > 1 ->
io:format("~p processes, ~p messages~n", [N, M]),
T = erlang:monotonic_time(),
{FirstPid, FirstRef} = spawn_monitor(fun() -> first() end),
LastPid = lists:foldl(fun(_, Pid) -> spawn_link(fun() -> loop(Pid) end) end, FirstPid, lists:seq(2, N)),
io:format("processes spawned in ~p usec~n", [dt(T)]),
@nickva
nickva / statbench.erl
Created July 11, 2023 06:56
High concurrency CouchDB Metrics Update Benchmark
-module(statbench).
-export([
go_counter/2,
go_gauge/2,
go_hist/2
]).
go_counter(N, X) ->
go(N, X, fun upstat_counter/1).
@nickva
nickva / haproxyabrt.cfg
Created September 27, 2023 03:06
CouchDB Haproxy With Quick Client Disconnect
global
maxconn 10000
spread-checks 5
defaults
mode http
log global
option httplog
log stdout format raw local0
balance roundrobin
@nickva
nickva / ioblock.erl
Last active October 31, 2023 05:53
Reproducer attempt for process_info slowdown in OTP 25
%% Reproducer attempt for https://github.com/erlang/otp/issues/7801
%% It's supposed to model the couch_file.erl from Apache CouchDB
%%
%% Example run:
%% c(ioblock), ioblock:go("./junk.bin", 8192, 60, 4000).
%% - Create a temporary junk.bin file with 8GB of random data
%% - Spawn 60 gen_servers to handle preads from the file
%% - Spawn 4000 caller processes to call the servers with pread commands
%%
%% Note: run the first time without measuring to create the larger file.