sing-box icon indicating copy to clipboard operation
sing-box copied to clipboard

`process_name` or `find_process` cause high CPU load

Open Primate8423 opened this issue 8 months ago • 1 comments

Operating system

Linux

System version

Pop!_OS 24.04 LTS

Installation type

Original sing-box Command Line

If you are using a graphical client, please provide the version of the client.

No response

Version

sing-box version 1.13.3

Environment: go1.25.8 linux/amd64
Tags: with_gvisor,with_quic,with_dhcp,with_wireguard,with_utls,with_acme,with_clash_api,with_tailscale,with_ccm,with_ocm,with_naive_outbound,badlinkname,tfogo_checklinkname0,with_musl
Revision: d3768cca3602c2949417fe767c1acd88d7f67698
CGO: enabled

Description

If find_process is enabled or process_name is used in rules, high CPU load can be observed if there are a lot of active connections (e.g. running qBittorrent). Webpage loading is sluggish, and Clash API become very slow to respond.

Disabling find_process and process_name reduces CPU load significantly in my case.

I've tried reducing udp_timeout to 5s as suggested in #692 and it does not help.

Is the high CPU load when using find_process expected? If so, we should probably mention find_process and process_name are expensive in documentation.

Reproduction

Open qBittorrent, add 7 or 8 torrents with high seeding / leeching activities. Start sing-box with the config.json below.

During the observation the active connection fluctuates in 130 to 150 range. The CPU% may exceed 100 in htop.

pprof trace file is also attached below.

trace.zip

config.json:

{
    "log": {
        "disabled": false,
        "level": "trace",
        "output": "box.log",
        "timestamp": true
    },
    "dns": {
        "servers": [
            {
                "tag": "local",
                "type": "udp",
                "server": "223.5.5.5"
            }
        ],
        "final": "local",
        "strategy": "prefer_ipv4",
        "disable_cache": false,
        "disable_expire": false,
        "reverse_mapping": true
    },
    "inbounds": [
        {
            "type": "tun",
            "tag": "Tun-In",
            "address": [
                "172.19.0.1/30",
                "fdfe:dcba:9876::1/126"
            ],
            "auto_redirect": true,
            "auto_route": true,
            "strict_route": false
        }
    ],
    "outbounds": [
        {
            "type": "direct",
            "tag": "direct"
        }
    ],
    "route": {
        "rules": [
            {
                "action": "sniff"
            },
            {
                "protocol": "dns",
                "action": "hijack-dns"
            },
            {
                "ip_is_private": true,
                "outbound": "direct"
            }
        ],
        "final": "direct",
        "auto_detect_interface": true,
        "override_android_vpn": false,
        "find_process": true,
        "default_domain_resolver": "local"
    },
    "experimental": {
        "cache_file": {
            "enabled": true
        },
        "clash_api": {
            "external_controller": "127.0.0.1:9090",
            "secret": "1145141919810"
        },
        "debug": {
            "listen": "localhost:23232"
        }
    }
}

Logs

Field can not be longer than 65536 characters, see the attachment `trace.zip` above.

Supporter

Integrity requirements

  • [x] I confirm that I have read the documentation, understand the meaning of all the configuration items I wrote, and did not pile up seemingly useful options or default values.
  • [x] I confirm that I have provided the server and client configuration files and process that can be reproduced locally, instead of a complicated client configuration file that has been stripped of sensitive data.
  • [x] I confirm that I have provided the simplest configuration that can be used to reproduce the error I reported, instead of depending on remote servers, TUN, graphical interface clients, or other closed-source software.
  • [x] I confirm that I have provided the complete configuration files and logs, rather than just providing parts I think are useful out of confidence in my own intelligence.

Primate8423 avatar Mar 18 '26 09:03 Primate8423

Fixed. Closing.

Primate8423 avatar Aug 19 '26 07:08 Primate8423