Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #8576 (closed defect: incomplete)

Opened 1 year ago

Last modified 1 year ago

[PATCH] Module#local_constants is slow as dirt

Reported by: zenspider Assigned to: bitsweat
Priority: normal Milestone: 1.x
Component: ActiveSupport Version: edge
Severity: normal Keywords: tiny, patch, optimization
Cc:

Description

Every time I profile a single test Hash#key? and #select drive up into the top 5. Poking around points entirely at this method which has way too much in it for what it does.

Attachments

introspection_optimization.patch (0.9 kB) - added by zenspider on 06/04/07 21:43:52.

Change History

06/04/07 21:43:52 changed by zenspider

  • attachment introspection_optimization.patch added.

06/04/07 21:44:46 changed by zenspider

  • keywords set to tiny, patch, optimization.
  • owner changed from core to bitsweat.
  • component changed from ActiveRecord to ActiveSupport.

06/06/07 10:52:33 changed by marclove

  • summary changed from [patch] Module#local_constants is slow as dirt to [PATCH] Module#local_constants is slow as dirt.

06/06/07 16:49:11 changed by bitsweat

  • status changed from new to closed.
  • resolution set to incomplete.

This misses a case

module Foo
  A = 1
end

class Bar
  include Foo
  A = 'b'
end

Bar.local_constants should return A? so Bar::A will be reloaded, but this patch will return A? since it can't distinguish the mixed-in Foo::A from Bar::A.

Also, caching the local constants can't work since they're reloaded per request in development. In production, reloading and hence this method aren't used.

Ironing out these hotspots is welcome but I haven't figured out how to crack this one without doing a bunch of const_get to compare the objects the constants reference.