Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce stat(2) calls #37265

Merged
merged 1 commit into from Sep 22, 2019
Merged

Reduce stat(2) calls #37265

merged 1 commit into from Sep 22, 2019

Conversation

nobu
Copy link
Contributor

@nobu nobu commented Sep 22, 2019

Summary

File.file? and other predicates for permissions can use same stat(2) call result.

`File.file?` and other predicates for permissions can use same
stat(2) call result.
@carlosantoniodasilva carlosantoniodasilva merged commit 1e14a24 into rails:master Sep 22, 2019
2 checks passed
@nateberkopec
Copy link
Contributor

@nateberkopec nateberkopec commented Jun 10, 2021

Hmmm... since ActionDispatch::Static is based around this:

def call(env)
  @file_handler.attempt(env) || @app.call(env)
end

... this change causes any request that is not for a static file to raise 5-10 exceptions that are silently rescued. I think the original code is probably faster for requests handled by the app.

nateberkopec added a commit to nateberkopec/rails that referenced this issue Jun 10, 2021
Using File.stat where a file does not exist raises an exception.

Since ActionDispatch::Static does this:

def call(env)
  @file_handler.attempt(env) || @app.call(env)
end

... this means that around 8 exceptions are raised and rescued on each
request which is passed to the application.

This change improves latency by ~.14 milliseconds on all applications.

Partial revert of rails#37265
byroot pushed a commit that referenced this issue Jun 11, 2021
Using File.stat where a file does not exist raises an exception.

Since ActionDispatch::Static does this:

def call(env)
  @file_handler.attempt(env) || @app.call(env)
end

... this means that around 8 exceptions are raised and rescued on each
request which is passed to the application.

This change improves latency by ~.14 milliseconds on all applications.

Partial revert of #37265
brendon pushed a commit to brendon/rails that referenced this issue Jun 17, 2021
Using File.stat where a file does not exist raises an exception.

Since ActionDispatch::Static does this:

def call(env)
  @file_handler.attempt(env) || @app.call(env)
end

... this means that around 8 exceptions are raised and rescued on each
request which is passed to the application.

This change improves latency by ~.14 milliseconds on all applications.

Partial revert of rails#37265
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants