• Kirill Smelkov's avatar
    go/neo/neonet: Lightweight mode · ec4b3ce0
    Kirill Smelkov authored
    In situations when created connections are used to only send/receive 1
    request/response, the overhead to create/shutdown full connections could be
    too much. Unfortunately this is exactly the mode that is currently
    primarily used for compatibility with NEO/py. To help mitigate the overhead
    in such scenarios, lightweight connections mode is provided:
    
    At requester side, one message can be sent over node link with link.Send1 .
    Inside a connection will be created and then shut down, but since the
    code manages whole process internally and does not show the connection to
    user, it can optimize those operations significantly. Similarly link.Ask1
    sends 1 request, receives 1 response, and then puts the connection back into
    pool for later reuse.
    
    At receiver side, link.Recv1 accepts a connection with the first message
    remote peer sent us when establishing it, and wraps the result into Request
    object. The Request contains the message received and internally the
    connection. A response can be sent back via Request.Reply. Then once
    Request.Close is called the connection object that was accepted is
    immediately put back into pool for later reuse.
    
    Some history of lightweight mode:
    
    lab.nexedi.com/kirr/neo/commit/0fa96338	X Clarified Request.Close semantics - tests working again
    lab.nexedi.com/kirr/neo/commit/a5ac1652	X Ask1: switch to sending directly over link
    lab.nexedi.com/kirr/neo/commit/755e3654	X Request.Reply: switch to replying directly over link
    lab.nexedi.com/kirr/neo/commit/c643ba53	X Send1: switch to sending directly over link
    lab.nexedi.com/kirr/neo/commit/7dcbc9c5	X Send1: switch to lightClose
    lab.nexedi.com/kirr/neo/commit/851864a9	X chan RTT benchmark which simulates Recv1 = Accept + Recv
    lab.nexedi.com/kirr/neo/commit/099bfc29	X freelist for PktBuf
    lab.nexedi.com/kirr/neo/commit/58c2e39a	X Benchmark for link Ask1/Recv1 over TCP loopback
    ec4b3ce0
connection_test.go 25.6 KB