Skip to content
Permalink
Browse files

Buffer messages a little, to reduce inter-process communication

  • Loading branch information...
muglug committed May 31, 2019
1 parent 543ae40 commit 5d391587873ed922b060908e284076a4e2077317
Showing with 12 additions and 5 deletions.
  1. +2 −2 src/Psalm/Internal/Analyzer/ProjectAnalyzer.php
  2. +10 −3 src/Psalm/Internal/Fork/Pool.php
@@ -479,8 +479,6 @@ public function check($base_dir, $is_diff = false)
}
}
$this->progress->startAnalyzingFiles();
$this->config->visitStubFiles($this->codebase, $this->progress);
$plugin_classes = $this->config->after_codebase_populated;
@@ -491,6 +489,8 @@ public function check($base_dir, $is_diff = false)
}
}
$this->progress->startAnalyzingFiles();
$this->codebase->analyzer->analyzeFiles($this, $this->threads, $this->codebase->alter_code);
if ($this->parser_cache_provider) {
@@ -136,10 +136,17 @@ public function __construct(
$task_result = $task_closure($i, $task_data);
$task_done_message = new ForkTaskDoneMessage($task_result);
$serialized_message = $task_done_buffer . base64_encode(serialize($task_done_message)) . PHP_EOL;
$bytes_written = @fwrite($write_stream, $serialized_message);
if (strlen($serialized_message) !== $bytes_written) {
$task_done_buffer = substr($serialized_message, $bytes_written);
if (strlen($serialized_message) > 200) {
$bytes_written = @fwrite($write_stream, $serialized_message);
if (strlen($serialized_message) !== $bytes_written) {
$task_done_buffer = substr($serialized_message, $bytes_written);
} else {
$task_done_buffer = '';
}
} else {
$task_done_buffer = $serialized_message;
}
}

0 comments on commit 5d39158

Please sign in to comment.
You can’t perform that action at this time.