Optimizing the Praxis rendering pipeline

26 views
Skip to first unread message

Justin Gaylor

unread,
Sep 7, 2016, 6:51:35 PM9/7/16
to praxis-support
Hi Praxis folks,

I have a service I'm working on that is particularly CPU-intensive. I've profiled it and determined that it spends about 2/3 of its time rendering its mediatypes, during which it uses 100% of the CPU.

Below are the average timings I collected regarding where the service spends its time for a single Thingy#index call (taking the average of about 10 calls):
 - Loading records from DB (4 seconds, ~27% total time)
 - Dumping praxis mediatypes to Hashes (10 seconds, 67% total time)
 - Serializing hashes to JSON (1 second, ~6% total time)

Note: This call returns about 40K resources -- so it is very crazy, I know -- but I'm wondering if there are any low-lying optimization fruit in the rendering of Praxis mediatypes?

Here is the actual call I'm making:

result_hash = data[:result].map { |resource| V1_6::MediaTypes::Thingy.dump(resource, view: view.to_sym) }

This is the segment of code that takes about 10 secs for 40K thingies. Not sure if there is anything that can be done to optimize the rendering pipeline, but if so it would be much appreciated.

Please let me know if you need more information or if I can be of any assistance.

Thank,
Justin
Reply all
Reply to author
Forward
0 new messages