-
Notifications
You must be signed in to change notification settings - Fork 318
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
performance optimization about CompletableFuture #107
Comments
我在ack 确认的任务中增加了许多log来确定耗时的问题,如下
在4ktps 写入下,当我观察log时 发现 2022-02-07 10:21:40 INFO QuorumAckChecker-n0 - partA 201 , partB 43 , partC 1133 , partD 2594866 , partE 73 , partF 148, ackNum 3 , pending size 231 有时partD 部分会超过1ms甚至到达3-5ms,parD 部分的代码为循环递减一个index 然后从ConcurrentHashMap 中remove 元素,(此时ConcurrentHashMap中的元素数量<1000),并且执行 future.complete(response);
|
i guess the most cost part may be the iteration of the ConcurrentHashMap. can we add iterate entry counter in the log ? i agree with the first point. and in the current RocketMQ use the |
pending size 206 is map size before loop .< 1000.Maybe it's caused by read-write locks and hash collisions. |
the concurrentHashMap will rehash the key hash code, even key is put continuously. hash collision won't be a problem. may be we can profile this case. and i wonder your write qps and the config for |
i think your idea is a good point to optimize dledger performance. and hope for more information from you. |
maxPendingRequestsNum is default 10000. |
Looking forward to your pull request |
in dledger ,Use a lot of CompletableFutures . But there is a problem,if you use thenAccept ,thenApply . the thread that executes the function is, Thread that executes complete.
在dledger 用了非常多的 CompletableFutures,但是CompletableFutures 有一个问题,就是如果用 thenAccept ,thenApply 这样的方法后,谁来执行回调函数呢,是调用future.complete方法的线程。
在如下例子中
打印值为
Thread[main,5,main]
thenApply
Thread[main,5,main]
thenAccept
执行回调函数的都是main 函数。
dledger 中CompletableFutures 往往都传递的很深,而执行 complete 都是一些单线程的任务,这部分线程资源非常珍贵。
列如发生消息流程中,我用arthas 观察执行回调函数的线程
watch *.StoreStatsService setPutMessageEntireTimeMax "@java.lang.Thread@currentThread().name" -x 1 -n 10
DefaultMessageStore 437 :
执行DefaultMessageStore 437 行代码的线程居然是 QuorumAckChecker-n0
QuorumAckChecker-n0 是master 用来同步消息的线程,是个单线程的任务。我觉得如此重要的线程资源用来执行这种回调函数是非常影响性能的
The text was updated successfully, but these errors were encountered: