Skip to content

Use ProcessPoolExecutor instead of ThreadPoolExecutor. #250

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

Open
wants to merge 1 commit into
base: main
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
4 changes: 2 additions & 2 deletions refresh.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -1142,8 +1142,8 @@ def _convert_compile_commands(aquery_output):

# Process each action from Bazelisms -> file paths and their clang commands
# Threads instead of processes because most of the execution time is farmed out to subprocesses. No need to sidestep the GIL. Might change after https://github.com/clangd/clangd/issues/123 resolved
with concurrent.futures.ThreadPoolExecutor(
max_workers=min(32, (os.cpu_count() or 1) + 4) # Backport. Default in MIN_PY=3.8. See "using very large resources implicitly on many-core machines" in https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.ThreadPoolExecutor
with concurrent.futures.ProcessPoolExecutor(
max_workers=os.cpu_count() # Default before Python 3.13, after which it is os.process_cpu_count().
) as threadpool:
outputs = threadpool.map(_get_cpp_command_for_files, aquery_output.actions)

Expand Down