| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |
|
|\
| |
| | |
Document, refactor and create test case for ActionDispatch::Response
|
| |
| |
| |
| | |
ActionDispatch::Response#charset= method
|
| |
| |
| |
| |
| | |
Now that we have encoding strategies, we can just walk the params hash
once to encode as HWIA, and remove nils.
|
| |
| |
| |
| | |
we'll refactor deep munge mostly out of existence shortly
|
| |
| |
| |
| | |
This should have been done along with 8f8ccb9901cab457c6e1d52bdb25acf658fd5777
|
| |
| |
| |
| |
| | |
this just pushes the conditional in to the case / when so we can switch
to method dispatch later
|
|\ \
| | |
| | | |
Remove unnecessary `dup` from Mapper `add_route`
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The `dup` was introduced by c4106d0c08954b0761726e0015ec601b7bc7ea4b
to work around a frozen key. Nowadays, the string is already being
duplicated by the `tr` in `options[:action] ||= action.tr('-', '_')`
and later joined into a new string in `name_for_action`.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
I wrote a utility that helps find areas where you could optimize your program using a frozen string instead of a string literal, it's called [let_it_go](https://github.com/schneems/let_it_go). After going through the output and adding `.freeze` I was able to eliminate the creation of 1,114 string objects on EVERY request to [codetriage](codetriage.com). How does this impact execution?
To look at memory:
```ruby
require 'get_process_mem'
mem = GetProcessMem.new
GC.start
GC.disable
1_114.times { " " }
before = mem.mb
after = mem.mb
GC.enable
puts "Diff: #{after - before} mb"
```
Creating 1,114 string objects results in `Diff: 0.03125 mb` of RAM allocated on every request. Or 1mb every 32 requests.
To look at raw speed:
```ruby
require 'benchmark/ips'
number_of_objects_reduced = 1_114
Benchmark.ips do |x|
x.report("freeze") { number_of_objects_reduced.times { " ".freeze } }
x.report("no-freeze") { number_of_objects_reduced.times { " " } }
end
```
We get the results
```
Calculating -------------------------------------
freeze 1.428k i/100ms
no-freeze 609.000 i/100ms
-------------------------------------------------
freeze 14.363k (± 8.5%) i/s - 71.400k
no-freeze 6.084k (± 8.1%) i/s - 30.450k
```
Now we can do some maths:
```ruby
ips = 6_226k # iterations / 1 second
call_time_before = 1.0 / ips # seconds per iteration
ips = 15_254 # iterations / 1 second
call_time_after = 1.0 / ips # seconds per iteration
diff = call_time_before - call_time_after
number_of_objects_reduced * diff * 100
# => 0.4530373333993266 miliseconds saved per request
```
So we're shaving off 1 second of execution time for every 220 requests.
Is this going to be an insane speed boost to any Rails app: nope. Should we merge it: yep.
p.s. If you know of a method call that doesn't modify a string input such as [String#gsub](https://github.com/schneems/let_it_go/blob/b0e2da69f0cca87ab581022baa43291cdf48638c/lib/let_it_go/core_ext/string.rb#L37) please [give me a pull request to the appropriate file](https://github.com/schneems/let_it_go/blob/b0e2da69f0cca87ab581022baa43291cdf48638c/lib/let_it_go/core_ext/string.rb#L37), or open an issue in LetItGo so we can track and freeze more strings.
Keep those strings Frozen
![](https://www.dropbox.com/s/z4dj9fdsv213r4v/let-it-go.gif?dl=1)
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This will silence deprecation warnings.
Most of the test can be changed from `render :text` to render `:plain`
or `render :body` right away. However, there are some tests that needed
to be fixed by hand as they actually assert the default Content-Type
returned from `render :body`.
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This is another take at #14384 as we decided to wait until `master` is
targeting Rails 5.0. This commit is implementation-complete, as it
guarantees that all the public methods on the hash-inherited Parameters
are still working (based on test case). We can decide to follow-up later
if we want to remove some methods out from Parameters.
|
| | |
| | |
| | |
| | | |
Rack [already implements `redirect?` on the response object](https://github.com/rack/rack/blob/1569a985e17d9caaf94d0e97d95ef642c4ab14ba/lib/rack/response.rb#L141) so we don't need to implement our own.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
We shouldn't depend on specific methods imlemented in the TestResponse
subclass because the response could actually be a real response object.
In the future, we should either push the aliased predicate methods in
TestResponse up to the real response object, or remove them
|
| | | |
|
|\ \ \
| | | |
| | | | |
Removed usage line docs [ci skip]
|
| | | | |
|
|\ \ \ \
| | | | |
| | | | | |
Concurrent load interlock (rm Rack::Lock)
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
We can't actually lean on Rack::Lock's implementation, so we'll just
copy it instead. It's simple enough that that's not too troubling.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
We don't need to fully disable concurrent requests: just ensure that
loads are performed in isolation.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
pass in the instance variable to start decoupling the meat of the parser
from the instance of the middleware
|
| |/ / /
|/| | |
| | | |
| | | |
| | | | |
We will always make an assignment to the env hash and eliminate a
conditional
|
| | | |
| | | |
| | | |
| | | |
| | | | |
If we only deal with proc objects, then we can eliminate type checking
in the parameter parsing middleware
|
| | | |
| | | |
| | | |
| | | | |
this prevents mutations from being available globally
|
| | | | |
|
| | | | |
|
| | | | |
|
| | | |
| | | |
| | | |
| | | |
| | | | |
We should leverage the request / response objects that the superclass
has already allocated for us.
|
|/ / / |
|
| | |
| | |
| | |
| | |
| | | |
we should be pushing the cookies in via headers rather than maintaining
some object and "recycling" it.
|
| | | |
|
|\ \ \
| | | |
| | | | |
Allow filtering params based on parent keys
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Add the possibility to only filter parameters based on
their full path instead of relying on the immediate key.
config.filter_parameters += ['credit_card.code']
{ 'credit_card' => { 'code' => '[FILTERED]' },
'source' => { 'code' => '<%= puts 5 %>' } }
|
| |/ /
|/| |
| | |
| | |
| | |
| | | |
This change decouples `cookie_jar` allocation from the request object.
We need this for moving controller tests to integration tests so we can
access the `cookie_jar` object separately.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Clarify the `url_for` usage in mailers.
Re-add the documentation about `url_for` and Route's path parameters,
first introduced by 5c4f1859970d06228a0b67cad6d4486c1526ef2a.
This was reported on #15097 and until it is decided to deprecate it
or not, I believe the documentation should exist.
|
|\ \ \
| |/ /
|/| | |
Respect routing precedence for HEAD requests
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Fixes the issue described in #18764 - prevents Rack middleware from
swallowing up HEAD requests that should have been matched by a
higher-precedence `get` route, but still allows Rack middleware to
respond to HEAD requests.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This reverts commit 0b3397872582f2cf1bc6960960a6393f477c55e6, reversing
changes made to 56d52e3749180e6c1dcf7166adbad967470aa78b.
As pointed out on the PR, this will hide development mistakes too, which
is not ideal.
|
|\ \ \
| | | |
| | | | |
Catch InvalidURIError on bad paths on redirect.
|
| | |/
| |/|
| | |
| | |
| | | |
Handle URI::InvalidURIError errors on the redirect route method, so it
wont raise a 500 if a bad path is given.
|
|/ / |
|
| |
| |
| |
| |
| |
| | |
People should be free to mutate the header object, but not to set a new
header object. That header object may be specific to the webserver, and
we need to hide it's internals.
|
| |
| |
| |
| |
| | |
this way we don't have to mutate the instance (as much) when writing a
rack response
|
| |
| |
| |
| |
| |
| | |
`ActionDispatch::SSL` changes headers to `Hash`.
So some headers will be broken if there are some middlewares
on ActionDispatch::SSL and if it uses `Rack::Utils::HeaderHash`.
|
| |
| |
| |
| |
| | |
I want to decouple Rails from the rack ENV as much as possible. We
should try to keep as few references to the env as possible
|
| | |
|
| |
| |
| |
| |
| | |
See the following commit to have context about this change:
https://github.com/rails/rails/commit/757a2bc3e3e52a5d9418656928db993db42b741b
|
| | |
|