Skip to content

Conversation

PokeMMO
Copy link

@PokeMMO PokeMMO commented Nov 2, 2019

Currently every call to update calls flush which creates a new flush buffer and segment. Even when there is no work required to be done.

ByteBufAllocator.ioBuffer is a fairly expensive call to call every update.

Unless I am doing something wrong, Kcp#check will schedule a work duration (100ms by default) not necessarily when the next "action" is required. This might be better handled by changing Kcp#check?

@szhnet
Copy link
Owner

szhnet commented Dec 31, 2019

There are check logics both checkFlushRequired and flush method. I think it is difficult to maintain. What do you think?

@PokeMMO
Copy link
Author

PokeMMO commented Dec 31, 2019

It is definitely not ideal and will cause more effort to maintain, but it is a very large performance benefit.

The other alternative is likely worse, editing flush to only create the seg and buffer when they're actually used.

https://github.com/szhnet/kcp-netty/blob/master/kcp-netty/src/main/java/io/jpower/kcp/netty/Kcp.java#L1108-L1117

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