Skip to content

[SPARK-58021][CONNECT] Warm local server pool members before use - #57688

Open
ericm-db wants to merge 6 commits into
apache:masterfrom
ericm-db:local-connect-pool-warmup
Open

[SPARK-58021][CONNECT] Warm local server pool members before use#57688
ericm-db wants to merge 6 commits into
apache:masterfrom
ericm-db:local-connect-pool-warmup

Conversation

@ericm-db

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

This is layer 6 of the local Connect pool stack: #57684 -> #57685 -> #57686 -> #57687 -> #57102 -> this PR. Until the lower layers merge, GitHub shows their cumulative diff; the new review unit here is commit 275235cd137.

This layer adds optional JIT warmup for newly booted pool members:

  • attendants launch a bounded child process against each published server;
  • fixed synthetic queries warm JVM JIT and Spark codegen paths without creating persistent catalog state;
  • warmup stops immediately if the member is claimed and is killed after its timeout;
  • SPARK_LOCAL_CONNECT_POOL_WARMUP=0 disables it;
  • the internal --warm entry point runs the query set; and
  • the pool documentation explains the latency and memory trade-off.

Why are the changes needed?

A booted server avoids JVM and SparkContext startup, but its first real query can still pay JIT and code-generation costs. Keeping warmup separate from acquisition makes this optimization and its subprocess failure boundary optional and independently reviewable.

Does this PR introduce any user-facing change?

Yes, only for the experimental pool opt-in introduced by #57102. Pool members warm themselves by default before use. Set SPARK_LOCAL_CONNECT_POOL_WARMUP=0 to retain the booted-server behavior without synthetic queries. Behavior is unchanged when the pool opt-in is disabled.

How was this patch tested?

Added focused tests for environment parsing, termination of a warmup child after a member is claimed, and execution plus cleanup of the fixed query set. The full pool suite also covers sequential and concurrent clients against real local Connect servers.

python -m unittest -v pyspark.sql.tests.connect.test_connect_local_server_pool

All 22 tests passed. Ruff check, Ruff format check, and git diff --check also passed.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Fable 5) and OpenAI Codex (GPT-5)

ericm-db added 6 commits July 31, 2026 16:54
Expose the per-user runtime directory and startup seed configuration, and let LocalConnectServer start isolated daemons with an ephemeral port and precomputed configuration. Keep persistent-server reuse on the same launch path and add focused unit coverage.
@uros-b

uros-b commented Jul 31, 2026

Copy link
Copy Markdown
Member

Thank you @ericm-db! cc @HyukjinKwon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants