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

feat: support configurable I/O space to drain at a time in edge-trigg… #644

Closed

Conversation

lovefyf928
Copy link

@lovefyf928 lovefyf928 commented Oct 28, 2024

…ered mode(#643)

1. Are you opening this pull request for bug-fixes, optimizations or new feature?

new feature

2. Please describe how these code changes achieve your intention.

在eventloop_unix.go中将read/write函数中以前的maxBytesTransferET移除变更为了配置的值,对EdgeTriggeredIOSpace配置进行了初始化。

3. Please link to the relevant issues (if any).

#643

4. Which documentation changes (if any) need to be made/updated because of this PR?

4. Checklist

  • I have squashed all insignificant commits.
  • I have commented my code for explaining package types, values, functions, and non-obvious lines.
  • I have written unit tests and verified that all tests passes (if needed).
  • I have documented feature info on the README (only when this PR is adding a new feature).
  • (optional) I am willing to help maintain this change if there are issues with it later.

gnet.go Outdated
@@ -418,6 +418,8 @@ func (*BuiltinEventEngine) OnTick() (delay time.Duration, action Action) {
// MaxStreamBufferCap is the default buffer size for each stream-oriented connection(TCP/Unix).
var MaxStreamBufferCap = 64 * 1024 // 64KB

var DefaultEdgeTriggeredIOSpace = 1 << 20
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment for this new exported variable.

@@ -152,7 +150,7 @@ loop:
_, _ = c.inboundBuffer.Write(c.buffer)
c.buffer = c.buffer[:0]

if c.isEOF || (isET && recv < maxBytesTransferET) {
if c.isEOF || (isET && recv < el.engine.opts.EdgeTriggeredIOSpace) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declare a new local variable for this, like isET.

options.go Outdated
@@ -268,3 +272,10 @@ func WithEdgeTriggeredIO(et bool) Option {
opts.EdgeTriggeredIO = et
}
}

// WithEdgeTriggeredIOSpace set number of bytes that gnet can read/write up to in one event loop of ET.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// WithEdgeTriggeredIOSpace sets the number of bytes that gnet can read/write up to in one event loop of ET.

Copy link
Owner

@panjf2000 panjf2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add some tests for this, on the server and client sides.

@panjf2000
Copy link
Owner

I haven't got a response to my request about adding new tests for almost a week, so I've created #646, thank you for the efforts here.

@panjf2000 panjf2000 closed this Nov 5, 2024
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