Skip to content

Instantly share code, notes, and snippets.

View hugosenari's full-sized avatar
🌞

Hugo Sena Ribeiro hugosenari

🌞
View GitHub Profile
@hugosenari
hugosenari / paraugol-lang.md
Created June 8, 2024 06:32
Draft of a parallel programing language

Paraugol

One syntax to write parallel algorithms.

Origins

This syntax comes from the observation that arrays are representation of sequences, but sequences could be represented by linkded list or trees.

In this case, if we draw a tree like this:

This Idea:

Use nimscripter with libssh to compile a code that uploads itself and a script to a server than run it.

Objective:

Make a portable remote commander.

@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