Output more information to dev console when loading filter lists

Related discussion:
https://github.com/uBlockOrigin/uBlock-issues/discussions/2993#discussioncomment-8265914
This commit is contained in:
Raymond Hill 2024-01-27 18:23:04 -05:00
parent 6c54731a72
commit 030072c324
No known key found for this signature in database
GPG key ID: 25E1490B761470C2

View file

@ -849,8 +849,10 @@ onBroadcast(msg => {
let loadingPromise; let loadingPromise;
let t0 = 0; let t0 = 0;
const elapsed = ( ) => `${Date.now() - t0} ms`;
const onDone = ( ) => { const onDone = ( ) => {
ubolog(`loadFilterLists() All filters in memory at ${Date.now() - t0} ms`); ubolog(`loadFilterLists() All filters in memory at ${elapsed()}`);
staticNetFilteringEngine.freeze(); staticNetFilteringEngine.freeze();
staticExtFilteringEngine.freeze(); staticExtFilteringEngine.freeze();
@ -858,12 +860,12 @@ onBroadcast(msg => {
vAPI.net.unsuspend(); vAPI.net.unsuspend();
filteringBehaviorChanged(); filteringBehaviorChanged();
ubolog(`loadFilterLists() All filters ready at ${Date.now() - t0} ms`); ubolog(`loadFilterLists() All filters ready at ${elapsed()}`);
logger.writeOne({ logger.writeOne({
realm: 'message', realm: 'message',
type: 'info', type: 'info',
text: `Reloading all filter lists: done, took ${Date.now() - t0} ms` text: `Reloading all filter lists: done, took ${elapsed()}`
}); });
vAPI.storage.set({ 'availableFilterLists': µb.availableFilterLists }); vAPI.storage.set({ 'availableFilterLists': µb.availableFilterLists });
@ -883,7 +885,7 @@ onBroadcast(msg => {
}; };
const applyCompiledFilters = (assetKey, compiled) => { const applyCompiledFilters = (assetKey, compiled) => {
ubolog(`loadFilterLists() Loading filters from ${assetKey} at ${Date.now() - t0} ms`); ubolog(`loadFilterLists() Loading filters from ${assetKey} at ${elapsed()}`);
const snfe = staticNetFilteringEngine; const snfe = staticNetFilteringEngine;
const sxfe = staticExtFilteringEngine; const sxfe = staticExtFilteringEngine;
let acceptedCount = snfe.acceptedCount + sxfe.acceptedCount; let acceptedCount = snfe.acceptedCount + sxfe.acceptedCount;
@ -917,7 +919,7 @@ onBroadcast(msg => {
µb.selfieManager.destroy(); µb.selfieManager.destroy();
staticFilteringReverseLookup.resetLists(); staticFilteringReverseLookup.resetLists();
ubolog(`loadFilterLists() All filters removed at ${Date.now() - t0} ms`); ubolog(`loadFilterLists() All filters removed at ${elapsed()}`);
// We need to build a complete list of assets to pull first: this is // We need to build a complete list of assets to pull first: this is
// because it *may* happens that some load operations are synchronous: // because it *may* happens that some load operations are synchronous:
@ -959,7 +961,9 @@ onBroadcast(msg => {
loadedListKeys.length = 0; loadedListKeys.length = 0;
loadingPromise = Promise.all([ loadingPromise = Promise.all([
this.getAvailableLists().then(lists => onFilterListsReady(lists)), this.getAvailableLists().then(lists => onFilterListsReady(lists)),
this.loadRedirectResources(), this.loadRedirectResources().then(( ) => {
ubolog(`loadFilterLists() Redirects/scriptlets ready at ${elapsed()}`);
}),
]).then(( ) => { ]).then(( ) => {
onDone(); onDone();
}); });