winzik/ide/bin/ide-worker.php
David Nurdin 2f41a46d66 IDE speed: the first indexing on every core (worker processes), the library cache read and written in slices
- Async\WorkerPool: helper processes of the same PHP (the desktop runtime and the exported
  StaticPHP micro have no threads), JSON lines, plain values only; errors come back as values
  (WorkerError), a dead or hung worker is replaced and its job tried once more, a pool that
  cannot start or whose workers die too often closes itself and every caller works alone
- Index: project files and library files analyzed by the workers when there are many (only
  once a worker is ready: inline meanwhile); the libraries' cache is JSON lines read a slice
  per frame and decoded only when reached, written a slice per frame and only when something
  changed; the libraries' folders listed one per frame
- Ide: one worker per core minus one (max 8); off with JUMPHP_IDE_WORKERS=0 or perf.workers
  {enabled: false}; workers let go once the indexing is done
- standalone stub: JUMPHP_WORKER_SCRIPT runs a script of the app (the IDE's worker) instead
  of the app, only a file inside it; older executables get no pool (the IDE works alone)

JumPHP repo, cold: 16.1 s -> 3.7 s, longest frame 284 -> 32 ms; warm: 3.8 s -> 1.2 s,
peak memory 315 -> 161 MB. Symfony project cold: 8.9 s -> 2.0 s, longest frame 187 -> 14 ms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JkYTqsvYu6AYr9yQ3Q4Nt6
2026-11-16 00:11:11 +01:00

18 lines
736 B
PHP

<?php
// A helper process of the JumPHP IDE (JumPHP\Ide\Async\WorkerPool): jobs as JSON lines on stdin, answers on stdout.
// Started by the IDE itself with the autoloader to use (JUMPHP_IDE_AUTOLOAD); in an exported IDE, through its own executable
// (tools/standalone-stub.php, JUMPHP_WORKER_SCRIPT).
$autoload = getenv('JUMPHP_IDE_AUTOLOAD');
if (!defined('JUMPHP_EXECUTABLE')) {
if (!is_string($autoload) || !is_file($autoload)) {
fwrite(STDERR, "ide-worker: JUMPHP_IDE_AUTOLOAD is not a file\n");
exit(70);
}
require $autoload;
}
$code = JumPHP\Ide\Async\Worker::serve(STDIN, STDOUT);
if (defined('JUMPHP_EXECUTABLE')) {
return $code; // the executable's stub exits with it
}
exit($code);