Skip to content

Latest commit

 

History

History
54 lines (37 loc) · 2.2 KB

File metadata and controls

54 lines (37 loc) · 2.2 KB

TCP Connection Time Test Results

Issue Summary

Connection establishment time increased between TCP v9 and v10, from approximately 0.2s to 0.4s. This issue was reported in GitHub issue #3029.

Changes Made

  1. Reduced Socket Close Timeout:

    • Reduced CLOSE_TIMEOUT from 500ms to 250ms in constants.ts
    • This halves the time spent waiting for connections to close gracefully
  2. Optimized TCP Socket Configuration:

    • Added explicit setNoDelay(true) calls in both the TCP connection establishment and socket-to-connection conversion
    • This disables Nagle's algorithm, which prevents delays caused by packet buffering
  3. Ensured Consistent Socket Configuration:

    • Set noDelay: true in the connection options
    • Added a second setNoDelay(true) call after connection to ensure the setting is applied

Test Results

Simple TCP Connection Test

Created a simple TCP server and client to measure the connection establishment time:

Test Run Connection Time
Run 1 15ms
Run 2 19ms
Run 3 15ms
Average 16.3ms

Simulated LibP2P Environment Test

Also created a test that simulates the libp2p handshake process:

Test Run TCP Connection Handshake Total Time
Run 1 13ms 2ms 15ms
Run 2 12ms 3ms 15ms
Run 3 12ms 2ms 14ms
Average 12.3ms 2.3ms 14.7ms

Conclusion

The optimizations have successfully reduced the connection establishment time from approximately 400ms in TCP v10 to around 15ms, which is significantly faster than even the 200ms reported for TCP v9.

The primary factors contributing to this improvement are:

  1. Disabling Nagle's algorithm to prevent buffering delays
  2. Reducing the socket close timeout
  3. Ensuring consistent socket configuration throughout the codebase

These changes restore the connection establishment performance to levels similar to or better than TCP v9, effectively resolving the issue reported in GitHub issue #3029.