apache / apache/pulsar-client-node
Improve Timing of Promise "then"
- 主要语言
- C++
- 星标
- 164
- 派生
- 98
- PR 合并指标
- 30 天内没有已合并 PR
描述
Currently, To measure latency of sending messages, asynchronous processing using Nodejs [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) like following code:
```
const results = [];
for (let mi = 0; mi < numOfMessages; mi += 1) {
const startSendTimeMilliSeconds = performance.now();
results.push(producer.send({
data: message,
}).then(() => {
// add latency
histogram.recordValue((performance.now() - startSendTimeMilliSeconds));
}));
}
await Promise.all(results); // wait until all messages are sent.
```
https://github.com/apache/pulsar-client-node/blob/master/perf/perf_producer.js#L88-L98
This code creates histogram about latency of sending messages.
However, all `then()` of `Promise` in `results` start after `await Promise.all(results)`.
So, We cannot get accurate histogram.
贡献指南
这个仓库没有索引到贡献指南
调研方向
从 perf/perf_producer.js 的第 88-98 行附近开始,检查 producer.send() 的 promise 和 Promise.all() 的使用方式。验证每个 then() 回调相对于 Promise.all() 的执行时机,然后让延迟直方图反映实际的消息发送 timing,并确认性能脚本仍能正确完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, node.js
- 领域
- performance
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100