Custom Wizard Plugin 🧙


According to the ?pp=flamegraph output, this plugin seems to be slowing down stuff like HTML-rendered topic pages a bit on our instance:

/usr/local/lib/ruby/2.6.0/monitor.rb:230:in `MonitorMixin#mon_synchronize'	(218 samples - 48.55%)
… lru_redux-1.1.0/lib/lru_redux/util/safe_sync.rb:30:in `LruRedux::Util::SafeSync#fetch'	(208 samples - 46.33%)
/var/www/discourse/lib/freedom_patches/inflector_backport.rb:25:in `block (2 levels) in memoize'	(208 samples - 46.33%)
… activesupport- `String#underscore'	(208 samples - 46.33%)
/var/www/discourse/plugins/discourse-custom-wizard/extensions/custom_field/serializer.rb:25:in `CustomWizardCustomFieldSerializer#get_cw_class'	(209 samples - 46.55%)

(total amount of samples for this page load - /t/SOMEID?pp=flamegraph - was around 446)

We’re not using any custom fields on posts/topics (and especially not the topic just opened), and as an experiment, commenting out the CustomWizardCustomFieldSerializer#attributes override seems to have had a noticeably positive effect on site performance, taking the ‘Topic page 99th percentile performance’ statistic in our Grafana from 400-600ms instantly to a more manageable 250-350ms, and also improving perceived performance by a fair bit.

It also seems String#underscore being slow is a known concern, since there’s a fast_underscore project on GitHub for example.

1 Like