目录

Using the Daemon Process

A daemon process is a program that runs in the background, other than one under the direct control of users. The Hvigor daemon process is a persistent background process that helps to reduce the build time.

Understanding the Daemon Process

The Hvigor client sends build information such as command line arguments, project directories, and environment variables to the daemon process to facilitate build execution. The communication between the client and daemon process is conducted through a local socket connection. A maximum of eight daemon processes can run concurrently. Among these, no more than six processes can be in the active state (that is, neither stopped nor interrupted).

Enabling or Disabling Usage of the Daemon Process

Usage of the daemon process is enabled in Hvigor by default. You can manage the settings using the following methods:

Setting the Daemon Memory

The maximum old-generation memory allocated to the daemon process defaults to 8192 MB, which is sufficient for most builds. To customize the maximum old-generation memory for the daemon process, use either of the following methods. Adjust the settings based on your available local memory. The command-line option takes precedence over the hvigor-config.json5 configuration.

The maximum semi-space size of the young-generation memory for the daemon process defaults to 16 MB. By modifying this value, you can control garbage collection frequency, which directly impacts performance and memory usage. You can use either of the following methods to modify the settings. The CLI method has a higher priority than the hvigor-config.json5 file.

This feature is supported since DevEco Studio 5.1.0 Release.

Setting the Daemon Idle Timeout

The default idle timeout for the daemon process is three hours, counted from the completion of the last build task. The daemon process exits once this duration is exceeded. Since version 26.0.0, the daemon idle timeout can be customized. Two methods are supported, with the command-line option taking precedence over the hvigor-config.json5 configuration:

Checking the Status of the Daemon Process

To get a list of running daemon processes and their status, you can use the following command:

hvigorw --status-daemon
> hvigor PID    STATUS  PORT    ROOT_PATH
> hvigor 11072  idle    45001   D:\Demo1
> hvigor 18836  stopped 45000   D:\Demo2

Status

Description

idle

Idle

half_busy

Half busy

busy

Busy

canceled

Canceled

stopReq

Stopped as requested.

stopped

Stopped

broken

Interrupted

Stopping a Daemon Process

It is necessary to restart a daemon process when changing the memory settings or debugging faults.

You can use the following command to stop a daemon process:

hvigorw --stop-daemon

If you want to stop all daemon processes, run the following command:

hvigorw --stop-daemon-all

Performance Impact

The daemon process can significantly reduce the time for repeated builds of the same project. For multiple builds, the daemon process loads Hvigor into the memory only once, instead of for every build.