These are chat archives for ManageIQ/manageiq/performance

24th
Nov 2015
Joe Rafaniello
@jrafanie
Nov 24 2015 16:00
@kbrock do you have a big database to confirm something for me?
ie, one from @akrzos's big envioronment refreshes?
or @dmetzger57 if you're there
I think this misconfigured cache on the relationship mixin is a big performance fix
I don't believe it so I'm running it again
Alex Krzos
@akrzos
Nov 24 2015 16:04
@jrafanie feel free to connect to the big environment if you need to do so
Joe Rafaniello
@jrafanie
Nov 24 2015 16:04
thanks @akrzos, I have the db... just want to make sure I'm doing things right
reports that hit the relationships cache bug are now 1/3 faster
roughly
Jason Frey
@Fryguy
Nov 24 2015 16:05
:+1:
Gregg Tanzillo
@gtanzillo
Nov 24 2015 16:06
Nice!
Jason Frey
@Fryguy
Nov 24 2015 16:06
@jrafanie I'm interested to see the code :)
did you do it by keying on the relationship type like we discussed? or something else?
Joe Rafaniello
@jrafanie
Nov 24 2015 16:06
checkout out this enormous change
diff --git a/app/models/mixins/relationship_mixin.rb b/app/models/mixins/relationship_mixin.rb
index bdc5f82..de522c6 100644
--- a/app/models/mixins/relationship_mixin.rb
+++ b/app/models/mixins/relationship_mixin.rb
@@ -28,7 +28,7 @@ module RelationshipMixin

     has_many :all_relationships, :class_name => "Relationship", :dependent => :destroy, :as => :resource

-    memoize *MEMOIZED_METHODS
+    memoize *MEMOIZED_METHODS, :identifier => Class === self ? self.name : self.class.name
   end
Jason Frey
@Fryguy
Nov 24 2015 16:07
wow...memoize does that?
Joe Rafaniello
@jrafanie
Nov 24 2015 16:07
I believe we were expiring the cache on VmOrTemplate instead of the subclass
Jason Frey
@Fryguy
Nov 24 2015 16:07
it's not a clas level thing though
I think that might not be correct for the multi-tree case, but we can discuss
Joe Rafaniello
@jrafanie
Nov 24 2015 16:09
it's using the method name and identifier (nil currently) to create a ivar on the base class, I believe
Jason Frey
@Fryguy
Nov 24 2015 16:10
right, but that's the issue
children for the realtionship_type of "ems_metadata" is different from the childnre for the relationship_type of "genealogy"
so when you switch, the cache must be cleared
which is also what's killing it
so I would think the relationship_type would have to be part of the key somehow
Joe Rafaniello
@jrafanie
Nov 24 2015 16:14
Right, so, I don't follow the whole ems_metadata/genealogy thing... I'm just instrumenting the "cache hits, misses, and flushes"
before and after I get the same number of cache hits
and same misses
Jason Frey
@Fryguy
Nov 24 2015 16:15
right, I would not expect that to change
Joe Rafaniello
@jrafanie
Nov 24 2015 16:15
but I get no cache flushes, after
Jason Frey
@Fryguy
Nov 24 2015 16:15
That doesn't make sense to me
if you flush that makes the next one a cache miss
if you don't it's a hit
so I would expect hits to go up if you don't flush
Joe Rafaniello
@jrafanie
Nov 24 2015 16:16
Sorry, I get flushes but no cases where it actually deletes the ivar capturing the cached result
Jason Frey
@Fryguy
Nov 24 2015 16:16
but is the ivar cleared?
Joe Rafaniello
@jrafanie
Nov 24 2015 16:22
no, it looks like memoist has a bug with flush_cache when you specified an identifier on the memoize line
Joe Rafaniello
@jrafanie
Nov 24 2015 16:34
ok, thanks for asking WAT @Fryguy memoist, looks like it's buggy here, where it sets the ivar vs. here where it clears the ivar if it exists
be offline for a bit, I'll dig more into the relationship_type
Keenan Brock
@kbrock
Nov 24 2015 17:27
@jrafanie wow - that ROCKS. thanks