Giter Site home page Giter Site logo

Comments (3)

JeffCyr avatar JeffCyr commented on June 24, 2024

Hi Aaron,

You talked about using SocketAsyncEventArgs in Helios 2.0. From experience, you need to pool them to get better results than BeginReceive/BeginSend. I'm not very familiar with the Helios 1.X codebase, but it doesn't seem to pool its Send buffers, have you thought about a strategy for send buffer pooling in Helios 2.0?

Jeff

from helios.

Maximusya avatar Maximusya commented on June 24, 2024

SocketAsyncEventArgs pooling is questionable:

  • for long living connections even the use of non-pooled SAEA is already an advantage over BeginReceive/BeginSend (well, that is the point SAEA was introduced in the first place);
  • for short living connections pooling of SAEA might make sence.

Anyway pooling logic complicates the code.

Now I tend to aquire/release buffers from the pool on every new/completed network operation.
And create/dispose 2xSAEA on accept/close of a connection.
Though it all may be an oversight from my side on socket-server architecture ;)

from helios.

JeffCyr avatar JeffCyr commented on June 24, 2024

@Maximusya I think your design is good, but assigning only one SAEA for write operation on the socket force you to copy the buffer you want to send in the SAEA's buffer.

If you replace your traditional buffer pool by a SAEA pool, you can write directly in the SAEA buffer and send that to the socket. So one less Buffer.Copy per write.

Another advantage is that the socket can release the SAEA when it is done writing, so a connection will consume less memory when it's not writing data.

To optimize things further, your pool can allocate large buffers so they end up in the Large Object Heap. Then multiple SAEA can all point to the same buffer with different offset/count. This will result in less fragmentation and less pressure in the GC because it won't need to compact the heap.

from helios.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.