Skip to content

Performance improvement possibilities

pkqk edited this page Nov 27, 2014 · 1 revision

Done

Most of of questionnaire loading has been converted to use ActiveRecord queries and scopes instead of loading subsections of the tables and selecting/maping over them. Eager loading has been put in where I could find opportunities.

NewRelic has been removed as it appears to have been slowing down page generation a lot, this may have either been a feedback issue from the page being slow and it then trying to profile slow sections. Once the site is faster it may be able to be re-enabled.

I have removed the use of underscore.js as it only provided functionality duplicated by jQuery and Hogan which were already present, this has saved 5KB in the javascript package.

Backend

There is probably more room for data to be eager loaded.

An audit on the indexes for tables would probably produce some improvements, there are cases of duplicated indexes or where there is only an id index where adding secondary columns might help common queries.

De-normalizing surveyor data model

Surveyor stores the data for the questionnaire in a very spread out form with data spread across several tables for flexibility. This works for recording data but is less efficient for display as it has to recompute values a lot. Published certificates could have a much simpler data model.

Frontend

The size of the html for the questionnaire form is enormous and unnecessarily so, due mostly to the way formtastic puts all elements into lists (including hidden form elements).

The way the combination of formtastic/surveyor helpers are being used is currently generating quite a mess of invalid html, valid well thought out markup would be both simpler to maintain and possibly render faster as the css could be simplified as well.

There is also room for templating the warning messages and not leaving all possibilities in the markup to be shown when required.