perf(doodstream): gate per-upload _debugLog behind logVerbose (default off) — drop ~8-15 sync fs syscalls/upload off the main loop
doodstream-upload.js's _debugLog ran with NO verbose gate: every call did a synchronous statSync (via maybeRotateLogFile) + appendFileSync directly on the main-process event loop, ~8-15x per upload (server probe, response, redirect, result page, filecode parse, hidden fields, submit/follow, plus retry branches). DoodstreamUploader runs in the main process, so each pair of sync fs syscalls blocked the event loop while uploading — delaying IPC, upload-progress-batch forwarding, tray-tooltip and webhook handling for every other concurrent upload. A constant per-upload main-thread tax (not history-scaling), surfaced by the session-wide lag audit and confirmed as the one finding that bites in the real upload scenario. Fix: gate _debugLog behind the existing globalSettings.logVerbose setting (default false), exactly mirroring main.js logDebug/_logVerbose. A module-level _debugVerbose flag + setDebugVerbose() setter, an early-return at the top of _debugLog, and one wire at main.js's single setLogVerbose chokepoint (covers boot + save-config + the verbose toggle). When verbose is off the doodstream trace simply isn't written — same contract as the main debug.log — and the per-upload sync fs disappears. When a doodstream issue needs tracing, enabling verbose restores the full trace. The config-store audit findings (load() history-clone cost, per-write history serialize) are real but scale only with history size — tens of microseconds at this user's 8-batch config, and the safe fix is risky persistence surgery on credential-bearing code for a latent micro-cost; deferred and documented in tasks/todo.md rather than shipped. 397/397 tests pass, eslint clean, gate wiring verified (shared module instance, default-off, toggles). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c37c8e3906
commit
233952af8f
@ -27,7 +27,11 @@ function _doodstreamLogPath() {
|
||||
return path.join(__dirname, '..', 'doodstream-debug.log');
|
||||
}
|
||||
|
||||
let _debugVerbose = false;
|
||||
function setDebugVerbose(v) { _debugVerbose = !!v; }
|
||||
|
||||
function _debugLog(msg) {
|
||||
if (!_debugVerbose) return;
|
||||
try {
|
||||
const logPath = _doodstreamLogPath();
|
||||
maybeRotateLogFile(logPath, _DOODSTREAM_LOG_MAX_BYTES, _DOODSTREAM_LOG_MAX_BACKUPS);
|
||||
@ -698,3 +702,4 @@ class DoodstreamUploader {
|
||||
}
|
||||
|
||||
module.exports = DoodstreamUploader;
|
||||
module.exports.setDebugVerbose = setDebugVerbose;
|
||||
|
||||
2
main.js
2
main.js
@ -139,7 +139,7 @@ function debugLog(msg) {
|
||||
}
|
||||
|
||||
let _logVerbose = false;
|
||||
function setLogVerbose(v) { _logVerbose = !!v; }
|
||||
function setLogVerbose(v) { _logVerbose = !!v; try { require('./lib/doodstream-upload').setDebugVerbose(_logVerbose); } catch {} }
|
||||
function _ctxTag(ctx) {
|
||||
if (!ctx || typeof ctx !== 'object') return '';
|
||||
const tags = [];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user