Skip to content

Conversation

@CufeHaco
Copy link

Implements native JEP 380 (JDK 16+) Unix Domain Sockets with automatic
fallback to JNR for JDK 11-15. Includes production-ready IPC helper system
with auto-cleanup, auto-reconnect, connection pooling, and signal handling.
Provides 20-30% performance improvement on modern JDKs with zero breaking changes.

Core Implementation:

  • Modified 4 core socket classes (RubyUNIXSocket, RubyUNIXServer, RubyTCPSocket, RubyTCPServer)
  • Added 14 channel implementation files with factory pattern
  • Automatic runtime backend selection (JEP 380 vs JNR)
  • Maintains full MRI Ruby socket API compatibility

IPC Helper System (socket.rb):

  • unix_server() / unix_client() - High-level Unix socket helpers
  • tcp_server() / tcp_client() - High-level TCP socket helpers
  • tcp_pool() - Connection pooling for high-frequency operations
  • Auto-cleanup of stale socket files
  • Auto-reconnect with exponential backoff (configurable retries)
  • Signal handling (INT, TERM) with graceful shutdown
  • Built-in SHUTDOWN command for remote server control
  • Thread-safe connection pool with statistics

Architecture:

  • UnixSocketChannelFactory: Auto-selects JDK 16+ native or JNR fallback
  • TCPSocketChannelFactory: Handles plain/SSL socket selection
  • Interface-based design for extensibility
  • JRubySockets module with Server, Client, TCPServer, TCPClient, ConnectionPool classes

Performance: 20-30% improvement on JDK 16+ compared to JNR-only implementation

Documentation: Comprehensive guide in JEP380_SOCKETS.md covering usage,
architecture, performance benchmarks, and migration guide.

Authored-By: Troy Mallory (CufeHaco) [email protected]

  Implements native JEP 380 (JDK 16+) Unix Domain Sockets with automatic
  fallback to JNR for JDK 11-15. Includes production-ready IPC helper system
  with auto-cleanup, auto-reconnect, connection pooling, and signal handling.
  Provides 20-30% performance improvement on modern JDKs with zero breaking changes.

  Core Implementation:
  - Modified 4 core socket classes (RubyUNIXSocket, RubyUNIXServer, RubyTCPSocket, RubyTCPServer)
  - Added 14 channel implementation files with factory pattern
  - Automatic runtime backend selection (JEP 380 vs JNR)
  - Maintains full MRI Ruby socket API compatibility

  IPC Helper System (socket.rb):
  - unix_server() / unix_client() - High-level Unix socket helpers
  - tcp_server() / tcp_client() - High-level TCP socket helpers
  - tcp_pool() - Connection pooling for high-frequency operations
  - Auto-cleanup of stale socket files
  - Auto-reconnect with exponential backoff (configurable retries)
  - Signal handling (INT, TERM) with graceful shutdown
  - Built-in SHUTDOWN command for remote server control
  - Thread-safe connection pool with statistics

  Architecture:
  - UnixSocketChannelFactory: Auto-selects JDK 16+ native or JNR fallback
  - TCPSocketChannelFactory: Handles plain/SSL socket selection
  - Interface-based design for extensibility
  - JRubySockets module with Server, Client, TCPServer, TCPClient, ConnectionPool classes

  Performance: 20-30% improvement on JDK 16+ compared to JNR-only implementation

  Documentation: Comprehensive guide in JEP380_SOCKETS.md covering usage,
  architecture, performance benchmarks, and migration guide.

  Authored-By: Troy Mallory (CufeHaco) <[email protected]>
@CufeHaco
Copy link
Author

@headius @enebo this one is ready for testing and review. i had some issues with Claude and the push, so hopfully my code base didnt get changed or nothing left out. i ran though and I didn't see anything missing, but as always, please double check behind me. you can blame the electrician in me for constantly testing and checking behind myself.

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.

1 participant