mirror of
https://gitlab.com/SukkaW/ruleset.skk.moe.git
synced 2026-01-02 02:20:24 +00:00
deploy: 61035df4a80264b2bd77ab634ec97bdb623b309a
This commit is contained in:
@@ -198,6 +198,17 @@ const threads = require('os').cpus().length - 1;
|
||||
workerData: [...domainSets]
|
||||
});
|
||||
|
||||
console.log(`Launching ${threads} threads...`)
|
||||
|
||||
const tasksArray = Array.from(domainSets)
|
||||
.reduce((result, element, index) => {
|
||||
const chunk = index % threads;
|
||||
result[chunk] ??= [];
|
||||
|
||||
result[chunk].push(element);
|
||||
return result;
|
||||
}, []);
|
||||
|
||||
(await Promise.all(
|
||||
Array.from(domainSets)
|
||||
.reduce((result, element, index) => {
|
||||
@@ -208,11 +219,15 @@ const threads = require('os').cpus().length - 1;
|
||||
return result;
|
||||
}, [])
|
||||
.map(chunk => piscina.run(
|
||||
{ chunk },
|
||||
{ name: 'dedupe' }
|
||||
{ chunk }
|
||||
))
|
||||
)).forEach(set => {
|
||||
set.forEach(i => domainSets.delete(i));
|
||||
)).forEach((result, taskIndex) => {
|
||||
const chunk = tasksArray[taskIndex];
|
||||
result.forEach((value, index) => {
|
||||
if (value === 1) {
|
||||
domainSets.delete(chunk[index])
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
console.log(`Deduped ${previousSize - domainSets.size} rules!`);
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
const { workerData } = require('piscina');
|
||||
const { workerData, move } = require('piscina');
|
||||
|
||||
const len = workerData.length;
|
||||
|
||||
exports.dedupe = ({ chunk }) => {
|
||||
const outputToBeRemoved = new Set();
|
||||
module.exports = ({ chunk }) => {
|
||||
const chunkLength = chunk.length;
|
||||
const outputToBeRemoved = new Int32Array(chunkLength);
|
||||
|
||||
for (let i = 0, l = chunk.length; i < l; i++) {
|
||||
for (let i = 0; i < chunkLength; i++) {
|
||||
const domainFromInput = chunk[i];
|
||||
|
||||
for (let j = 0; j < len; j++) {
|
||||
@@ -26,7 +27,7 @@ exports.dedupe = ({ chunk }) => {
|
||||
}
|
||||
|
||||
if (shouldBeRemoved) {
|
||||
outputToBeRemoved.add(domainFromInput);
|
||||
outputToBeRemoved[i] = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -34,12 +35,12 @@ exports.dedupe = ({ chunk }) => {
|
||||
|
||||
if (domainFromInput.length >= domainFromFullSet.length) {
|
||||
if (domainFromInput.endsWith(domainFromFullSet)) {
|
||||
outputToBeRemoved.add(domainFromInput);
|
||||
outputToBeRemoved[i] = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return outputToBeRemoved;
|
||||
return move(outputToBeRemoved);
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<main class="container">
|
||||
<h1>Sukka Surge Ruleset Server</h1>
|
||||
<p>Made by <a href="https://skk.moe">Sukka</a> | <a href="https://github.com/SukkaW/Surge/">Source @ GitHub</a> | Licensed under <a href="https://github.com/SukkaW/Surge/blob/master/LICENSE" target="_blank">AGPL-3.0</a></p>
|
||||
<p>Last Updated: 2022-09-05T05:35:08.425Z</p>
|
||||
<p>Last Updated: 2022-09-05T06:18:13.779Z</p>
|
||||
<hr>
|
||||
<br>
|
||||
<ul>
|
||||
|
||||
Reference in New Issue
Block a user