Skip to content

Remove initTimeagoTimeout and let timeago.js update timeagos internally.

  1. Lets timeago.js handle updating timeagos on page internally, rather than setting our own timeouts
  2. Removes unused code

Performance Impact

Here are some quick measurements that show the performance impact of this change. I gathered this info on an MR with ~80 diff notes at rest (not scrolling/clicking, etc) immediately after adding 2 diff notes:

On master calling the initTimeagoTimeout every second over ~10 seconds, we can see each execution, many of which are flagged with red warnings to signify that FPS are dangerously low. This explains periodic jankiness on the page, particularly when scrolling.

Screen_Shot_2017-06-29_at_3.21.54_PM

It's also important to note that a single execution lasts around 60ms and runs quite a lot of operations, plus the time it takes for reflowing the DOM after updating text nodes for all timeagos, even if they don't need updating. During this time the browser is locked.

Screen_Shot_2017-06-29_at_3.23.18_PM

With the fix on this MR, we see very few executions of timeago updates, even though they are still updating real-time. That's because we're only updating them as needed, rather than every second.

Screen_Shot_2017-06-29_at_3.21.12_PM

The burden on the browser is also significantly smaller when executions are performed (< 5ms). This is because the updates are scoped to single timeagos and don't require looping through every single one and updating so many DOM nodes.

Screen_Shot_2017-06-29_at_3.15.01_PM

What are the relevant issue numbers?

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/34340

Edited by username-removed-408230

Merge request reports