1. 19 9月, 2015 1 次提交
  2. 28 8月, 2015 1 次提交
    • J
      10X speed improvements for AS::Dependencies.loadable_constants_for_path · 2e0cd0f3
      Jean Boussier 提交于
      When the autoload_paths start to grows, this methods is quite a hotspot
      
      >> ActiveSupport::Dependencies.autoload_paths.size
      => 49
      
      >> Benchmark.ips { |x| x.report('baseline') { ActiveSupport::Dependencies.loadable_constants_for_path(File.expand_path('app/models/shop')) }}
      Calculating -------------------------------------
                  baseline    90.000  i/100ms
      -------------------------------------------------
                  baseline      1.073k (±20.2%) i/s -      4.950k
      
      After the patch
      
      Calculating -------------------------------------
                   patched   883.000  i/100ms
      -------------------------------------------------
                   patched     11.050k (±19.7%) i/s -     50.331k
      2e0cd0f3
  3. 23 7月, 2015 1 次提交
  4. 20 7月, 2015 2 次提交
    • M
      We need stricter locking before we can unload · bd31aec9
      Matthew Draper 提交于
      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.
      bd31aec9
    • S
      Freeze string literals when not mutated. · 5bb1d4d2
      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)
      5bb1d4d2
  5. 09 7月, 2015 2 次提交
  6. 29 1月, 2015 1 次提交
  7. 05 1月, 2015 1 次提交
  8. 29 11月, 2014 1 次提交
  9. 11 11月, 2014 1 次提交
  10. 25 10月, 2014 1 次提交
    • X
      fixes circularity check in dependencies · ae078068
      Xavier Noria 提交于
      The check for circular loading should depend on a stack of files being
      loaded at the moment, rather than the collection of loaded files.
      
      This showed up indirectly in #16468, where a misspelled helper would
      incorrectly result in a circularity error message.
      
      References #16468
      ae078068
  11. 25 6月, 2014 1 次提交
  12. 20 6月, 2014 2 次提交
  13. 24 5月, 2014 1 次提交
  14. 09 2月, 2014 2 次提交
  15. 07 12月, 2013 1 次提交
    • X
      better error message for constants autoloaded from anonymous modules [fixes #13204] · 01c9782f
      Xavier Noria 提交于
      load_missing_constant is a private method that basically plays the role of const_missing.
      This method has an error condition that is surprising: it raises if the class or module
      already has the missing constant. How is it possible that if the class of module has
      the constant Ruby has called const_missing in the first place?
      
      The answer is that the from_mod argument is self except for anonymous modules, because
      const_missing passes down Object in such case (see the comment in the source code of the
      patch for the rationale).
      
      But then, it is better to pass down Object *if Object is also missing the constant* and
      otherwise err with an informative message right away.
      01c9782f
  16. 15 10月, 2013 1 次提交
  17. 01 10月, 2013 2 次提交
  18. 27 8月, 2013 1 次提交
    • S
      Ensure all-caps nested consts marked as autoloaded · b4a96686
      Simon Coffey 提交于
      Previously, an autoloaded constant `HTML::SomeClass` would not be marked
      as autoloaded by AS::Dependencies. This is because the
      `#loadable_constants_for_path` method uses `String#camelize` on the
      inferred file path, which in turn means that, unless otherwise directed,
      AS::Dependencies watches for loaded constants in the `Html` namespace.
      
      By passing the original qualified constant name to `#load_or_require`,
      this inference step is avoided, and the new constant is picked up in the
      correct namespace.
      b4a96686
  19. 18 6月, 2013 2 次提交
  20. 10 6月, 2013 1 次提交
  21. 14 12月, 2012 1 次提交
    • T
      Replace some global Hash usages with the new thread safe cache. · 45448a57
      thedarkone 提交于
      Summary of the changes:
       * Add thread_safe gem.
       * Use thread safe cache for digestor caching.
       * Replace manual synchronization with ThreadSafe::Cache in Relation::Delegation.
       * Replace @attribute_method_matchers_cache Hash with ThreadSafe::Cache.
       * Use TS::Cache to avoid the synchronisation overhead on listener retrieval.
       * Replace synchronisation with TS::Cache usage.
       * Use a preallocated array for performance/memory reasons.
       * Update the controllers cache to the new AS::Dependencies::ClassCache API.
         The original @controllers cache no longer makes much sense after @tenderlove's
         changes in 7b6bfe84 and f345e238.
       * Use TS::Cache in the connection pool to avoid locking overhead.
       * Use TS::Cache in ConnectionHandler.
      45448a57
  22. 05 12月, 2012 1 次提交
    • C
      Replace comments' non-breaking spaces with spaces · 019df988
      claudiob 提交于
      Sometimes, on Mac OS X, programmers accidentally press Option+Space
      rather than just Space and don’t see the difference. The problem is
      that Option+Space writes a non-breaking space (0XA0) rather than a
      normal space (0x20).
      
      This commit removes all the non-breaking spaces inadvertently
      introduced in the comments of the code.
      019df988
  23. 28 11月, 2012 1 次提交
  24. 15 11月, 2012 2 次提交
  25. 17 9月, 2012 1 次提交
  26. 06 9月, 2012 3 次提交
    • X
      we already have the module objects, do not constantize · 2ed325a3
      Xavier Noria 提交于
      I have also chosen a variable name that matches the
      parameter in the definition of load_missing_constant.
      2ed325a3
    • X
      restores awesome comment · 021cb85b
      Xavier Noria 提交于
      Those who say source code should be without comments lie.
      021cb85b
    • X
      no more const_missing combinatorics · 3ee191fd
      Xavier Noria 提交于
      Basically, const_missing had a loop to try parent namespaces
      if the constant lookup failed, but at the same time delegated
      to load_missing_constant which in turn also walks up parent
      namespaces calling const_missing by hand. In the case of missing
      constants this results in repeated work in some funky nested way.
      3ee191fd
  27. 04 9月, 2012 1 次提交
  28. 29 8月, 2012 2 次提交
  29. 28 8月, 2012 1 次提交
    • X
      fixes a bug in dependencies.rb · db8ff15a
      Xavier Noria 提交于
      loaded stores file names without the .rb extension, but search_for_file
      returns file names with the extension.
      
      The solution is hackish, but this file needs a revamp.
      db8ff15a
  30. 25 8月, 2012 1 次提交