Skip to content

Conversation

sheremet-va
Copy link
Member

Description

process.title takes 10ms on my machine (MacBook Pro) and 20ms on @AriPerkkio's machine. We are considering removing this call to improve performance.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

Copy link

netlify bot commented Aug 19, 2025

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit 5597043
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/68a43650ef4ffc0008f83143
😎 Deploy Preview https://deploy-preview-8453--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@sheremet-va sheremet-va requested a review from AriPerkkio August 19, 2025 08:41
Copy link
Member

@AriPerkkio AriPerkkio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was nice feature but maybe not worth the perf hit. Users can still do this in setupFiles I guess.

@AriPerkkio
Copy link
Member

Minimal repros without Vitest:

const startTime = performance.now();
process.title = "node (example)";
console.log(`${(performance.now() - startTime).toFixed(2)} ms`);
// 12-15ms, Apple M2 Air 16BG

Inside node:child_process, env var to control process.title setter for comparison:

import { fork } from "node:child_process";
import { fileURLToPath } from "node:url";

const SET_NAME = process.env.SET_NAME;
const isMainThread = process.send === undefined;

if (isMainThread) {
  const startTime = performance.now();
  const subprocess = fork(fileURLToPath(import.meta.url));
  subprocess.on("exit", () => console.log(`${(performance.now() - startTime).toFixed(2)} ms`));
} else {
  if (SET_NAME) {
    process.title = "node (example)";
  }
}
$  node ./example.mjs 
26.50 ms
$  node ./example.mjs 
27.05 ms
$  node ./example.mjs 
26.66 ms

$ SET_NAME=1 node ./example.mjs 
40.38 ms
$ SET_NAME=1 node ./example.mjs 
39.52 ms
$ SET_NAME=1 node ./example.mjs 
38.79 ms

Using --title has same perf hit, ~40ms with this one:

import { fork } from "node:child_process";
import { fileURLToPath } from "node:url";

const isMainThread = process.send === undefined;

if (isMainThread) {
  const startTime = performance.now();

  const subprocess = fork(fileURLToPath(import.meta.url), undefined, { execArgv: ["--title=node (example)"]});
  subprocess.on("exit", () => console.log(`${(performance.now() - startTime).toFixed(2)} ms`));
} else {
  // Child process running
}

@sheremet-va sheremet-va merged commit 0a76663 into vitest-dev:main Aug 19, 2025
12 of 14 checks passed
@sheremet-va sheremet-va deleted the perf/dont-set-process-title branch August 19, 2025 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants