Skip to content

Instantly share code, notes, and snippets.

View nickva's full-sized avatar

Nick Vatamaniuc nickva

  • USA
View GitHub Profile
@nickva
nickva / findlimit.py
Last active January 30, 2024 06:18
Mango execution stats checker
#!/usr/bin/env python
import json
import time
import requests
import string
import random
S = requests.session()
@nickva
nickva / chnagesrevtree.sh
Created January 4, 2024 22:56
Various changes feed parameters for Apache CouchDB
#!/bin/bash
http -q delete $DB/db
http -q put $DB/db
http post $DB/db/_bulk_docs new_edits:='false' docs:='[{"_id":"d1", "_revisions":{"start":2, "ids":["x", "z"]}, "data":1}, {"_id":"d1", "data":2, "_revisions":{"start":2, "ids":["y", "z"]}}, {"_id":"d1", "data":3, "_deleted":true, "_revisions":{"start":2, "ids":["w", "z"]}}]'
http -q put $DB/db/d1/att2y'?rev=2-y' data=2y
http -q put $DB/db/d1/att2x'?rev=2-x' data=2x
echo "Without a filter with atts"
@nickva
nickva / multiuser.py
Last active November 9, 2023 04:34
Test script to generate a lot of CouchDB regular and admin users
#!/usr/bin/env python
#
# make && ./dev/run -n 1 --admin=adm:pass
# ./multiuser.py --users-scheme=simple --users-salt="abc" --users-hash-sha1 --tries 100
import copy
import sys
import time
import threading
import os
@nickva
nickva / distblockleak.erl
Created November 7, 2023 06:17
Reproducer for a binary memory leak across a dist channel on OTP 24+
%
% $ erl -name otp252@127.0.0.1
% > c(distblockleak).
%
% $ erl -name otp251@127.0.0.1
% > c(distblockleak), distblockleak:go('otp252@127.0.0.1', "./junk.bin", 10000, 100, 200).
%
-module(distblockleak).
@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.
@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 / 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 / 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 / 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 / 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([