aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #21052 from robin850/caching-guideKasper Timm Hansen2015-08-032-51/+160
|\ | | | | Publish the "Caching with Rails" guide
| * Improve the "Caching with Rails" guide's introduction [ci skip]claudiob2015-08-031-2/+14
| |
| * Add a section about "Collection caching" [ci skip]Robin Dupret2015-08-031-0/+23
| |
| * Publish the "Caching with Rails" guide [ci skip]Celestino Gomes2015-07-281-0/+4
| |
| * Add a "Managing dependencies" part to the caching guide [ci skip]Robin Dupret2015-07-281-0/+87
| |
| * Tiny edits to the "Caching with Rails" guideRobin Dupret2015-07-281-49/+32
| | | | | | | | | | | | | | | | | | | | | | * Fix a few typos * Remove reference to the old `memcache-client` gem * Remove the "ActiveSupport::Cache::EhCacheStore" part from the guide as the gem doesn't seem to be maintained anymore. * Move the "Custom Cache Stores" part under the "AS::Cache::Store" part as they are pretty related. [ci skip]
* | Merge pull request #21104 from atul-shimpi/masterYves Senn2015-08-032-2/+4
|\ \ | | | | | | | | | | | | | | | Inform user to add styles in correct location in application.css [ci skip]
| * | Inform user to add styles in correct location in application.cssatul-shimpi2015-08-032-2/+4
| | |
* | | test runner should crash with non existing file argument.Yves Senn2015-08-032-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | Before this patch, using `bin/rails test` with a non existing file or directory argument would silently swallow the argument and run the whole test suite. After the patch the command fails with `cannot load such file --`.
* | | Merge pull request #21095 from aditya-kapoor/add-missing-assertionYves Senn2015-08-031-2/+4
|\ \ \ | | | | | | | | Add missing assertion for test_route_with_colon_first
| * | | Add missing assertion for test_route_with_colon_firstAditya Kapoor2015-08-031-2/+4
| | | |
* | | | Merge pull request #21103 from mikeastock/update_time_advance_docsYves Senn2015-08-031-0/+6
|\ \ \ \ | |_|/ / |/| | | Update Time#advance documentation with examples [ci skip]
| * | | [ci skip] Update Time#advance documentation with examplesMichael Stock2015-08-021-0/+6
| |/ /
* | | Merge pull request #21093 from vngrs/fix_ambiguous_argument_warningKasper Timm Hansen2015-08-021-1/+1
|\ \ \ | | | | | | | | Fix ambiguous argument warning
| * | | Fix ambiguous argument warningMehmet Emin İNAÇ2015-08-021-1/+1
| |/ / | | | | | | | | | encapsulate all arguments
* | | Merge pull request #21100 from bquorning/route-setRichard Schneeman2015-08-021-2/+2
|\ \ \ | | | | | | | | Use #start_with? and #[] for speed
| * | | Use #start_with? and #[] for speedBenjamin Quorning2015-08-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While the readability may be slightly worse, the speed improvement is significant: Twice as fast when there's no leading "/" to remove, and over 4 times as fast when there is a leading "/". Benchmark: require 'benchmark/ips' def match(controller) if controller if m = controller.match(/\A\/(?<controller_without_leading_slash>.*)/) m[:controller_without_leading_slash] else controller end end end def start_with(controller) if controller if controller.start_with?('/'.freeze) controller[1..-1] else controller end end end Benchmark.ips do |x| x.report("match") { match("no_leading_slash") } x.report("start_with") { start_with("no_leading_slash") } x.compare! end Benchmark.ips do |x| x.report("match") { match("/a_leading_slash") } x.report("start_with") { start_with("/a_leading_slash") } x.compare! end Result (Ruby 2.2.2): Calculating ------------------------------------- match 70.324k i/100ms start_with 111.264k i/100ms ------------------------------------------------- match 1.468M (± 7.1%) i/s - 7.314M start_with 3.787M (± 3.5%) i/s - 18.915M Comparison: start_with: 3787389.4 i/s match: 1467636.4 i/s - 2.58x slower Calculating ------------------------------------- match 36.694k i/100ms start_with 86.071k i/100ms ------------------------------------------------- match 532.795k (± 4.7%) i/s - 2.679M start_with 2.518M (± 5.8%) i/s - 12.566M Comparison: start_with: 2518366.8 i/s match: 532794.5 i/s - 4.73x slower
* | | | Merge pull request #21098 from bquorning/shovel-twice-and-save-a-stringRichard Schneeman2015-08-021-3/+8
|\ \ \ \ | |/ / / |/| | | Save a string allocation inside loop
| * | | Save a string allocation inside loopBenjamin Quorning2015-08-021-3/+8
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the `tag_options` method, strings are continuously added to the `output` string. Previously, we concatenated two strings and added the generated string to `output`. By adding each of the strings to `output`, one after the other, we will save the allocation of that concatenated string. Benchmark: require 'benchmark/ips' sep = " ".freeze Benchmark.ips do |x| x.report("string +") { output = "" output << sep + "foo" } x.report("string <<") { output = "" output << sep output << "foo" } x.compare! end Results (Ruby 2.2.2): Calculating ------------------------------------- string + 88.086k i/100ms string << 94.287k i/100ms ------------------------------------------------- string + 2.407M (± 5.8%) i/s - 12.068M string << 2.591M (± 7.0%) i/s - 12.917M Comparison: string <<: 2591482.4 i/s string +: 2406883.7 i/s - 1.08x slower
* | | Merge pull request #21097 from y-yagi/fix_button_to_exampleArun Agrawal2015-08-021-1/+1
|\ \ \ | |/ / |/| | correct example of button_tag [ci skip]
| * | correct example of button_tag [ci skip]yuuji.yaginuma2015-08-021-1/+1
|/ / | | | | | | wrapper div has been removed in cbb917455f306cf5818644b162f22be09f77d4b2
* | Fix test failures caused by #20884Sean Griffin2015-08-011-1/+3
| | | | | | | | | | | | | | PostgreSQL is strict about the usage of `DISTINCT` and `ORDER BY`, which one of the tests demonstrated. The order clause is never going to be relevant in the query we're performing, so let's just remove it entirely.
* | Merge pull request #20884Sean Griffin2015-08-016-0/+137
|\ \ | | | | | | | | | Add #cache_key to ActiveRecord::Relation.
| * | Add #cache_key to ActiveRecord::Relation.Alberto F. Capel2015-07-206-0/+137
| | |
* | | Merge pull request #21088 from yui-knk/doc/to_paramRichard Schneeman2015-08-012-0/+29
|\ \ \ | | | | | | | | [ci skip]
| * | | [ci skip]yui-knk2015-08-012-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add descriptions about `ActiveRecord::Base#to_param` to * `ActionDispatch::Routing::Base#match` * Overriding Named Route Parameters (guide) When passes `:param` to route definision, always `to_param` method of related model is overridden to constructe an URL by passing these model instance to named_helper.
* | | | docs, custom api base controllers shoudl subclass metal. [ci skip]Yves Senn2015-08-011-1/+1
| | | | | | | | | | | | | | | | This is a follow up to #21008.
* | | | Merge pull request #21008 from svenwin/patch-1Yves Senn2015-08-011-1/+1
|\ \ \ \ | | | | | | | | | | | | | | | Add documentation to get a running custom base controller [ci skip]
| * | | | Add documentation to get a running custom base controller [ci skip]Sven Winkler2015-07-231-1/+1
| | | | |
* | | | | minor AR changelog edits. [ci skip]Yves Senn2015-08-011-9/+8
| |/ / / |/| | |
* | | | Merge pull request #21063 from cmisenas/fix-guides-warning-envYves Senn2015-07-311-1/+1
|\ \ \ \ | | | | | | | | | | Fix WARNINGS flag inside guides/Rakefile
| * | | | Fix WARNINGS flag inside guides/RakefileJade Misenas2015-07-291-1/+1
| | | | |
* | | | | Merge pull request #20992 from JuanitoFatas/fix/bin-setup-scriptYves Senn2015-07-311-1/+1
|\ \ \ \ \ | | | | | | | | | | | | Don't fail when checking dependencies in bin/setup script
| * | | | | Don't fail when checking dependencies in bin/setup scriptJuanito Fatas2015-07-231-1/+1
| | | | | |
* | | | | | Merge pull request #21075 from byroot/not-empty-vs-anyRafael Mendonça França2015-07-301-2/+2
|\ \ \ \ \ \ | | | | | | | | | | | | | | Array#any? is slower and not the inverse of Array#empty?
| * | | | | | Array#any? is slower and not the inverse of Array#empty?Jean Boussier2015-07-301-2/+2
|/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ``` empty_array = [] small_array = [1] * 30 bigger_array = [1] * 300 Benchmark.ips do |x| x.report('empty !empty?') { !empty_array.empty? } x.report('small !empty?') { !small_array.empty? } x.report('bigger !empty?') { !bigger_array.empty? } x.report('empty any?') { empty_array.any? } x.report('small any?') { small_array.any? } x.report('bigger any?') { bigger_array.any? } end ``` ``` Calculating ------------------------------------- empty !empty? 132.059k i/100ms small !empty? 133.974k i/100ms bigger !empty? 133.848k i/100ms empty any? 106.924k i/100ms small any? 85.525k i/100ms bigger any? 86.663k i/100ms ------------------------------------------------- empty !empty? 8.522M (± 7.9%) i/s - 42.391M small !empty? 8.501M (± 8.5%) i/s - 42.202M bigger !empty? 8.434M (± 8.6%) i/s - 41.894M empty any? 4.161M (± 8.3%) i/s - 20.743M small any? 2.654M (± 5.2%) i/s - 13.256M bigger any? 2.642M (± 6.4%) i/s - 13.173M ``` Ref: https://github.com/rails/rails/pull/21057#discussion_r35902468
* | | | | | Merge pull request #21057 from schneems/schneems/journey-formatter-objectsRichard Schneeman2015-07-3018-68/+157
|\ \ \ \ \ \ | | | | | | | | | | | | | | Beyond Ludicrous Speed
| * | | | | | Use delete_if instead of each; delete(key)schneems2015-07-301-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is slightly faster: ``` Calculating ------------------------------------- each; delete 35.166k i/100ms delete_if 36.416k i/100ms ------------------------------------------------- each; delete 478.026k (± 8.5%) i/s - 2.391M delete_if 485.123k (± 7.9%) i/s - 2.440M ```
| * | | | | | Remove (another) array allocationschneems2015-07-301-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't always need an array when generating a url with the formatter. We can be lazy about allocating the `missing_keys` array. This saves us: 35,606 bytes and 889 objects per request
| * | | | | | Remove array allocationschneems2015-07-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | THe only reason we were allocating an array is to get the "missing_keys" variable in scope of the error message generator. Guess what? Arrays kinda take up a lot of memory, so by replacing that with a nil, we save: 35,303 bytes and 886 objects per request
| * | | | | | zOMG 37 objects savedschneems2015-07-301-1/+1
| | | | | | |
| * | | | | | Don't allocate array when not necessaryschneems2015-07-301-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the `tag_options` method an array is used to build up elements, then `Array#*` (which is an alias for `Array#join` is called to turn the array into a string. Instead of allocating an array to build a string, we can build the string we want from the beginning. Saved: 121,743 bytes 893 objects
| * | | | | | String#freeze optimizationsschneems2015-07-302-2/+2
| | | | | | |
| * | | | | | Decrease allocations in transliterateschneems2015-07-301-5/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We can save a few objects by freezing the `replacement` string. We save a few more by down-casing the string in memory instead of allocating a new one. We save far more objects by checking for the default separator `"-"`, and using pre-generated regular expressions. We will save 209,231 bytes and 1,322 objects.
| * | | | | | Avoid hash duplication by skipping mutationschneems2015-07-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we don't mutate the `recall` hash, then there's no reason to duplicate it. While this change doesn't get rid of that many objects, each hash object it gets rid of was massive. Saves 888 string objects per request, 206,013 bytes (thats 0.2 mb which is kinda a lot).
| * | | | | | Only allocate new string when neededschneems2015-07-301-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of calling `sub` on every link_to call for controller, we can detect when the string __needs__ to be allocated and only then create a new string (without the leading slash), otherwise, use the string that is given to us. Saves 888 string objects per request, 35,524 bytes.
| * | | | | | Freeze a string in comparatorschneems2015-07-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Saves 888 string objects per request.
| * | | | | | Avoid calling to_s on nil in journey/formatterschneems2015-07-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When `defaults[key]` in `generate` in the journey formatter is called, it often returns a `nil` when we call `to_s` on a nil, it allocates an empty string. We can skip this check when the default value is nil. This change buys us 35,431 bytes of memory and 887 fewer objects per request. Thanks to @matthewd for help with the readability
| * | | | | | Cut string allocations in content_tag_stringschneems2015-07-296-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | content_tag's first argument is will generate a string with an html tag so `:a` will generate: `<a></a>`. When this happens, the symbol is implicitly `to_s`-d so a new string is allocated. We can get around that by using a frozen string instead which This change buys us 74,236 bytes of memory and 1,855 fewer objects per request.
| * | | | | | Cut string ActionView template allocationsschneems2015-07-291-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The instrument method creates new strings, the most common action to instrument is "!render_template` so we can detect when that action is occurring and use a frozen string instead. This change buys us 113,714 bytes of memory and 1,790 fewer objects per request.