-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve startup performance #408
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly makes sense to me so far. Left some thoughts.
extension/data/modules/oldreddit.js
Outdated
} | ||
}); | ||
} | ||
profileResults('oldRedditInitDone', performance.now()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This profile is basically useless since all that's being done between here and oldRedditInit
is setting a bunch of timeouts.
extension/data/tbapi.js
Outdated
|
||
TBApi.setModHash = modhash => { | ||
TBApi.modhash = modhash; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Er... why does this function exist...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To set the modhash :P Has to do with how toolbox is structured, when TBApi is loaded in the modhash isn't known yet. I wanted a clean way to set it once it is known.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not just do TBApi.modhash = stuff
from wherever the modhash is retreived?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly, but afaik we never directly update class/object values so this did seem like a bit cleaner. There also might have been a technical reason I convinced myself was there, but I can't remember now....
extension/data/tbcore.js
Outdated
@@ -4,22 +4,22 @@ function initwrapper ({userDetails, newModSubs, cacheDetails}) { | |||
(function (TBCore) { | |||
// We need these before we can do anything. | |||
TBCore.userDetails = userDetails; | |||
TBCore.modhash = userDetails.data.modhash; | |||
TBCore.modhash = TBApi.modhash; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should really only store this value in one place, why not just replace all TBCore.modhash
with TBApi.modhash
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm not sure why I did it like this to be honest...
extension/data/tbui.js
Outdated
TBui.getBestTextColor.cache = {}; | ||
})(window.TBui = window.TBui || {}); | ||
if (document.readyState === 'loading') { | ||
document.addEventListener('readystatechange', TBuiInitWrapper, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be restricted to only run for a certain ready state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, as long as it isn't loading it is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, so it seems like it's always being called on interactive
then. I'd rather call out the state we're targeting explicitly, but that might be too small a nitpick. I see how it works now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Frankly seemed like a wasted check as it really doesn't matter as long as it isn't loading
.
extension/data/tbstorage.js
Outdated
logger.error('firefox is in incognito mode, toolbox will not work.'); | ||
return; | ||
} | ||
console.log('sendInit7', performance.now()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will probably want to remove these logs eventually
Co-authored-by: Geo <georgej1088@gmail.com>
…/reddit-moderator-toolbox into startup-performance
Aside from the obvious stuff that still needs fixing before we merge this I do want to try to get some actual benchmarks with enough datapoints with a few scenarios to see actual benefits. Specifically I came across a article regarding performance from a chrome developer where it was pointed out that changing the DOM while it is still being rendered might actually hurt performance. With that in mind I still want to experiment with some specific scenarios and try to get tangible date points:
I'd like to try to not only measure reported load times but also visible load times, at what point do we see toolbox being loaded. To that end I'll probably set up a simple test with selenium. |
This branch hadn't been updated since before #518 (content script esm) so it was very outdated. I got bored and merged current
Diff is much smaller now, could probably be a pretty easy merge. |
* move init api calls, shuffle timing * $body = $body doesn't work. * Move api specific constants to TBApi * remove weird $body usage * Make sure tbui gets loaded at the right time. * Not sure how this got back in there. * Improve new modmail performance and reliability. * Only listen to init events once * Better diff for geo ;) * Update extension/data/tbcore.js Co-authored-by: Geo <georgej1088@gmail.com> * Disable travis unit tests * Finish moving off TBCore errors and remove them Co-authored-by: Geo <georgej1088@gmail.com> Co-authored-by: Erin <erin20913@gmail.com>
Still a draft but from initial testing it seems to make 1-2 seconds depending on circumstances. Effectively it moves the API calls to get user information forward so they can get started before the DOM is in an interactive state. I also moved most javascript around in the manifest so it should be loaded sooner.
Still a bit of a draft as I put in a lot of console log statements with
performance.now()
timestamps to get insights in delays and I still need to investigate a few things.I also did play around with replacing all
$body
declarations with oneTBCore
variant with the idea that this might improve performance but that doesn't seem to any impact (maybe in memory usage though, didn't look into that).I also checked if disabling modules like
betterbuttons
which still scrape the page in an oldschool way had an effect but that also doesn't seem to be the case.There is still some more investigating to do to see if we can get out a bit more performance but all things considered from what I can see a lot of the perceived delays is mostly down to the sheer amount of things toolbox does with reddit.
On a final note, on firefox performance seems slightly better compared to chromium based browsers both in visual aspect as in actual numbers.