-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[improve][fn] Improve implementation for maxPendingAsyncRequests async concurrency limit when return type is CompletableFuture<Void> #23708
Merged
lhotari
merged 1 commit into
apache:master
from
lhotari:lh-improve-pf-async-concurrency-limit
Dec 17, 2024
Merged
Conversation
This file contains 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
…c concurrency limit
lhotari
force-pushed
the
lh-improve-pf-async-concurrency-limit
branch
from
December 10, 2024 23:05
bec9365
to
bc519d4
Compare
lhotari
changed the title
[improve][fn] Improve implementation for maxPendingAsyncRequests async concurrency limit
[improve][fn] Improve implementation for maxPendingAsyncRequests async concurrency limit when return type is CompletableFuture<Void>
Dec 10, 2024
lhotari
requested review from
merlimat,
eolivelli,
gaoran10,
nodece,
dao-jun,
david-streamlio,
cbornet,
freeznet,
heesung-sn and
jiazhai
December 11, 2024 09:03
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #23708 +/- ##
============================================
+ Coverage 73.57% 74.42% +0.85%
- Complexity 32624 35100 +2476
============================================
Files 1877 1945 +68
Lines 139502 147483 +7981
Branches 15299 16276 +977
============================================
+ Hits 102638 109768 +7130
- Misses 28908 29232 +324
- Partials 7956 8483 +527
Flags with carried forward coverage won't be shown. Click here to find out more.
|
nodece
approved these changes
Dec 17, 2024
nikhil-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Dec 19, 2024
…c concurrency limit when return type is CompletableFuture<Void> (apache#23708) (cherry picked from commit 8ad6777) (cherry picked from commit a8512e7)
nikhil-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Dec 21, 2024
…c concurrency limit when return type is CompletableFuture<Void> (apache#23708) (cherry picked from commit 8ad6777) (cherry picked from commit a8512e7)
srinath-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Dec 23, 2024
…c concurrency limit when return type is CompletableFuture<Void> (apache#23708) (cherry picked from commit 8ad6777) (cherry picked from commit a8512e7)
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
cherry-picked/branch-3.0
cherry-picked/branch-3.3
cherry-picked/branch-4.0
doc-not-needed
Your PR changes do not impact docs
ready-to-test
release/3.0.9
release/3.3.4
release/4.0.2
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.
Motivation
When using asynchronous functions in Pulsar Functions, concurrency needs to be limited to prevent unbounded resource consumption. This is currently handled by the
maxPendingAsyncRequests
configuration parameter (default value: 1000). Without such limits, asynchronous processing could lead to unbounded message consumption from input topics, potentially causing resource exhaustion (out-of-memory errors) and function crashes.However, the current implementation has a performance issue specifically for asynchronous functions that return
CompletableFuture<Void>
. In these cases, the current queue-based implementation introduces unnecessary processing delays when the concurrency limit is reached. In particular:Context.newOutputMessage(...).sendAsync()
to send messages to multiple topicsCompletableFuture<Void>
)Modifications
This PR improves the implementation by:
Semaphore
instead ofLinkedBlockingQueue
for concurrency limiting when the function's return type isCompletableFuture<Void>
JavaExecutionResult
class by removing unusedsystemException
fieldImplementation Details
CompletableFuture<Void>
return type through function configurationSemaphore
-based concurrency limiter that gets used when order preservation isn't neededThrowable
withnew Exception(t)
type of code.Testing
Added new unit test
testAsyncFunctionMaxPendingVoidResult()
that verifies:Documentation
doc
doc-required
doc-not-needed
doc-complete