-
Notifications
You must be signed in to change notification settings - Fork 461
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
WIP: feat: add foreach for zero copy #66
base: develop
Are you sure you want to change the base?
Conversation
想先问下,这个 API 是为了解析 HTTP header “\r\n” 吗? 关于这个问题,我们有这样的想法: view 1:
按照这个逻辑,应该鼓励使用 关于如何规避 copy view 2:
|
1、 其实也是考虑到peek会有跨节点的问题。这样违背了zero copy的特性。这个放到下层去做可以避免copy的问题。 |
|
嗯嗯, |
顺便问下,跨节点问题的草案是什么呢? |
嗯,这个我先标记了。我们的方案已经在安排测试了,表现还可以,等 pr 了我 link 过来。 |
|
chenchen.ccqy66 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
@Hchenn 如果用 Peek 来解析,只能用下面这种方法:
一方面实现起来比较晦涩,另一方面由于真实的数据是一个二维数组,而如果等 peek return 后再去遍历一个一维切片,中间做了很多无用功。考虑到用特殊字符间隔的上层协议(http,mysql)其实挺多的,所以觉得还是有必要内置一个类似 bufio.ReadSilce 的接口:#91 |
Reader
接口增加新apiForEachByte()
。使用场景如下:
使用示例: