Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:

Mamy Ratsimbazafy mratsim

:shipit:
View GitHub Profile
@mratsim
mratsim / multipairing.nim
Created Aug 15, 2021
Testing BLS multipairing impl
View multipairing.nim
# Constantine
# Copyright (c) 2018-2019 Status Research & Development GmbH
# Copyright (c) 2020-Present Mamy André-Ratsimbazafy
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
import
# Standard library
@mratsim
mratsim / chase_lev_deque.nim
Created Jun 28, 2021
Debugging chase_lev_deques
View chase_lev_deque.nim
# Nim-Taskpools
# Copyright (c) 2021 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
# chase_lev_deques.nim
# --------------------
# This file implements a Chase-Lev deque
View Eventcounts.md

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

View batching_opportunities.md

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 Feb 10, 2021
GMP vs Assembly for ZKP
View mcl with gmp_mont
$ ./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 Jan 29, 2021
Stash constant-time decimal conversion for constantine
View README.md

Algorithms

Continued fractions

Continued fractions are used to convert

size_in_bits <=> size_in_decimal

for constant-time buffer preallocation when converting to decimal.

View bench.nim
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 Dec 22, 2020 — forked from MattPD/cpp.std.coroutines.draft.md
C++ links: Coroutines (WIP draft)
View cpp.std.coroutines.draft.md
@mratsim
mratsim / multithreading_flavors.md
Last active Dec 20, 2020
Draft - Multithreading flavors: Choosing the right scheduler for the right job.
View multithreading_flavors.md
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.

View 2020-12-17 Eth2 Call 54.md