Skip to content

Instantly share code, notes, and snippets.

View hugosenari's full-sized avatar
🌞

Hugo Sena Ribeiro hugosenari

🌞
View GitHub Profile
@hugosenari
hugosenari / eBPFOpCodes.nim
Last active April 18, 2024 00:38
all eBPF Operations
type
OpCode = enum
LOAD_IMME_IMMEDI_32_BITS = (000, "LOAD_IMME | SIZE_32 | IMMEDI = 0x00"),
LOAD_SRC_IMMEDI_32_BITS = (001, "LOAD_SRC | SIZE_32 | IMMEDI = 0x01"),
STORE_IMME_IMMEDI_32_BITS = (002, "STORE_IMME | SIZE_32 | IMMEDI = 0x02"),
STORE_SRC_IMMEDI_32_BITS = (003, "STORE_SRC | SIZE_32 | IMMEDI = 0x03"),
ADD_IMM_32_BITS = (004, "ADD | IMM | MATH_32 = 0x04"),
GO_TO_IMM = (005, "GO_TO | IMM | JUMP_64 = 0x05"),
ADD_IMM_64_BITS = (007, "ADD | IMM | MATH_64 = 0x07"),
LOAD_IMME_IMMEDI_16_BITS = (008, "LOAD_IMME | SIZE_16 | IMMEDI = 0x08"),
@hugosenari
hugosenari / Pragmas.md
Last active March 20, 2024 19:43
Pragma Helper
Identity Closed Pure Associative Commutative Feature
NoOP early return of X
Memoise early return cache
Idempotent early return cache
Map No need to define
Reduce No need to define
ParMap Parallel Map
ParReduce
@hugosenari
hugosenari / memcopybench.nim
Created November 2, 2023 16:42
CopyMen Size Bench
import std/[macros, monotimes, strformat, strutils, times]
# source
# https://github.com/timotheecour/Nim/blob/94a32119cb5eeeff2a825dc29cbbe60accb6432e/lib/std/cputicks.nim
##[
Experimental API, subject to change.
]##
#[
@hugosenari
hugosenari / apr_env_get.txt
Created October 19, 2023 03:12
svn env vars
subversion-1.14.2/subversion/libsvn_subr/user.c: apr_env_get(... "HOME" ...)
subversion-1.14.2/subversion/libsvn_subr/cmdline.c: apr_env_get(... "SVN_EDITOR" ...)
subversion-1.14.2/subversion/libsvn_subr/cmdline.c: apr_env_get(... "VISUAL" ...)
subversion-1.14.2/subversion/libsvn_subr/cmdline.c: apr_env_get(... "EDITOR" ...)
subversion-1.14.2/subversion/svn/util.c: apr_env_get(... "SVN_MERGE" ...)
@hugosenari
hugosenari / cascli.nim
Last active September 20, 2023 15:27
Nim cassandra cli example
# Requires: cassandra wrapper https://github.com/yglukhov/cassandra
#
# Expect a query from stdin
# printf "SELECT cql_version FROM system.local"|./cascli
#
# Fist parameter is config file name, default is clascli.ini
# Example:
# [cassandra]
# ips=127.0.0.1
# user=cass_user
@hugosenari
hugosenari / malebogia-spin.csv
Last active September 8, 2023 16:29
Malebolgia PR19 vs SpinLocks
OP T0E0 T0E1 T1E0 T1E1 T2E0 T0E1-T0E0 T1E0-T0E1
count 100 100 100 100 100 100 100 100
mean 88 60161 60196 83309 83346 119640 35 23149
std 49 158756 158759 203086 203090 301369 17 67967
min 42 1238 1267 3385 3412 5622 23 866
25% 60 5089 5118 10852 10882 16680 25 2020
50% 73 13457 13485 23656 23685 30790 30 4886
75% 94 32269 32302 55943 55978 94389 38 13003
max 295 999287 999349 1570617 1570679 2244872 128 571330
@hugosenari
hugosenari / PR19.tsv
Last active August 31, 2023 05:45
Nessie vs PR19
OP T0E0 T0E1 T1E0 T1E1 T2E0 T0E1-T0E0 T1E0-T0E1
53 20051 20141 21110 21162 21489 90 1021
38 9689 9807 10563 10622 11029 118 815
40 33800 33857 34065 34103 34310 57 246
60 11960 12000 12304 12344 12524 40 344
39 24083 24123 24413 24453 24632 40 330
41 10385 10535 11253 11309 11496 150 774
40 20820 20877 21188 21245 22507 57 368
39 9352 9392 9776 9815 9992 40 423
41 21047 21086 21463 21505 21682 39 419
@hugosenari
hugosenari / 256ops_128spawns_8threads.csv
Last active September 15, 2023 05:12
For smallest op how expensive is another thread vs same thread
count mean std min 25% 50% 75% max
Setup 1000 83 36 54 76 78 83 668
Serial 1000 28 5 22 25 26 30 106
Spwn0000E0 - Epoch 1000 7505 5537 2999 4156 6041 10329 111353
Spwn0001E0 - Epoch 1000 8931 5624 3574 5349 8424 11697 112437
Spwn0002E0 - Epoch 1000 9988 5694 3945 6388 9635 12703 113501
Spwn0003E0 - Epoch 1000 10930 5793 4007 7318 10755 13671 113359
Spwn0004E0 - Epoch 1000 12146 6002 5510 8388 12125 14658 118282
Spwn0005E0 - Epoch 1000 14336 6379 6325 10317 14129 16290 119504
Spwn0006E0 - Epoch 1000 16807 7572 8382 12575 16036 18738 125174
@hugosenari
hugosenari / flake.nix
Last active July 6, 2023 21:33
NixOS Flake Template
{
description = "NixOS Flakes Template";
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
outputs = inputs: {
nixosConfigurations.HOSTNAME = inputs.nixpkgs.lib.nixosSystem {
modules = [ ./configuration.nix ];
system = "x86_64-linux";
};
};
@hugosenari
hugosenari / lsof.txt
Created May 24, 2023 23:52
nixos rebuild files
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nixos-reb 3237568 root cwd DIR 259,2 4096 14814237 /home/hugosenari/Code/nixos-config
nixos-reb 3237568 root rtd DIR 259,2 4096 2 /
nixos-reb 3237568 root txt REG 259,2 987864 6423924 /nix/store/gsnqgx5ai6czlqjipiawc5x8c4bv2ndj-bash-5.1-p16/bin/bash
nixos-reb 3237568 root mem REG 259,2 3059040 6051885 /nix/store/h68xxa8rkns0cm15vmypr41wnm18320g-glibc-locales-2.35-224/lib/locale/locale-archive
nixos-reb 3237568 root mem REG 259,2 2400600 6315581 /nix/store/3xwi7gsyzl3sy4cq2467gca9zdk8yz9r-glibc-2.35-224/lib/libc.so.6
nixos-reb 3237568 root mem REG 259,2 15616 6315588 /nix/store/3xwi7gsyzl3sy4cq2467gca9zdk8yz9r-glibc-2.35-224/lib/libdl.so.2
nixos-reb 3237568 root mem REG 259,2 250992 6315574 /nix/store/3xwi7gsyzl3sy4cq2467gca9zdk8yz9r-glibc-2.