@regisF can you record again? I don't know if this is something that got improved by the patch release we deployed since this issue was created, but loading the issue seems pretty responsive for me, and the timings in my machine are around 6s even with cache disabled:
By mistake I've loaded a very heavy page in the Invisible mode in Chrome. And actually, when we are logged out, those super heave pages load really, really fast.
I did the test with the same page logged, and it takes forever to load them.
In the example above, logged out, the page takes less then 4 seconds to load. When logged, > 30 seconds.
@regisF Seeing the large number of participants that may be due to GitLab checking if you're subscribed to the issue (which involves building the list of participants). This doesn't happen when you're not logged in.
@regisF Right, we're aware that the performance is different based on permissions of the user. For example, since you have Master access, the "Edit" note button is available to you. This causes us to render a hidden Markdown element for every note (see gitlab-org/gitlab-ce#23227), which is slow. Let me get you the backend profile on that issue with an authenticated user.
The previous benchmark is simply the time it takes for the backend to return the full HTML to display. The above doesn't cover the time it takes to load the images and display them in the browser.
@regisF something isn't right here, at all. autocomplete_sources shouldn't be loading more than once and it definitely shouldn't be blocking the page render. What happens if you disable all your extensions? Are you on the latest version of Chrome? (53 or 54 should be fine)
@connorshea my internet is crazy fast. This is not the issue.
This is my test, logged , on a fresh installation of Google Canary without any plugins. autocomplete_sources is executed multiple times. And Canada shouldn't be that far from the datacenter.
I don't understand why it only happens to you though, no one else can seem to reproduce it, and it definitely shouldn't be trying to load the autocomplete_sources file more than once.
Well we're loading the script from the same URL. I wonder if the SHA hash is different for yours for some reason? Being modified in-transit by the ISP or something?
Let's think through the problem here: Regis is seeing autocomplete_sources load multiple times. It's possible there's a bug that only happens in certain circumstances. In the code, we see:
One reason is that he is has Master privileges, and the JavaScript is rendered for each note that he can edit. If I look at the HTML of my page, I see the duplicate JavaScript. When I put breakpoints on the page, I definitely see GitLab.GfmAutoComplete.setup(); being called multiple times.
tldr: It's not a network problem, it's an insane amount of DOM operations being inadvertantly run for every editable diff note on a page. If you're not looking at a page with lots of comments/notes, you won't be able to to reproduce. (cc: @connorshea )
Calls to GfmAutoComplete.setupwere inlined as part of an effort to avoid loading gfm resources on pages where we don't need them. That made the slowdown more noticeable because it was run for each diff note.
I refactored setup a bit, to avoid running DOM operations for gfm more than once. Removing inline calls isn't a clean fix because setup is often called from multiple places on a page, other than the offending inline calls. setup needs to be a better gatekeeper.
@brycepj Thanks for making GfmAutoComplete.setup a better gatekeeper. It does seem, however, that the root cause is that we were inadvertently including duplicate calls to GfmAutoComplete.setup. This happens usually when the user can edit notes (e.g. Master privileges). I think @iamphill's attempt to address this in !6840 (merged) is a better fix for 8.12 since it changes fewer things to fix the crux of the issue.
@stanhu that's fine with me. I agree that the many additional calls made by editable diff notes really made this problem a problem.
Afaik the number of unnecessary DOM setup interactions (the source of the lag) will still be n^2 - n, where n is the number of times setup is called. I believe this fix will keep n to 4. Not good, but definitely not as bad as n growing indefinitely.
@stanhu just tested to load the issue that caused problems, I think you've pushed a fix to production (you or someone else), because it loads super fast now. Thanks!!!!
8.13 RC2 was deployed, and Bryce's fix (!6569 (merged)) solves the load time problem. However, the duplicate JavaScript code still remains, and I think we want to fix this for 8.12. I recommend that we keep this issue open until we address the root cause.