aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* 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-204-34/+49
| | | | | | | | | | | | 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.
* Fix tests broken by previous commitSean Griffin2015-07-191-1/+1
|
* Merge pull request #20946 from schneems/schneems/let-it-goSean Griffin2015-07-1932-60/+60
|\ | | | | Freeze string literals when not mutated.
| * Freeze string literals when not mutated.schneems2015-07-1932-60/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* | Merge pull request #20936 from repinel/fix-params-fetch-exception-overwrittenSean Griffin2015-07-193-3/+25
|\ \ | | | | | | Fix exception overwritten for parameters fetch method
| * | Fix exception overwritten for parameters fetch methodRoque Pinel2015-07-183-3/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | When executing an `ActionController::Parameters#fetch` with a block that raises a `KeyError` the raised `KeyError` will be rescued and converted to an `ActionController::ParameterMissing` exception, covering up the original exception. [Jonas Schubert Erlandsson & Roque Pinel]
* | | Merge Pull Request #16445Sean Griffin2015-07-196-5/+35
|\ \ \
| * | | Fix the test that was broken by #16445 rather than deleting itSean Griffin2015-07-191-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since the counter cache was properly being updated, the model became stale. Simply reloading the model before attempting to destroy is sufficient for this case. I believe this is enough of an edge case to be a valid change to the tests, even though it represents a potential breaking change.
| * | | Fix counter_cache for polymorphic associationsStefan Kanev2015-07-196-16/+34
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also removes a false positive test that depends on the fixed bug: At this time, counter_cache does not work with polymorphic relationships (which is a bug). The test was added to make sure that no StaleObjectError is raised when the car is destroyed. No such error is currently raised because the lock version is not incremented by appending a wheel to the car. Furthermore, `assert_difference` succeeds because `car.wheels.count` does not check the counter cache, but the collection size. The test will fail if it is replaced with `car.wheels_count || 0`.
* | | Merge pull request #20944 from repinel/fix-time-with-zone-eqlKasper Timm Hansen2015-07-193-1/+13
|\ \ \ | |_|/ |/| | Fix `TimeWithZone#eql?` to handle `TimeWithZone` created from `DateTime`
| * | Fix `TimeWithZone#eql?` to handle `TimeWithZone` created from `DateTime`Roque Pinel2015-07-193-1/+13
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: ```ruby twz = DateTime.now.in_time_zone twz.eql?(twz.dup) => false ``` Now: ```ruby twz = DateTime.now.in_time_zone twz.eql?(twz.dup) => true ``` Please notice that this fix the `TimeWithZone` comparison to itself, not to `DateTime`. Based on #3725, `DateTime` should not be equal to `TimeWithZone`.
* | Merge pull request #20931 from eliotsykes/force_ssl-docs-options-formattingKasper Timm Hansen2015-07-191-6/+6
|\ \ | | | | | | Fix formatting of force_ssl options documentation [ci skip]
| * | Fix formatting of force_ssl options documentation [ci skip]Eliot Sykes2015-07-191-6/+6
|/ /
* | Merge pull request #20924 from andrii/masterAbdelkader Boudih2015-07-191-1/+1
|\ \ | | | | | | [ci skip] Fix typo in #any? RDoc
| * | [ci skip] Fix typo in #any? RDocAndrii Ponomarov2015-07-171-1/+1
| | |
* | | Merge pull request #20839 from ↵Sean Griffin2015-07-181-9/+34
|\ \ \ | |_|/ |/| | | | | | | | TheBlasfem/added_examples_dateandtime_calculations Added examples to DateAndTime::Calculations [ci skip]
| * | added examples to DateAndTime::Calculations [ci skip]Julio Lopez2015-07-181-9/+34
| | |
* | | Merge pull request #20932 from twalpole/collection_association_parametersSean Griffin2015-07-182-1/+19
|\ \ \ | | | | | | | | Ensure that 'ActionController::Parameters' can still be passed to AR …
| * | | Ensure that 'ActionController::Parameters' can still be passed to AR for ↵Thomas Walpole2015-07-182-1/+19
| | | | | | | | | | | | | | | | collection associations
* | | | Ensure cyclic associations w/ autosave don't cause duplicate errorsSean Griffin2015-07-185-0/+37
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Merge pull request #20763 from maurogeorge/default_scope_create-docSean Griffin2015-07-181-0/+12
|\ \ \ | | | | | | | | Add a note about default_scope and create records [ci skip]
| * | | Add a note about default_scope and create recordsMauro George2015-07-161-0/+12
| | | | | | | | | | | | | | | | [ci skip]
* | | | Ensure that `ActionController::Parameters` can still be passed to ARSean Griffin2015-07-183-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | Merge pull request #20930 from prathamesh-sonpatki/rm-render-textSean Griffin2015-07-181-1/+1
|\ \ \ \ | | | | | | | | | | Replaced render :text with render :plain in AC gem bug report template
| * | | | Replaced render :text with render :plain in AC gem bug report templatePrathamesh Sonpatki2015-07-181-1/+1
|/ / / / | | | | | | | | | | | | | | | | - Followup of https://github.com/rails/rails/pull/20929. [ci skip]
* | | | Merge pull request #20929 from y-yagi/fix_deprecated_warningKasper Timm Hansen2015-07-181-1/+1
|\ \ \ \ | | | | | | | | | | use `plain` option instead of deprecated `text` option
| * | | | use `plain` option instead of deprecated `text` optionyuuji.yaginuma2015-07-181-1/+1
|/ / / / | | | | | | | | | | | | this will silence deprecation warnings
* | | | Merge pull request #20923 from sikachu/silence-render-text-warningMatthew Draper2015-07-1841-245/+247
|\ \ \ \ | | | | | | | | | | Stop using deprecated `render :text` in test
| * | | | Stop using deprecated `render :text` in testPrem Sichanugrist2015-07-1741-245/+247
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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`.
* | | | Merge pull request #20917 from sikachu/ps-deprecate-render-textJeremy Daer (Kemper)2015-07-172-11/+56
|\ \ \ \ | |_|_|/ |/| | | Add deprecation warning for `render :text`
| * | | Add deprecation warning for `render :text`Prem Sichanugrist2015-07-172-11/+56
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | push fields_for_style? in to a protected methodAaron Patterson2015-07-171-5/+5
| | | | | | | | | | | | | | | | | | | | this way we don't need to call `to_unsafe_h` to get access to ask questions about the underlying hash
* | | | Merge pull request #20902 from sikachu/silence-association-reload-warningSean Griffin2015-07-1710-105/+125
|\ \ \ \ | | | | | | | | | | Silence deprecation warning from force reload
| * | | | Silence deprecation warning from force reloadPrem Sichanugrist2015-07-1610-105/+125
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We deprecate the support for passing an argument to force reload in 6eae366d0d2e5d5211eeaf955f56bd1dc6836758. That led to several deprecation warning when running Active Record test suite. This commit silence the warnings by properly calling `#reload` on the association proxy or on the association object instead. However, there are several places that `ActiveSupport::Deprecation.silence` are used as those tests actually tests the force reload functionality and will be removed once `master` is targeted next minor release (5.1).
* | | | | push is_a checks up the stackAaron Patterson2015-07-171-13/+13
| | | | | | | | | | | | | | | | | | | | now `hash_filter` doesn't need to know about the `Parameters` class
* | | | | remove useless conditionalAaron Patterson2015-07-171-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | Since we proved that `element` is always of type `Parameter`, we know that it will always respond to `permit`, so lets remove this conditional
* | | | | Merge pull request #20125Sean Griffin2015-07-173-0/+19
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | Manually merged to fix conflicts.
| * | | | | ActiveSupport::HashWithIndifferentAccess select and reject should return ↵Bernard Potocki2015-07-173-0/+19
|/ / / / / | | | | | | | | | | | | | | | enumerator if called without block
* | | | | remove useless conditionalsAaron Patterson2015-07-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `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
* | | | | remove useless functionAaron Patterson2015-07-171-8/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | | stop passing `params` to `array_of_permitted_scalars_filter`Aaron Patterson2015-07-171-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | | push key checking upAaron Patterson2015-07-171-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | | Merge pull request #20918 from jonatack/fix-lookup-grammarRafael Mendonça França2015-07-177-14/+17
|\ \ \ \ \ | |_|/ / / |/| | | | [skip ci] Lookup can be a noun but it is not a verb
| * | | | [skip ci] Lookup can be a noun but it is not a verbJon Atack2015-07-177-14/+17
|/ / / / | | | | | | | | | | | | Various grammar corrections and wrap to 80 characters.
* | | | Merge pull request #20915 from robin850/jruby-skipsSean Griffin2015-07-173-0/+8
|\ \ \ \ | | | | | | | | | | Skip a few failing tests on JRuby with the attached tickets
| * | | | Skip a few failing tests on JRuby with the attached ticketsRobin Dupret2015-07-173-0/+8
|/ / / /