Perf: add reject base first before adding third-party data

This commit is contained in:
SukkaW
2025-03-07 10:00:25 +08:00
parent 22b1f6f4e1
commit 4b26958578
2 changed files with 15 additions and 32 deletions

View File

@@ -76,6 +76,16 @@ export const buildRejectDomainSet = task(require.main === module, __filename)(as
await span
.traceChild('download and process hosts / adblock filter rules')
.traceAsyncFn((childSpan) => Promise.all([
// Dedupe domainSets
// Collect DOMAIN, DOMAIN-SUFFIX, and DOMAIN-KEYWORD from non_ip/reject.conf for deduplication
// DOMAIN-WILDCARD is not really useful for deduplication, it is only included in AdGuardHome output
// It is faster to add base than add others first then whitelist
rejectOutput.addFromRuleset(readLocalRejectRulesetPromise),
rejectExtraOutput.addFromRuleset(readLocalRejectRulesetPromise),
readLocalRejectDomainsetPromise.then(appendArrayToRejectOutput),
readLocalRejectDomainsetPromise.then(appendArrayToRejectExtraOutput),
readLocalRejectExtraDomainsetPromise.then(appendArrayToRejectExtraOutput),
// Parse from remote hosts & domain lists
hostsDownloads.map(task => task(childSpan).then(appendArrayToRejectOutput)),
hostsExtraDownloads.map(task => task(childSpan).then(appendArrayToRejectExtraOutput)),
@@ -109,18 +119,7 @@ export const buildRejectDomainSet = task(require.main === module, __filename)(as
addArrayElementsToSet(filterRuleWhitelistDomainSets, blackDomainSuffixes, suffix => '.' + suffix);
})
),
getPhishingDomains(childSpan).then(appendArrayToRejectExtraOutput),
readLocalRejectDomainsetPromise.then(appendArrayToRejectOutput),
readLocalRejectDomainsetPromise.then(appendArrayToRejectExtraOutput),
readLocalRejectExtraDomainsetPromise.then(appendArrayToRejectExtraOutput),
// Dedupe domainSets
// span.traceChildAsync('collect black keywords/suffixes', async () =>
/**
* Collect DOMAIN, DOMAIN-SUFFIX, and DOMAIN-KEYWORD from non_ip/reject.conf for deduplication
* DOMAIN-WILDCARD is not really useful for deduplication, it is only included in AdGuardHome output
*/
rejectOutput.addFromRuleset(readLocalRejectRulesetPromise),
rejectExtraOutput.addFromRuleset(readLocalRejectRulesetPromise)
getPhishingDomains(childSpan).then(appendArrayToRejectExtraOutput)
].flat()));
if (foundDebugDomain.value) {