1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
Commit graph

8 commits

Author SHA1 Message Date
Jeremy Kemper
b474d06d5e Perf: save ~9% of object allocations on heavy requests.
The per-thread registry is keyed on the class name, and each request for
the class name returns a new string. This is in the hot path for a lot
of Active Record behavior, so we easily accumulate thousands of repeated
strings.

To fix, we simply cache the key when the class is first extended with
the module.

TODO: Eliminate this module. The per-thread instance concept is common,
but this technique confuses and obfuscates.
2013-12-12 18:53:32 -07:00
Aaron Patterson
5584ddc43d Stop using method missing for singleton delegation.
This saved about 46 array allocations per request on an extremely simple
application.  The delegation happened in the notification subsystem
which is a hotspot, so this should result in even more savings with
larger apps.

Squashed commit of the following:

commit 41eef0d1479526f7de25fd4391d98e61c126d9f5
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Wed Nov 6 16:32:31 2013 -0800

    speed up notifications

commit 586b4a18656f66fb2c518fb8e8fee66a016e8ae6
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Wed Nov 6 16:31:05 2013 -0800

    speed up runtime registry methods

commit b67d074cb4314df9a88438f785868cef77e583d7
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Wed Nov 6 16:28:12 2013 -0800

    change method name and make it public
2013-11-06 16:32:47 -08:00
Francesco Rodriguez
9e82ffcada use define_singleton_method instead of class_eval 2013-04-13 12:14:12 -05:00
Francesco Rodriguez
364f579b8c Add :nodoc: mark to PerThreadRegistry#method_missing [ci skip] 2013-04-13 11:56:19 -05:00
Xavier Noria
e5ef3abdd2 hides the per thread registry instance, and caches singleton methods
Existing code was delegating to the instance with delegate
macro calls, or invoking the instance method to reach
the object and call its instance methods.

But the point is to have a clean class-level interface where
the thread local instance is hidden in the implementation.

References #11c6973.
References #10198.
2013-04-13 17:09:13 +02:00
Xavier Noria
2d42fe7fb5 complete rewrite of the documentation of AS::PerThreadRegistry
* It focuses on how to use it.

* Removes some ambigueties in the original docs about whether the state is stored in the class.

* Documents it provides class-level accessors via method_missing.

* Documents that if the extended class has an initializer, it must accept no arguments.
2013-04-13 08:21:38 +02:00
wangjohn
60a5ac78b0 Using public send instead of send for the PerThreadRegistry module.
Prevents you from accidentally calling a protected method.
2013-04-10 09:56:40 -04:00
wangjohn
e94f024e14 Creating a module so that per thread registries can be easily created as
thread local variables.
2013-04-09 22:27:21 -04:00