Skip to content

Instantly share code, notes, and snippets.

View mratsim's full-sized avatar
:shipit:

Mamy Ratsimbazafy mratsim

:shipit:
  • Paris
View GitHub Profile
@mratsim
mratsim / Eventcounts.md
Last active November 19, 2023 13:52
Eventcounts

Eventcounts are "lock-free condition variables".

The lock acquisition is removed from the hot path, significantly reducing contention and overhead.

Eventcounts were pioneered by Chris Thomasson and Dmitry Vyukov (from Go multithreading runtime, LLVM thread sanitizer, Relacy Race Detector and Eigen/Tensorflow multithreading runtime).

Production

Batching opportunities overviews

Recap

aggregate != batching

An aggregate is spec-defined, for a receiver:

  • the signature is received aggregated from the network
  • the attesters public key must be aggregated (on BLS G1)
  • only attestations are aggregated
@mratsim
mratsim / mcl with gmp_mont
Created February 10, 2021 15:31
GMP vs Assembly for ZKP
$ ./bin/bls12_test.exe -m gmp_mont
JIT 1
ctest:module=size
ctest:module=naive
i=0 curve=BLS12_381
G1
G2
GT
G1::mulCT 656.335Kclk
G1::mul 584.777Kclk
@mratsim
mratsim / README.md
Last active January 29, 2021 00:02
Stash constant-time decimal conversion for constantine

Algorithms

Continued fractions

Continued fractions are used to convert

size_in_bits <=> size_in_decimal

for constant-time buffer preallocation when converting to decimal.

import benchy, random, streams
import jsony, jason
import eminim
#import packedjson, packedjson/deserialiser
import json
import serialization
import json_serialization except Json, toJson
type Node = ref object
active: bool
@mratsim
mratsim / cpp.std.coroutines.draft.md
Created December 22, 2020 15:25 — forked from MattPD/cpp.std.coroutines.draft.md
C++ links: Coroutines (WIP draft)
@mratsim
mratsim / multithreading_flavors.md
Last active December 20, 2020 11:31
Draft - Multithreading flavors: Choosing the right scheduler for the right job.
title author excerpt
Multithreading flavors: Choosing the right scheduler for the right job.
Mamy Ratsimbazafy (mratsim)
Demystifying multithreading for IO and multithreading for Compute.

_Disclaimer: This post represent my current understanding as of December 2020 and might not age well.

With the advent of multicores CPU, developers are urge to blast through performance bottlenecks by exploiting more cores. Hence we are attracted to multithreading solutions like light is attracted by a black hole.

func dacPairing[HashLen](
sigsets: ptr UncheckedArray[SignatureSet[HashLen]],
contexts: ptr UncheckedArray[ContextMultiAggregateVerify[DST]],
numBatches: uint32,
batchID: uint32,
subsetStart: uint32,
subsetStopEx: uint32
): bool =
## Distribute pairing computation using a recursive divide-and-conquer (DAC) algorithm