mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Enable log discard modes for all scripts
Summary: Fixes T2273. We currently discard logs, service calls, etc., for daemons, but not for other scripts. However, other scripts may be long-running or issue a large body of service calls (e.g., `bin/search index --all`). We never retrieve this information from scripts (it is used to build darkconsole; in scripts, we echo it immediately under --trace), so discard it immediately to prevent these scripts from requiring a large amount of memory. (When the daemons load `__init_script__.php` they end up calling this code, so this doesn't change anything for them. They hit another ServiceProfiler discard along the daemon pathways in libphutil, but the call is idempotent.) Test Plan: Ran `bin/search index --all` and saw increasing memory usage before this patch, but steady memory usage after this patch. Reviewers: btrahan, vrana, codeblock Reviewed By: codeblock CC: aran Maniphest Tasks: T2273 Differential Revision: https://secure.phabricator.com/D4364
This commit is contained in:
parent
7752717125
commit
cbe9aea876
2 changed files with 8 additions and 7 deletions
|
@ -5,13 +5,6 @@ abstract class PhabricatorDaemon extends PhutilDaemon {
|
|||
protected function willRun() {
|
||||
parent::willRun();
|
||||
|
||||
// This stores unbounded amounts of log data; make it discard instead so
|
||||
// that daemons do not require unbounded amounts of memory.
|
||||
DarkConsoleErrorLogPluginAPI::enableDiscardMode();
|
||||
|
||||
// Also accumulates potentially unlimited amounts of data.
|
||||
DarkConsoleEventPluginAPI::enableDiscardMode();
|
||||
|
||||
$phabricator = phutil_get_library_root('phabricator');
|
||||
$root = dirname($phabricator);
|
||||
require_once $root.'/scripts/__init_script__.php';
|
||||
|
|
8
src/infrastructure/env/PhabricatorEnv.php
vendored
8
src/infrastructure/env/PhabricatorEnv.php
vendored
|
@ -90,6 +90,14 @@ final class PhabricatorEnv {
|
|||
// NOTE: This is dangerous in general, but we know we're in a script context
|
||||
// and are not vulnerable to CSRF.
|
||||
AphrontWriteGuard::allowDangerousUnguardedWrites(true);
|
||||
|
||||
// There are several places where we log information (about errors, events,
|
||||
// service calls, etc.) for analysis via DarkConsole or similar. These are
|
||||
// useful for web requests, but grow unboundedly in long-running scripts and
|
||||
// daemons. Discard data as it arrives in these cases.
|
||||
PhutilServiceProfiler::getInstance()->enableDiscardMode();
|
||||
DarkConsoleErrorLogPluginAPI::enableDiscardMode();
|
||||
DarkConsoleEventPluginAPI::enableDiscardMode();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue