KEMBAR78
Improve APIs for Globally Enabling/Disabling fast_fallback in Socket by shioimm · Pull Request #12257 · ruby/ruby · GitHub
Skip to content

Conversation

@shioimm
Copy link
Contributor

@shioimm shioimm commented Dec 4, 2024

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)

Additionally, documentation for these methods has been added.

@shioimm shioimm force-pushed the improve-tcp_fast_fallback-api branch 2 times, most recently from 7dd8970 to b7b1168 Compare December 7, 2024 05:42
@shioimm shioimm changed the title WIP: Improve Socket.tcp_fast_fallback Improve Socket.tcp_fast_fallback= / Socket.tcp_fast_fallback Dec 7, 2024
@shioimm shioimm force-pushed the improve-tcp_fast_fallback-api branch 2 times, most recently from cf8229b to c723880 Compare December 12, 2024 13:57
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)
@shioimm shioimm force-pushed the improve-tcp_fast_fallback-api branch from c723880 to 62c63a9 Compare December 14, 2024 01:41
@shioimm shioimm changed the title Improve Socket.tcp_fast_fallback= / Socket.tcp_fast_fallback Improve APIs for Globally Enabling/Disabling fast_fallback in Socket Dec 14, 2024
@shioimm shioimm marked this pull request as ready for review December 14, 2024 02:46
@shioimm shioimm merged commit 9f924e2 into ruby:master Dec 14, 2024
77 checks passed
headius added a commit to headius/jruby that referenced this pull request Mar 13, 2025
This is used by the new fast fallback algorithm for the Socket.tcp
method. This appears to be the only C change needed.

See the following PRs for the bulk of the related logic:

* ruby/ruby#9374
* ruby/ruby#11187
* ruby/ruby#12257
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