Improve APIs for Globally Enabling/Disabling fast_fallback in Socket (#12257)

This change includes the following updates:
- Added an environment variable `RUBY_TCP_NO_FAST_FALLBACK` to control enabling/disabling fast_fallback
- Updated documentation and man pages
- Revised the implementation of Socket.tcp_fast_fallback= and Socket.tcp_fast_fallback, which previously performed dynamic name resolution of constants and variables. As a result, the following performance improvements were achieved:

(Case of 1000 executions of `TCPSocket.new` to the local host)

Rehearsal -----------------------------------------
before   0.031462   0.147946   0.179408 (  0.249279)
after    0.031164   0.146839   0.178003 (  0.346935)
-------------------------------- total: 0.178003sec

            user     system      total        real
before   0.027584   0.138712   0.166296 (  0.233356)
after    0.025953   0.127608   0.153561 (  0.237971)
This commit is contained in:
Misaki Shioi 2024-12-14 15:51:19 +09:00 committed by GitHub
parent 77016a7b43
commit 9f924e2f13
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
Notes: git 2024-12-14 06:51:36 +00:00
Merged-By: shioimm <shioi.mm@gmail.com>
6 changed files with 117 additions and 49 deletions

View file

@ -776,6 +776,17 @@ a program (or script) that is to be executed.
.Pp
The pipe template is split on spaces into an argument list before the
template parameters are expanded.
.Sh MISC ENVIRONMENT
.Pp
.Bl -hang -compact -width "RUBY_TCP_NO_FAST_FALLBACK"
.It Ev RUBY_TCP_NO_FAST_FALLBACK
If set to
.Li 1 ,
disables the fast fallback feature by default in TCPSocket.new and Socket.tcp.
When set to
.Li 0
or left unset, the fast fallback feature is enabled.
Introduced in Ruby 3.4, default: unset.
.Sh SEE ALSO
.Bl -hang -compact -width "https://www.ruby-toolbox.com/"
.It Lk https://www.ruby-lang.org/