Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use mprocessing config for evm report workers #2481

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions manticore/ethereum/manticore.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import logging
from multiprocessing import Queue, Process
from queue import Empty as EmptyQueue
from typing import Dict, Optional, Union
import threading
from typing import Callable, Dict, Optional, Tuple, Union
import io
import pyevmasm as EVMAsm
import random
Expand Down Expand Up @@ -1757,13 +1758,34 @@ def worker_finalize(q):
except EmptyQueue:
pass

class ReportWorkerSingle:
"""Run task in the current process and current thread"""

def __init__(self, target: Callable, args: Tuple) -> None:
self.target = target
self.args = args

def start(self) -> None:
self.target(*self.args)

def join(self) -> None:
pass

# Generate testcases for all but killed states
q = Queue()
for state_id in self._all_states:
# we need to remove -1 state before forking because it may be in memory
q.put(state_id)

report_workers = [Process(target=worker_finalize, args=(q,)) for _ in range(procs)]
core_consts = config.get_group("core")
report_workers = [
{
core_consts.mprocessing.single: ReportWorkerSingle,
core_consts.mprocessing.threading: threading.Thread,
core_consts.mprocessing.multiprocessing: Process,
}[core_consts.mprocessing](target=worker_finalize, args=(q,))
for _ in range(procs)
]
for proc in report_workers:
proc.start()

Expand Down