viirya commented on PR #55839: URL: https://github.com/apache/spark/pull/55839#issuecomment-5163020864
Following up on the efficiency point — one refinement worth calling out for the follow-up: the more impactful part isn't just the O(n^2) CPU, it's that `removeStageFromCache`'s full `stageCache` scan runs *inside* `withStageLifecycleLock` (once per obsolete stage), and that same lock guards the exchange-reuse path in `createNonResultQueryStages`. So a many-exchange replan lengthens the critical section and makes concurrent subquery/exchange-reuse acquisitions wait longer, not just burn driver CPU. (Minor precision: the `newStages.exists(...)` filter itself is outside the lock — it's the per-obsolete-stage full-cache scan that's inside it.) So the cleanest fix is to precompute the retained ids / shared-`resultOption` identities and the set of cache keys to drop *outside* the lock, and inside the lock do only the minimal mutation (remove the precomputed keys + cancel) in a single pass. Still non-blocking — just noting the lock-contention angle so the follow-up targets the critical section, not only the asymptotics. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
