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

perf: write with sleep if ringbuffer is full #15

Closed
wants to merge 1 commit into from

Conversation

rfyiamcool
Copy link
Contributor

@rfyiamcool rfyiamcool commented Apr 18, 2023

perf

当消费者处理数据过慢,或者本就是慢消费的任务类型,持续的慢消费造成 ringbuffer 队列已满,这样生产者无法写入,然后进行自旋的频繁调用 gosched 来切出调度资源,这样会引发 cpu 资源飙高。

  1. 增加了一个 writeSleep 接口,用户可选择性的 sleep 等待。
  2. 等待策略先 cpu pause 空指令,再执行 runtime.gosched 切换调度,最后执行 sleep 空闲等待。

@bruceshao 看下是否合理 ? 😁

@bruceshao
Copy link
Owner

暂不合入,我想想怎么让用户自由选择

@rfyiamcool
Copy link
Contributor Author

好的

@rfyiamcool
Copy link
Contributor Author

或者像 consumer block 策略那样,producer 也有一组 block 策略。

@bruceshao
Copy link
Owner

#18

@bruceshao
Copy link
Owner

这个就关了哈

@bruceshao bruceshao closed this May 11, 2023
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.

2 participants