Skip to content

Commit

Permalink
Avoid creating a process pool if we know we don't have any work for it.
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxColoring committed Dec 23, 2024
1 parent 35422b6 commit 05e5e1c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions robot-server/robot_server/persistence/_migrations/up_to_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ def _migrate_db_commands(
the work across subprocesses. Each subprocess extracts, migrates, and inserts
all of the commands for a single run.
"""
# Performance optimization: If we have nothing to migrate, don't even create the
# process pool. This avoids the heavy imports in the preload.
# On my laptop, this shaves ~1.5s off of each of our integration tests.
if not run_ids:
return

mp = multiprocessing.get_context("forkserver")
mp.set_forkserver_preload(_up_to_3_worker.imports)

Expand Down

0 comments on commit 05e5e1c

Please sign in to comment.