uBlockProtector icon indicating copy to clipboard operation
uBlockProtector copied to clipboard

For a faster future v2

Open jspenguin2017 opened this issue 9 years ago • 13 comments

Time for more optimization, the extension is slower than the Userscript due to some optimization being rolled back...

Done:

  • Disabled YaMD5 as it is not used anymore.
  • I just realized that I can't use the lazy load trick anymore due to $ is now defined on window...
  • a.filter is now able to handle function names like _(:3 」∠ )_.
  • Payloads that requires replace are changed to templates.
  • Generic payloads are going to be left as-is since carrying duplicate code isn't clean, a.generic() only take 3 ms anyway.
  • According to my tests, making a no-loop version of a.domCmp and a.domInc does not really change performance, just make development harder.
  • Replaced jQuery with domlib.

Note:

  • Before optimization, the extension takes about 53 ms to execute.
  • The Userscript takes about 10 ms to execute, bit Violentmonkey wrapper takes 30 ms (so 40 ms total).
  • The extension currently takes about 25 ms to execute.

jspenguin2017 avatar Jun 29 '17 23:06 jspenguin2017

Looks like there isn't a way to squeeze execution time below 40 ms without replacing jQuery...

jspenguin2017 avatar Jul 01 '17 21:07 jspenguin2017

I made a replacement of jQuery, which is significantly lighter and is able to take advantage of latest Chromium's built-in functions. However, it can only do a fraction of what jQuery can, that is enough for now, I will expand it as needed. The initial execution time is down to about 25 ms (on the go-to test page https://blockadblock.com/ ) Other executions are asynchronous and are done as the document loads, 2 to 5 ms here and there, won't make a difference as the initial burst is what slows down page load.

jspenguin2017 avatar Jul 02 '17 03:07 jspenguin2017

Let me know if something broke, I did a few quick tests and it seems to work...

jspenguin2017 avatar Jul 02 '17 03:07 jspenguin2017

Let me know if something broke, I did a few quick tests and it seems to work...

This, for example https://github.com/jspenguin2017/uBlockProtector/blob/master/Extension%20Compiler/Extension/content/content-rules.js#L2293L2294L2295

lain566 avatar Jul 02 '17 08:07 lain566

^^ Instead of having three separate removals, why not just block it with exrapidleech.info###idnotice ?

uBlock-user avatar Jul 02 '17 09:07 uBlock-user

@lain566 Eh... yea... Let me fix it...

jspenguin2017 avatar Jul 02 '17 13:07 jspenguin2017

@uBlock-user Can't, must leave one or it will trigger anti-adblock. And must remove and not hide.

jspenguin2017 avatar Jul 02 '17 13:07 jspenguin2017

@lain566 Updated, it is working correctly now. Pushing to store. 👍 👍

jspenguin2017 avatar Jul 02 '17 14:07 jspenguin2017

Now that jQuery is gone, will we still be able to do everything like we used to with jQuery or do we have limitations ?

uBlock-user avatar Jul 02 '17 16:07 uBlock-user

Not just that, the new library behaves differently than jQuery. Why are you worrying about this? I can expand my library as needed.

jspenguin2017 avatar Jul 02 '17 16:07 jspenguin2017

Not worrying, but rather curious as you mentioned "it can only do a fraction of what jQuery can" which can be a dis-advantage depending on the situation.

uBlock-user avatar Jul 02 '17 16:07 uBlock-user

Yea, it is missing most of the API, but it is trivial to add them. I don't want to add them now because I'm not using them. jQuery includes many workarounds to bypass bugs in old browsers, which is not needed for our case and just make things slow and bloated. jQuery runs tests when it is loading to see which workaround it needs to activate, there are hundreds of them, and none is needed for Chrome 59.

jspenguin2017 avatar Jul 02 '17 17:07 jspenguin2017

Seems to work pretty well, closing.

jspenguin2017 avatar Jul 03 '17 17:07 jspenguin2017