-
Notifications
You must be signed in to change notification settings - Fork 485
Open
Labels
Description
Problem
Manticore's multiprocessing capabilities are limited on macOS due to platform differences:
- Linux uses
fork()
for fast process creation with copy-on-write memory - macOS has deprecated
fork()
due to safety issues, must usespawn()
which is slower - Default workaround: Manticore defaults to threading on macOS, limiting parallelism due to Python's GIL
Solution Implemented
We've added support for spawn-based multiprocessing on macOS. While not as fast as Linux's fork, it provides true parallelism and can be significantly faster than threading for CPU-bound workloads.
Usage
Command Line
manticore --core.mprocessing=multiprocessing your_contract.sol
Configuration File (.manticore.yaml)
core:
mprocessing: multiprocessing
procs: 4 # Number of worker processes
Python API
from manticore import config
config.get_group("core").mprocessing = "multiprocessing"
Performance Expectations
Mode | Best For |
---|---|
threading (macOS default) | Small explorations, I/O-bound tasks |
multiprocessing (with spawn) | Large explorations, CPU-bound tasks |
single | Debugging, small problems |
Typical speedups for CPU-intensive symbolic execution:
- Small contracts (<100 states): Threading may be faster
- Medium contracts (100-1000 states): Multiprocessing ~1.5-2x faster
- Large contracts (>1000 states): Multiprocessing ~2-4x faster
Limitations
- Spawn overhead: Each worker must reimport modules (~1-2 seconds startup)
- Serialization: All shared state must be pickle-able
- Memory usage: Each process has its own Python interpreter
Recommendations
- For best performance: Use Linux (native or Docker/VM)
- On macOS with large problems: Try multiprocessing mode
- For quick tests: Default threading mode is fine
- For debugging: Use single mode
Future Improvements
Potential optimizations to explore:
- Ray or Dask for better serialization handling
- Process pools to reuse workers
- Shared memory for large readonly data
- Native extensions to avoid GIL