Skip to content

Header Search - Fix GitLab loading time by removing search_context usage

Zack Cuddy requested to merge explore-non-js-search into master

What does this MR do and why?

Closes #378413 (closed)

Right now the Header Search component is significantly increasing .Com load time by nearly 20% (50ms - 150ms depending on page).

After a deep dive with @mkozono it appears there is something very inefficient happening inside of SearchContext. I am not entirely sure what is so inefficient about it but it is killing our render time.

After exploring what SearchContext is used for with the header_search it was discovered we could instead un-abstract the logic inside of the Builder method in SearchContext into the helper method that was parsing the SearchContext. By doing this we completely remove the need for the SearchContext class (in this context) at all. Instead utilizing the conditional existence of @instance methods set by the respected controllers we are able to significantly reduce the render time.

Screenshots or screen recordings

GDK

Before After
Screenshot Screen_Shot_2022-10-20_at_9.57.41_AM Screen_Shot_2022-10-20_at_9.56.11_AM
Description 70.51ms (8.8%) 10.24ms (0.68%)

Review App

Before After
Screenshot Screen_Shot_2022-10-20_at_3.25.16_PM Screen_Shot_2022-10-20_at_3.26.38_PM
Description 110.51 ms (22% of render time) 9.58ms (2.8% of render time)

How to set up and validate locally

Testing Performance

  1. Open teh Flamegraph in Wall mode on a Group or Project
  2. CMD+F for header_search
  3. Ensure the render time appears reasonable (less than 5% of total time at least)
  4. Additionally compare to master to visualize the speed increase

Testing existing functionality

  1. Go to a Project/Group
  2. Search via the header search
  3. Ensure things like the group, project, tab are all preserved when you search (similar to production)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Zack Cuddy

Merge request reports

Loading