Issue #9262 has been updated by sam.saffron (Sam Saffron).


Discourse Bench, 

Disabled Method Cache vs Current cache vs 16x larger method cache vs Funny Falcon 


Disabled Method cache:

Your Results: (note for timings- percentile is first, duration is second in millisecs)
---
home_page:
  50: 43
  75: 44
  90: 48
  99: 67
topic_page:
  50: 14
  75: 15
  90: 16
  99: 39
home_page_admin:
  50: 57
  75: 60
  90: 64
  99: 89
topic_page_admin:
  50: 23
  75: 24
  90: 26
  99: 35
timings:
  load_rails: 2733
ruby-version: 2.1.0-p-1
architecture: amd64
operatingsystem: Ubuntu
kernelversion: 3.11.0
memorysize: 5.89 GB
physicalprocessorcount: 1
processor0: Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz

Current Method Cache:

---
home_page:
  50: 37
  75: 39
  90: 43
  99: 60
topic_page:
  50: 12
  75: 13
  90: 14
  99: 40
home_page_admin:
  50: 48
  75: 50
  90: 55
  99: 77
topic_page_admin:
  50: 20
  75: 21
  90: 23
  99: 32
timings:
  load_rails: 2721
ruby-version: 2.1.0-p-1
architecture: amd64
operatingsystem: Ubuntu
kernelversion: 3.11.0
memorysize: 5.89 GB
physicalprocessorcount: 1
processor0: Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz


16x larger method cache

Your Results: (note for timings- percentile is first, duration is second in millisecs)
---
home_page:
  50: 35
  75: 38
  90: 41
  99: 67
topic_page:
  50: 11
  75: 11
  90: 13
  99: 34
home_page_admin:
  50: 45
  75: 47
  90: 52
  99: 79
topic_page_admin:
  50: 18
  75: 19
  90: 20
  99: 29
timings:
  load_rails: 2761
ruby-version: 2.1.0-p-1
architecture: amd64
operatingsystem: Ubuntu
kernelversion: 3.11.0
memorysize: 5.89 GB
physicalprocessorcount: 1
processor0: Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz


Funny Falcon


Your Results: (note for timings- percentile is first, duration is second in millisecs)
---
home_page:
  50: 34
  75: 35
  90: 38
  99: 53
topic_page:
  50: 10
  75: 11
  90: 12
  99: 37
home_page_admin:
  50: 43
  75: 45
  90: 49
  99: 68
topic_page_admin:
  50: 18
  75: 19
  90: 20
  99: 32
timings:
  load_rails: 2771
ruby-version: 2.1.0-p-1
architecture: amd64
operatingsystem: Ubuntu
kernelversion: 3.11.0
memorysize: 5.89 GB
physicalprocessorcount: 1
processor0: Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz


---

Observations:

Funny Falcon patch is clearly fastest, x10 cache size improvement makes a very big difference, method caching impact is about 20% give or take a bit.





----------------------------------------
Bug #9262: global_method_cache should be configurable or grow automatically
https://bugs.ruby-lang.org/issues/9262#change-43847

Author: tmm1 (Aman Gupta)
Status: Open
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: 
Target version: next minor
ruby -v: trunk
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


The global_method_cache is currently a fixed 2048 entries. This is not configurable, and can be inadequate for large applications with thousands of classes and methods.

In our app, increasing the size of the cache to 32768 entries reduced time spent in search_method and overall pressure on st_lookup:

before
      420  14.0% st_lookup
      182   6.1% vm_search_method (inline)

after
      265   9.5% st_lookup
      125   4.5% vm_search_method (inline)

It's possible the VM could grow global_method_cache automatically, using some heuristic based on the number of long-lived classes or method_entries that are defined.
However this would break the hashing in the current implementation.


-- 
http://bugs.ruby-lang.org/