mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-10-19 22:27:20 +02:00
perf: bound request work and resource usage (#866)
* perf: bound request work and resource usage * fix: address performance review regressions * fix: guard content expiration and dashboard state * fix: tolerate cache outages and retire derived paths * fix: revalidate expiration claims and status pagination * fix: retry interrupted repository metadata cleanup * fix: retire obsolete content cache storage * fix: activate tree metadata and recheck expiration claims * fix: fence cache publication across expiration * fix: recover staged trees and enforce cache lifecycle cleanup * fix: prune expired transforms during database outages * fix: finish conference removals and reload expiration candidates
This commit is contained in:
1 parent
32722169a2
commit
6434337923
74 files changed
+4752
-553
No files matched your search
+42
@@ -0,0 +1,42 @@
|
||||
const { Readable } = require("node:stream");
|
||||
const path = require("node:path");
|
||||
const compiled = process.env.PERFORMANCE_STREAMER_COMPILED === "1";
|
||||
if (!compiled) require("ts-node/register/transpile-only");
|
||||
const base = path.join(__dirname, compiled ? "../../build" : "../../src");
|
||||
const GitHubStream = require(path.join(base, "core/source/GitHubStream")).default;
|
||||
const FileSystem = require(path.join(base, "core/storage/FileSystem")).default;
|
||||
const maintenance = require(path.join(base, "core/temporary-storage"));
|
||||
const startMaintenance = maintenance.startTemporaryStorageMaintenance;
|
||||
// Exercise the real startup/timer wiring without waiting a production minute.
|
||||
maintenance.startTemporaryStorageMaintenance = () => startMaintenance(25);
|
||||
GitHubStream.prototype.downloadWithFallback = async function () {
|
||||
process.send({ download: true });
|
||||
return Readable.from([Buffer.alloc(300000, "x")]);
|
||||
};
|
||||
const write = FileSystem.prototype.write;
|
||||
let release, releaseConnection;
|
||||
if (process.env.PERFORMANCE_HOLD_CONNECT === "1") {
|
||||
const database = require(path.join(base, "server/database")), connect = database.connect;
|
||||
database.connect = async (...args) => {
|
||||
const held = new Promise(resolve => { releaseConnection = resolve; });
|
||||
process.send({ connectionHeld: true }); await held;
|
||||
return connect(...args);
|
||||
};
|
||||
}
|
||||
FileSystem.prototype.write = async function (...args) {
|
||||
if (args[1].endsWith("/hold.txt")) {
|
||||
const held = new Promise(resolve => { release = resolve; });
|
||||
process.send({ held: true }); await held;
|
||||
}
|
||||
return write.apply(this, args);
|
||||
};
|
||||
if (process.env.CREDENTIAL_KEYS !== "invalid") process.on("message", message => {
|
||||
if (message === "release") release?.();
|
||||
if (message === "connect") releaseConnection?.();
|
||||
if (message === "inspect") {
|
||||
const options = require("mongoose").connection.getClient().options;
|
||||
process.send({ connected: require(path.join(base, "server/database")).isConnected,
|
||||
maxPoolSize: options.maxPoolSize, minPoolSize: options.minPoolSize });
|
||||
}
|
||||
});
|
||||
require(path.join(base, "streamer/index"));
|
||||
Reference in new issue
Block a user