constantine/constantine/threadpool
Mamy Ratsimbazafy 0f9b9e9606
Parallel Ethereum protocols (BLS signature and KZG) (#279)
* BLS sig: parallel batch verification

* BLS: speedup parallel batch verify with Miller loops on local threads

* shutdown bench

* nit: import style

* implement parallel KZG

* Parallel KZG commitments

* add benchmarks of KZG

* rename protocol file

* small optim: reorder await

* fix rebase

* Faster parallel BLS verification

* fix commitment status replacing previous error in verify_blob_kzg_proof_batch_parallel

* 2x faster parallel EC sum for less than 8192 points
2023-10-06 09:58:20 +02:00
..
benchmarks Parallel Ethereum protocols (BLS signature and KZG) (#279) 2023-10-06 09:58:20 +02:00
crossthread Pasta / Halo2 MSM bench (#243) 2023-06-04 17:41:54 +02:00
demos/raytracing Parallel Ethereum protocols (BLS signature and KZG) (#279) 2023-10-06 09:58:20 +02:00
docs Path reorgs (#240) 2023-05-29 20:14:30 +02:00
examples Parallel Ethereum protocols (BLS signature and KZG) (#279) 2023-10-06 09:58:20 +02:00
primitives Expose OS-provided cryptographically secure RNG (#257) 2023-08-27 20:50:09 +02:00
README.md Path reorgs (#240) 2023-05-29 20:14:30 +02:00
instrumentation.nim Pasta / Halo2 MSM bench (#243) 2023-06-04 17:41:54 +02:00
parallel_offloading.nim Parallel Ethereum protocols (BLS signature and KZG) (#279) 2023-10-06 09:58:20 +02:00
partitioners.nim Path reorgs (#240) 2023-05-29 20:14:30 +02:00
threadpool.nim Parallel Ethereum protocols (BLS signature and KZG) (#279) 2023-10-06 09:58:20 +02:00

README.md

Constantine Threadpool

API

The API spec follows https://github.com/nim-lang/RFCs/issues/347#task-parallelism-api

Overview

This implements a lightweight, energy-efficient, easily auditable multithreaded threadpool.

This threadpool will desirable properties are:

  • Ease of auditing and maintenance.
  • Resource-efficient. Threads spindown to save power, low memory use.
  • Decent performance and scalability. The CPU should spent its time processing user workloads and not dealing with threadpool contention, latencies and overheads.

Compared to Weave, here are the tradeoffs:

  • Constantine's threadpool provides spawn/sync (task parallelism) and optimized parallelFor for (data parallelism).
    It however does not provide precise in/out dependencies (events / dataflow parallelism).
  • Constantine's threadpool has been significantly optimized to provide overhead lower than Weave's default (and as low as Weave "lazy" + "alloca" allocation scheme).

Compared to nim-taskpools, here are the tradeoffs:

  • Constantine does not use std/tasks:
    • No external dependencies at runtime (apart from compilers, OS and drivers)
    • We can replace Task with an intrusive linked list
    • Furthermore we can embed tasks in their future
  • Hence allocation/scheduler overhead is 3x less than nim-taskpools as we fuse the following allocations:
    • Task
    • The linked list of tasks
    • The future (Flowvar) result channel
  • Contention improvement, Constantine is entirely lock-free while Nim-taskpools need a lock+condition variable for putting threads to sleep
  • Powersaving improvement, threads sleep when awaiting for a task and there is no work available.
  • Scheduling improvement, Constantine's threadpool incorporate Weave's adaptative scheduling policy with additional enhancement (leapfrogging)

See also design.md