Feature #3905: rb_clear_cache_by_class() called often during GC for non-b=
locking I/O
http://redmine.ruby-lang.org/issues/show/3905

Author: Eric Wong
Status: Open, Priority: Low
Category: core, Target version: 1.9.x

This still causes performance problems with frequent EAGAIN compared to 1=
.9.1

While akr fixed extend to no longer clear cache with empty modules in r28=
813,
the GC phase still scans and clears the cache when the extended object is=

collected.

ref: [ruby-core:32507], [ruby-core:32508]

A proposed patch to add memoizing of extended objects with
IO::Wait{Read,Writ}able is attached.  Comments/feedback appreciated.


----------------------------------------
http://redmine.ruby-lang.org
RnJvbSBmMGMyNzRlOWU4NzYzNGY0NzUxNWE2OGJiMTg2OTNkOWQ4NDIzYmM4
IE1vbiBTZXAgMTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBFcmljIFdvbmcgPG5v
cm1hbHBlcnNvbkB5aGJ0Lm5ldD4KRGF0ZTogV2VkLCAyMiBTZXAgMjAxMCAx
NzoyMDoyOCAtMDcwMApTdWJqZWN0OiBbUEFUQ0hdIGVycm9yLmMgKHJiX21v
ZF9zeXNfZmFpbCk6IHVzZSBzdWJjbGFzcyBhbmQgY2FjaGUKCldoaWxlIHIy
ODgxMyBhdm9pZHMgY2xlYXJpbmcgdGhlIG1ldGhvZCBjYWNoZSB1cG9uIGV4
dGVuZGluZwp3aXRoIElPOjpXYWl0e1JlYWQsV3JpdH1hYmxlIG1vZHVsZXMs
IHRoZSBtZXRob2QgY2FjaGUgc3RpbGwKZ2V0cyB3aGVuIHRoZSBleGNlcHRp
b25zIGFyZSBnYXJiYWdlIGNvbGxlY3RlZC4KClJldXNpbmcgdGhlIHNhbWUg
c3ViY2xhc3Mgbm93IHByZXZlbnRzIHJiX2NsZWFyX2NhY2hlX2J5X2NsYXNz
KCkKZnJvbSBzaG93aW5nIHVwIGF0L25lYXIgdGhlIHRvcCBvZiBwcm9maWxl
ciBvdXRwdXQuCi0tLQogZXJyb3IuYyB8ICAgNDAgKysrKysrKysrKysrKysr
KysrKysrKysrKysrKysrKysrKysrKystLQ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