netty / netty/netty

Questions about the doWrite method of NioSocketChannel

Open
#16,004 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
35.1k
Forks
16.3k
Avg merge
1d 5h
Merged PRs (30d)
143

Description

Hello, in the doWrite method of NioSocketChannel, if writeSpinCount reaches 0 at the same time all the data has been processed, then the method will call incompleteWrite(false) at the end to submit the flush0 task. I'm not sure if this is the correct understanding. If so, I think that performing ChannelOutboundBuffer.isEmpty after the loop completes is significantly less costly than submitting the task. I hope this helps, thank you!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading NioSocketChannel's doWrite method and the ChannelOutboundBuffer.isEmpty and incompleteWrite paths mentioned in the report. Verify whether the loop can exhaust both writeSpinCount and the outbound data, then determine whether the proposed empty-buffer check preserves the existing flush0 behavior; done means the behavior is confirmed or a focused change is justified.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
networking
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.