- 20 7月, 2015 1 次提交
-
-
由 schneems 提交于
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)
-
- 19 7月, 2015 6 次提交
-
-
由 Kasper Timm Hansen 提交于
Fix formatting of force_ssl options documentation [ci skip]
-
由 Eliot Sykes 提交于
-
由 Abdelkader Boudih 提交于
[ci skip] Fix typo in #any? RDoc
-
由 Sean Griffin 提交于
Added examples to DateAndTime::Calculations [ci skip]
-
由 Julio Lopez 提交于
-
由 Sean Griffin 提交于
Ensure that 'ActionController::Parameters' can still be passed to AR …
-
- 18 7月, 2015 25 次提交
-
-
由 Thomas Walpole 提交于
-
由 Sean Griffin 提交于
This code is so fucked. Things that cause this bug not to replicate: - Defining the validation before the association (we end up calling `uniq!` on the errors in the autosave validation) - Adding `accepts_nested_attributes_for` (I have no clue why. The only thing it does that should affect this is adds `autosave: true` to the inverse reflection, and doing that manually doesn't fix this). This solution is a hack, and I'm almost certain there's a better way to go about it, but this shouldn't cause a huge hit on validation times, and is the simplest way to get it done. Fixes #20874.
-
由 Sean Griffin 提交于
Add a note about default_scope and create records [ci skip]
-
由 Sean Griffin 提交于
Since nested hashes are also instances of `ActionController::Parameters`, and we're explicitly looking to work with a hash for nested attributes, this caused breakage in several points. This is the minimum viable fix for the issue (and one that I'm not terribly fond of). I can't think of a better place to handle this at the moment. I'd prefer to use some sort of solution that doesn't special case AC::Parameters, but we can't use something like `to_h` or `to_a` since `Enumerable` adds both. While I've added a trivial test case for verifying this fix in isolation, we really need better integration coverage to prevent regressions like this in the future. We don't actually have a lot of great places for integration coverage at the moment, so I'm deferring it for now. Fixes #20922.
-
由 Sean Griffin 提交于
Replaced render :text with render :plain in AC gem bug report template
-
由 Prathamesh Sonpatki 提交于
- Followup of https://github.com/rails/rails/pull/20929. [ci skip]
-
由 Kasper Timm Hansen 提交于
use `plain` option instead of deprecated `text` option
-
由 yuuji.yaginuma 提交于
this will silence deprecation warnings
-
由 Matthew Draper 提交于
Stop using deprecated `render :text` in test
-
由 Prem Sichanugrist 提交于
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`.
-
由 Jeremy Daer (Kemper) 提交于
Add deprecation warning for `render :text`
-
由 Prem Sichanugrist 提交于
We've started on discouraging the usage of `render :text` in #12374. This is a follow-up commit to make sure that we print out the deprecation warning.
-
由 Andrii Ponomarov 提交于
-
由 Aaron Patterson 提交于
this way we don't need to call `to_unsafe_h` to get access to ask questions about the underlying hash
-
由 Sean Griffin 提交于
Silence deprecation warning from force reload
-
由 Aaron Patterson 提交于
now `hash_filter` doesn't need to know about the `Parameters` class
-
由 Aaron Patterson 提交于
Since we proved that `element` is always of type `Parameter`, we know that it will always respond to `permit`, so lets remove this conditional
-
由 Sean Griffin 提交于
Manually merged to fix conflicts.
-
由 Bernard Potocki 提交于
ActiveSupport::HashWithIndifferentAccess select and reject should return enumerator if called without block
-
由 Aaron Patterson 提交于
`element` can never be a hash because: 1. `slice` returns a Parameters object and calls each on it: https://github.com/rails/rails/blob/cb3f25593b1137e344086364d4b1a52c08e8eb3b/actionpack/lib/action_controller/metal/strong_parameters.rb#L656 2. `each` which is implemented by `each_pair` will call `convert_hashes_to_parameters` on the value: https://github.com/rails/rails/blob/cb3f25593b1137e344086364d4b1a52c08e8eb3b/actionpack/lib/action_controller/metal/strong_parameters.rb#L192-197 3. `convert_hashes_to_parameters` will convert any hash objects in to parameters objects: https://github.com/rails/rails/blob/cb3f25593b1137e344086364d4b1a52c08e8eb3b/actionpack/lib/action_controller/metal/strong_parameters.rb#L550-566
-
由 Aaron Patterson 提交于
Now that the value is cached on the stack, `array_of_permitted_scalars_filter` is exactly the same as `array_of_permitted_scalars?`, so lets just have one
-
由 Aaron Patterson 提交于
this way the method doesn't have to know what the new params object is, it just yields to a block. This change also caches the value of `self[key]` on the stack
-
由 Aaron Patterson 提交于
We should disconnect `array_of_permitted_scalars_filter` from the instance so that we can make hash filtering functional. For now, pull the conditional up out of that method
-
由 Rafael Mendonça França 提交于
[skip ci] Lookup can be a noun but it is not a verb
-
由 Jon Atack 提交于
Various grammar corrections and wrap to 80 characters.
-
- 17 7月, 2015 8 次提交
-
-
由 Sean Griffin 提交于
Skip a few failing tests on JRuby with the attached tickets
-
由 Robin Dupret 提交于
-
由 Claudio B. 提交于
[ci skip] Add `bundle exec` to test run command
-
由 Claudio B. 提交于
[skip ci] Improve grammar/style in DB pooling guide.
-
由 Akira Matsuda 提交于
-
由 Akira Matsuda 提交于
-
由 yui-knk 提交于
-
由 Mauro George 提交于
[ci skip]
-