Parallelize flow compilation on submission path#4175
Open
DaisyModi wants to merge 3 commits intoapache:masterfrom
Open
Parallelize flow compilation on submission path#4175DaisyModi wants to merge 3 commits intoapache:masterfrom
DaisyModi wants to merge 3 commits intoapache:masterfrom
Conversation
Flow compilation happens twice: on submission and on execution. The execution path already runs on a thread pool of size 3 (DagProcessingEngine), but the submission path was serialized by a synchronized block in SpecCatalogListenersList.onAddSpec() and a single-thread executor in CallbacksDispatcher. This change removes the synchronized keyword from onAddSpec() and replaces the single-thread executor with a configurable thread pool (default 3 threads), allowing multiple flows to compile in parallel during submission. Compilation is still serialized per flow but multiple flows now compile concurrently. The thread pool size is configurable via: gobblin.service.specCatalogListener.numThreads (default: 3) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace Executors.newFixedThreadPool (unbounded queue) with a bounded ThreadPoolExecutor to prevent memory growth under heavy submission load. Queue capacity is set to numThreads * 10 with CallerRunsPolicy so that when the queue is full, the submitting thread runs the compilation itself, providing natural backpressure. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add inline comment in FlowCatalog explaining why the submission path is now parallelized and Javadoc on the new SpecCatalogListenersList constructor documenting the design decision and thread-safety reasoning. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dear Gobblin maintainers,
Please accept this PR. I understand that it will not be reviewed until I have checked off all the steps below!
JIRA
Description
Every flow gets compiled twice — once on submission and once on execution. The execution path already runs on a thread pool of size 3 (
DagProcessingEngine), proving thatcompileFlow()is thread-safe. However, the submission path was fully serialized by:synchronizedblock onSpecCatalogListenersList.onAddSpec()CallbacksDispatcherThis caused unnecessary queuing when multiple flows were submitted simultaneously.
Changes:
synchronizedfromSpecCatalogListenersList.onAddSpec()to allow concurrent flow compilationsSpecCatalogListenersListthat accepts anExecutorServiceFlowCatalogto create a configurableFixedThreadPool(default: 3 threads) viagobblin.service.specCatalogListener.numThreadsSafety:
onDeleteSpec/onUpdateSpecremainsynchronized(topology changes are infrequent)addListener/removeListenerremainsynchronizedtopologySpecMapis aConcurrentMap— safe for concurrent readsDagProcessingEnginewith 3 threads) already validatescompileFlow()thread-safetyTests
DagProcessingEngine) which runscompileFlow()from 3 concurrent threads. ExistingFlowCatalogTestandMultiHopFlowCompilerTestcover the compilation flow.Commits