HomePhabricator
Diffusion Comm 851d1f97c684

[keyserver] Add `$KEYSERVER_PROFILING_ENABLED` to toggle `node:cluster`

Description

[keyserver] Add $KEYSERVER_PROFILING_ENABLED to toggle node:cluster

Summary:
The 0x tool mentioned in ENG-5078 does not work with node:cluster. We can modify keyserver.js to launch a single process when KEYSERVER_PROFILING_ENABLED is set. This is what I did in my personal dev environment to get 0x working.

Basically if KEYSERVER_PROFILING_ENABLED is set, we avoid cluster.fork()ing and just "spill" into the else block that would usually only be executed by child processes (cpid == 0). Previous cluster fork()ing logic continues to work as expected when KEYSERVER_PROFILING_ENABLED is unset.

Will users have to set KEYSERVER_PROFILING_ENABLED in their environment manually?

The yarn command for profiling will begin with KEYSERVER=true KEYSERVER_PROFILING_ENABLED=true node... to make this config "invisible" to the dev. As long as they run yarn profile-* things will work as expected.


Depends on D9300

Test Plan:

  1. Added logging to ensure that conditionals behaved as expected when KEYSERVER_PROFILING_ENABLED is and isn't set.
  2. Successfully ran profiling session with KEYSERVER=true 0x -o -- node --trace-warnings --loader=./loader.mjs dist/keyserver

Reviewers: ashoat, ginsu, tomek, rohan

Reviewed By: ashoat

Differential Revision: https://phab.comm.dev/D9301

Details

Provenance
atulAuthored on Sep 27 2023, 9:12 AM
Reviewer
ashoat
Differential Revision
D9301: [keyserver] Add `$KEYSERVER_PROFILING_ENABLED` to toggle `node:cluster`
Parents
rCOMMd039d228e72b: [keyserver] Introduce `0x` dependency for `keyserver` profiling
Branches
Unknown
Tags
Unknown