Skip to content
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

optimize StreamUtil and fix the LimitingExecutor #550

Closed

Conversation

xiaoyu-yang-gh
Copy link
Collaborator

@xiaoyu-yang-gh xiaoyu-yang-gh commented Feb 15, 2024

(1) #548 fixed the issue to execute mapper function to each batch in the thread-pool. but the batches are still executed sequentially. We need to fix the issues to have the batches executed in parallel. Here we implement a Collector:
- the accumulate method collect data from original stream, create batches, and submit jobs for executing each batch to thread-pool.
- the finisher method handles the last batch, submit the job for the last batch to thread-pool. It also connect the result for the jobs executed in the thread-pool, combine the results, and stream the results.

Tested this can execute the batches in the thread-pool in parallel.

(2) Fix LimitingExecutor. LimitingExecutor use a Semaphore to control the maximum number of jobs concurrently executed in the thread-pool. But the Semaphore is just used to guard the ThreadPool.execute(command), and the ThreadPool.execute just submit the job to the threadpool. So the Semaphore does not guard the number of jobs concurrently running in the pool. We fix this issue by:
a. require a Semaphore when submitting a new job;
b. release a Semaphore when a job completes;

@xiaoyu-yang-gh xiaoyu-yang-gh marked this pull request as draft February 15, 2024 23:14
@codecov-commenter
Copy link

codecov-commenter commented Feb 15, 2024

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (9f838a0) 46.19% compared to head (61aa961) 46.29%.

Files Patch % Lines
...om/linkedin/avroutil1/builder/util/StreamUtil.java 83.33% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #550      +/-   ##
============================================
+ Coverage     46.19%   46.29%   +0.09%     
- Complexity     4548     4550       +2     
============================================
  Files           407      407              
  Lines         28443    28455      +12     
  Branches       4642     4643       +1     
============================================
+ Hits          13140    13172      +32     
+ Misses        13731    13715      -16     
+ Partials       1572     1568       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@xiaoyu-yang-gh xiaoyu-yang-gh marked this pull request as ready for review February 15, 2024 23:59
@xiaoyu-yang-gh xiaoyu-yang-gh marked this pull request as draft February 16, 2024 01:06
@xiaoyu-yang-gh xiaoyu-yang-gh marked this pull request as ready for review February 16, 2024 02:32
@xiaoyu-yang-gh
Copy link
Collaborator Author

Close this PR.

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.

3 participants