These are chat archives for ManageIQ/manageiq/performance

31st
Jul 2018
Daniel Berger
@djberg96
Jul 31 2018 18:00
@NickLaMuro Still pondering our object creation in azure-armrest, came across this, dunno if it's relevant: http://blog.honeybadger.io/objects-as-ruby-hash-keys/
was also looking at ActiveRecord::Model::Serializers::JSON, but it doesn't seem to handle nested keys
Nick LaMuro
@NickLaMuro
Jul 31 2018 18:11

okay, just got done wrapping my head around that post...

@djberg96 Okay, so what are you pondering about specifically?

just trying to make it faster?
Keenan Brock
@kbrock
Jul 31 2018 18:11
the thing that sticks out the most with global method cache
if you are doing fun stuff to define attributes, it blows the cache every time
Daniel Berger
@djberg96
Jul 31 2018 18:13
@NickLaMuro more memory efficient in general i guess
Nick LaMuro
@NickLaMuro
Jul 31 2018 18:19

was also looking at ActiveRecord::Model::Serializers::JSON

Been a while since I looked at it, but I am not so sure it is the JSON serialization that was the issue, but what we are doing with it once it was unserialized.

From what I remember (correct me if I am wrong), we were downloading the data from the azure API, and then with the data we received, we would determine what objects types needed to be instantiated from that, massage the data into a snake_cased format, and possibly define methods based on the keys from the result.

If I remember correctly, we did this for each object instantiated, not just for the objects as a whole. This has a plus of being "future proof" library (and avoids us being at the mercy of Azure's API changes), but a major downside of we are instantiating a lot of objects at once (MIQ's bread and butter), we eat that performance penalty for every object.

The brute force "screw it... I want all the perfs" solution would be to just hardcode ALL THE THINGS into azure-armrest, and have methods like:

def some_azure_key_thing
  json["SomeAzureKeyThing".freeze]
end

def some_azure_key_thing=(new_val)
  json["SomeAzureKeyThing".freeze] = new_val
end

All over the place, and it's "faster". But pretty sure nobody wants to do that...

Daniel Berger
@djberg96
Jul 31 2018 18:25
with ActiveRecord::Model::Serializers::JSON you get a from_json method which, combined with attr_accessor, gives you an equivalent method for each hash key
but it only goes one level deep - the implementation, after i looked at it, is very basic
(btw yes, your assessment is correct)