Documentation

Level 3: Multicore Parallelism

Level 3 provides true parallelism by bypassing Python's GIL.

Overview

AspectValue
Startup Overhead~500ms (pool initialization)
Per-Call Overhead~100μs
Memory~100MB
Best ForCPU-bound parallel work

Parallelism Mechanisms

Python 3.12+: Sub-interpreters

  • Each sub-interpreter has its own GIL
  • Lower memory overhead than processes
  • Faster startup than ProcessPool

Python 3.9-3.11: ProcessPool

  • Separate processes bypass GIL
  • Higher memory overhead
  • Data serialization required

Enabling Level 3

import epochly
@epochly.optimize(level=3)
def parallel_compute(data):
return [x ** 2 for x in data]

Speedup Expectations

Core CountTypical Speedup
4 cores2–3x
8 cores4–6x
16 cores8–12x
32 cores14–20x

When Level 3 Helps

  • Data-parallel loops
  • Independent calculations
  • Map operations
  • Large dataset processing (> 100K items)

When Level 3 Does Not Help

  • Small data (< 100K items)
  • Sequential dependencies
  • Frequent small operations