Repository navigation
[improve][fn] Run connectors extraction in parallel - #17902
Conversation
|
"Run search connectors in parallel" Isn't this completely generic? |
|
Oh, it seems that I misunderstood the naming.
"connector extraction" etc. would make more sense to me. |
eolivelli
left a comment
There was a problem hiding this comment.
Overall LGTM
I have left some suggestions
| ExecutorService oneTimeExecutor = null; | ||
| try { | ||
| int nThreads = Math.min(Runtime.getRuntime().availableProcessors(), archives.size()); | ||
| log.info("Loading {} connector definitions with a thread pool of size {}", archives.size(), nThreads); |
There was a problem hiding this comment.
We can log this at debug level. It is not useful.
Please add the if log.isDebugEnabled guard, as this is the code style in Pulsar for DEBUG statements
There was a problem hiding this comment.
I actually think the log is useful for troubleshooting no? Both # of connectors and # of CPU are variables, and if someone observes a long bootstrap time, we could quickly support them by ruling out the obvious (for example, they have 100 connectors but only single CPU...)
|
Side note for committer (@eolivelli @nicoloboschi) : Please update the commit message to match the PR title when merging,. |
|
Opened closed to trigger CI. |
…nectors thread pool
…ns/utils/io/ConnectorUtils.java Co-authored-by: Lari Hotari <[email protected]>
595f79b to
6f99bb6
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #17902 +/- ##
=============================================
+ Coverage 34.91% 46.64% +11.72%
- Complexity 5707 17814 +12107
=============================================
Files 607 1574 +967
Lines 53396 128331 +74935
Branches 5712 14115 +8403
=============================================
+ Hits 18644 59859 +41215
- Misses 32119 62317 +30198
- Partials 2633 6155 +3522
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Motivation
Improve functions worker bootstrap time with increased number of connectors. Currently all nar files are unpacked during startup to perform validation steps (e.g. if the connector class implements the correct interfaces). For that, the NarClassLoader will unpack all nars to disk sequentially which could delay startup.
On my Machine (Mac M1) I observed an improvement of ~ 3X (from 48 seconds down to 15 seconds). I know the max number of chosen threads (4) is a magic number (I have not seen improvements beyond that number), but if this is the right approach and it is worth it, we can make this number configurable (need guidance on the right config place)
Sample output:
Modifications
Just run the connectors search function (which unpacks the nars) in parallel via a CachedThreadPool.
Verifying this change
This change is already covered by existing tests, such as the unit tests under PulsarFunctionLocalRunTest already covers this path. Also CI for each existing connector will cover the change
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc-required(Your PR needs to update docs and you will update later)
doc-not-needed(Please explain why)
doc(Your PR contains doc changes)
doc-complete(Docs have been already added)
Matching PR in forked repository
PR in forked repository: (aymkhalil#2)
After opening this PR, the build in apache/pulsar will fail and instructions will
be provided for opening a PR in the PR author's forked repository.
apache/pulsar pull requests should be first tested in your own fork since the
apache/pulsar CI based on GitHub Actions has constrained resources and quota.
GitHub Actions provides separate quota for pull requests that are executed in
a forked repository.
The tests will be run in the forked repository until all PR review comments have
been handled, the tests pass and the PR is approved by a reviewer.
-->