From 7c5a448f63d296feda75784e418a0defa753355e Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 21 Jan 2016 22:43:56 +1100 Subject: [PATCH] PERF: remove 10-20ms of work from every page view <% s=Time.now; main_app.categories_path main_app.guidelines_path main_app.tos_path main_app.privacy_path p (Time.now-s)*1000%> Returns 10-20ms consistently on i7-4770k, on shared hosts the cost could easily reach 40ms This code simply calculates the strings /categories /guidelines /tos /privacy It is ludicrous to spend this enormous amount of work just to calculate 4 strings. I do not know if this is something specific about Discourse or a bug in Rails (I tried without the main_app prefix and got similar results), regardless we can got to avoid these _path APIs for now Discovered this when running a flamegraph on our home page. --- app/views/layouts/application.html.erb | 8 ++++---- app/views/layouts/crawler.html.erb | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index fb45a9b9df4..9a850037c48 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -46,10 +46,10 @@ diff --git a/app/views/layouts/crawler.html.erb b/app/views/layouts/crawler.html.erb index e68f58beb2a..1f94b828f21 100644 --- a/app/views/layouts/crawler.html.erb +++ b/app/views/layouts/crawler.html.erb @@ -27,10 +27,10 @@