aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'master' of github.com:rails/railsVijay Dev2015-08-2443-278/+884
|\ | | | | | | | | Conflicts: guides/source/security.md
| * Merge pull request #16245 from byroot/more-atomic-writeMatthew Draper2015-08-211-27/+29
| |\ | | | | | | File renaming should be the last operation of an atomic write
| | * File renaming should be the last operation of an atomic writeJean Boussier2015-08-201-27/+29
| | |
| * | Merge pull request #21300 from jonahb/cacheYves Senn2015-08-201-1/+1
| |\ \ | | | | | | | | Correct cache store superclass in comment [ci skip]
| | * | Correct cache store superclass in commentJonah Burke2015-08-191-1/+1
| | | |
| * | | Merge pull request #21279 from ronakjangir47/test_cleanupKasper Timm Hansen2015-08-202-2/+10
| |\ \ \ | | |/ / | |/| | Cleaned up generators tests using internal assertion helper
| | * | Cleaned up generators tests using internal assertion helperRonak Jangir2015-08-202-2/+10
| | |/
| * / Use == 0 instead of .zero? in #tryJean Boussier2015-08-171-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The perf gain is relatively minor but consistent: ``` Calculating ------------------------------------- 0.zero? 137.091k i/100ms 1.zero? 137.350k i/100ms 0 == 0 142.207k i/100ms 1 == 0 144.724k i/100ms ------------------------------------------------- 0.zero? 8.893M (± 6.5%) i/s - 44.280M 1.zero? 8.751M (± 6.4%) i/s - 43.677M 0 == 0 10.033M (± 7.0%) i/s - 49.915M 1 == 0 9.814M (± 8.0%) i/s - 48.772M ``` And try! is quite a big hotspot for us so every little gain is appreciable.
| * Replacing lambda with proc getting argument error because of it.Ronak Jangir2015-08-172-1/+7
| |
| * Merge pull request #20647 from twalpole/method_source_dependencyRafael Mendonça França2015-08-141-0/+1
| |\ | | | | | | Add method_source dependency to activesupport
| | * Add method_source dependency to activesupportThomas Walpole2015-07-291-0/+1
| | |
| * | Merge pull request #21025 from ronakjangir47/assertsKasper Timm Hansen2015-08-132-1/+18
| |\ \ | | | | | | | | Added helper methods to stub any instance
| | * | Added helper methods to stub any instanceRonak Jangir2015-08-132-1/+18
| | | |
| * | | Merge pull request #21219 from repinel/assert-human-size-prefix-deprecatedYves Senn2015-08-131-8/+10
| |\ \ \ | | | | | | | | | | Assert that the `:prefix` option of `number_to_human_size` is deprecated
| | * | | Assert that the `:prefix` option of `number_to_human_size` is deprecatedRoque Pinel2015-08-121-8/+10
| | | | |
| * | | | Merge pull request #21217 from myrridin/myrridin-documentation-updatesZachary Scott2015-08-122-4/+4
| |\ \ \ \ | | |/ / / | |/| | | [ci skip] Documentation: Switch around a common phrase for readability
| | * | | [ci skip] Switch around a common idiom for readabilityThomas Hart II2015-08-052-4/+4
| | | |/ | | |/|
| * | | [ci skip] Fix rdoc markupakihiro172015-08-121-1/+1
| | |/ | |/|
| * | :nodoc: internal class [ci skip]Godfrey Chan2015-08-101-1/+1
| | |
| * | Deprecate :si prefix in number_to_human_size without replacementJean Boussier2015-08-102-9/+15
| | |
| * | Deprecate the :prefix option of `number_to_human_size`Jean Boussier2015-08-102-2/+4
| | |
| * | Merge pull request #21124 from kirs/feature/reload-i18nKasper Timm Hansen2015-08-101-2/+17
| |\ \ | | | | | | | | Reload I18n.load_path in development
| | * | Reload I18n locales in developmentKir Shatrov2015-08-101-2/+17
| | | |
| * | | Merge pull request #21173 from repinel/fix-callback-terminator-docsClaudio B.2015-08-081-3/+3
| |\ \ \ | | | | | | | | | | [ci skip] Fix the AS::Callbacks terminator docs
| | * | | [ci skip] Fix the AS::Callbacks terminator docsRoque Pinel2015-08-081-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The second argument of the terminator lambda is no longer the result of the callback, but the result lambda. https://github.com/rails/rails/blob/3a7609e2bafee4b071fe35136274e6ccbae8cacd/activesupport/test/callbacks_test.rb#L553
| * | | | replace each with each_key when only the key is neededAaron Lasseigne2015-08-081-1/+1
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using each_key is faster and more intention revealing. Calculating ------------------------------------- each 31.378k i/100ms each_key 33.790k i/100ms ------------------------------------------------- each 450.225k (± 7.0%) i/s - 2.259M each_key 494.459k (± 6.3%) i/s - 2.467M Comparison: each_key: 494459.4 i/s each: 450225.1 i/s - 1.10x slower
| * | | Regexp#=== is faster than String#=~schneems2015-08-071-1/+1
| | | | | | | | | | | | | | | | Discussion https://github.com/JuanitoFatas/fast-ruby/pull/59#issuecomment-128513763
| * | | Only invoke the default block for mattr_accessor once so that it does not ↵Lachlan Sylvester2015-08-072-1/+7
| | | | | | | | | | | | | | | | cause issues if it is not idempotent
| * | | speed up code and avoid unnecessary MatchData objectsAaron Lasseigne2015-08-061-1/+1
| |/ /
| * | Merge pull request #21087 from vngrs/fix_hash_except_docKasper Timm Hansen2015-08-031-8/+9
| |\ \ | | | | | | | | Fix the documentation of Hash#except method [ci skip]
| | * | Fix the documentation of Hash#except method [ci skip]Mehmet Emin İNAÇ2015-08-031-8/+9
| | | | | | | | | | | | | | | | fix minor problems
| * | | [ci skip] Update Time#advance documentation with examplesMichael Stock2015-08-021-0/+6
| |/ /
| * | 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.
| * | Decrease string allocations in apply_inflectionsschneems2015-07-292-5/+36
| |/ | | | | | | | | | | In `apply_inflections` a string is down cased and some whitespace stripped in the front (which allocate strings). This would normally be fine, however `uncountables` is a fairly small array (10 elements out of the box) and this method gets called a TON. Instead we can keep an array of valid regexes for each uncountable so we don't have to allocate new strings. This change buys us 325,106 bytes of memory and 3,251 fewer objects per request.
| * Tiny documentation edits [ci skip]Robin Dupret2015-07-281-1/+1
| |
| * Add `:nodoc:` for internal testing methods [ci skip]Robin Dupret2015-07-281-2/+2
| |
| * Merge pull request #20928 from matthewd/unload-interlockMatthew Draper2015-07-244-34/+384
| |\ | | | | | | We need stricter locking before we can unload
| | * Small tweaks to mainly lock-ordering tests.thedarkone2015-07-221-21/+58
| | | | | | | | | | | | | | | | | | * only test the upgrade path, * add test to verify non upgrades can’t preempt, * add reentrancy assertion.
| | * Handle thread death during lock acquisitionMatthew Draper2015-07-212-4/+27
| | | | | | | | | | | | | | | | | | Specifically, clean up if the thread is killed while it's blocked awaiting the lock... if we get killed on some other arbitrary line, the result remains quite undefined.
| | * Adjust expectations around purpose/compatibility optionsMatthew Draper2015-07-212-9/+36
| | |
| | * Add some meta-assertions for the custom assertionsMatthew Draper2015-07-211-11/+63
| | | | | | | | | | | | | | | | | | I accidentally discovered `assert_threads_not_stuck` couldn't fail, so the simplest solution was to prove they're all now working in both directions.
| | * Order of execution is only guaranteed if upgradingMatthew Draper2015-07-212-2/+4
| | | | | | | | | | | | | | | If the thread isn't yet holding any form of lock, it has no claim over what may / may not run while it's blocked.
| | * Fix ShareLock issues.thedarkone2015-07-201-2/+2
| | |
| | * Tests for AS::Concurrency::ShareLock.thedarkone2015-07-201-0/+194
| | |
| | * We need stricter locking before we can unloadMatthew Draper2015-07-203-33/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifically, the "loose upgrades" behaviour that allows us to obtain an exclusive right to load things while other requests are in progress (but waiting on the exclusive lock for themselves) prevents us from treating load & unload interchangeably: new things appearing is fine, but they do *not* expect previously-present constants to vanish. We can still use loose upgrades for unloading -- once someone has decided to unload, they don't really care if someone else gets there first -- it just needs to be tracked separately.
| * | Don't apply locking around basic #load / #requireMatthew Draper2015-07-231-6/+4
| |/ | | | | | | | | | | That's outside our remit, and dangerous... if a caller has their own locking to protect against the natural race danger, we'll deadlock against it.
| * Fix tests broken by previous commitSean Griffin2015-07-191-1/+1
| |
| * Merge pull request #20946 from schneems/schneems/let-it-goSean Griffin2015-07-198-20/+20
| |\ | | | | | | Freeze string literals when not mutated.
| | * Freeze string literals when not mutated.schneems2015-07-198-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)