Multi-process support
heiher opened this issue · 2 comments
heiher commented
Summary
Improve CPU utilization on Linux systems by implementing multi-process support.
Motivation
To address the limitations of the current single-threaded mode, and to fully utilize the multi-core CPU resources of the system, enhancing transfer throughput by enabling multi-process mode.
Description
The multi-process mode will be supported on Linux systems, and a configuration option will be added to control the toggle of multi-process mode. When multi-process mode is enabled, the multi-queue function of the TUN device will be activated, allowing multiple processes to work on the same TUN device, with data flows distributed across multiple processes.
heiher commented
Enable multi-process (multi-queue) on Linux systems:
tunnel:
name: tun0
mtu: 9000
multi-queue: true
ipv4: 198.18.0.1
ipv6: 'fc00::1'
Run 4 processes:
# Process 1
hev-socks5-tunnel conf.yml
# Process 2
hev-socks5-tunnel conf.yml
# Process 3
hev-socks5-tunnel conf.yml
# Process 4
hev-socks5-tunnel conf.yml
heiher commented
Benchmarks (single-process vs multi-process)
- commit id: ee96124
- testing environment: same as basic benchmarks
- maximum processes: 4
Speed
CPU Usage
Memory Usage
Upload
$ iperf3 -c 192.168.0.8
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 5] 0.00-10.00 sec 23.0 GBytes 19.8 Gbits/sec 0 sender
[ 5] 0.00-10.04 sec 23.0 GBytes 19.7 Gbits/sec receiver
CPU usage: 76%
MEM usage: 2.7M
$ iperf3 -c 192.168.0.8 -P 10
- - - - - - - - - - - - - - - - - - - - - - - - -
[SUM] 0.00-10.00 sec 21.1 GBytes 18.1 Gbits/sec 0 sender
[SUM] 0.00-10.50 sec 21.1 GBytes 17.3 Gbits/sec receiver
CPU usage: 90%
MEM usage: 3.3M
$ iperf3 -c 192.168.0.8 -P 10
- - - - - - - - - - - - - - - - - - - - - - - - -
[SUM] 0.00-10.00 sec 51.3 GBytes 44.1 Gbits/sec 0 sender
[SUM] 0.00-10.04 sec 51.3 GBytes 43.9 Gbits/sec receiver
CPU usage 1: 68%
CPU usage 2: 64%
CPU usage 3: 42%
CPU usage 4: 28%
MEM usage 1: 2.7M
MEM usage 2: 2.7M
MEM usage 3: 2.5M
MEM usage 4: 2.7M
Download
$ iperf3 -c 192.168.0.8 -R
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 5] 0.00-10.04 sec 24.8 GBytes 21.2 Gbits/sec 0 sender
[ 5] 0.00-10.00 sec 24.7 GBytes 21.3 Gbits/sec receiver
CPU usage: 90%
MEM usage: 2.7M
$ iperf3 -c 192.168.0.8 -R -P 10
- - - - - - - - - - - - - - - - - - - - - - - - -
[SUM] 0.00-10.04 sec 24.7 GBytes 21.1 Gbits/sec 0 sender
[SUM] 0.00-10.00 sec 24.5 GBytes 21.1 Gbits/sec receiver
CPU usage: 90%
MEM usage: 3.2M
$ iperf3 -c 192.168.0.8 -R -P 10
- - - - - - - - - - - - - - - - - - - - - - - - -
[SUM] 0.00-10.04 sec 61.4 GBytes 52.6 Gbits/sec 0 sender
[SUM] 0.00-10.00 sec 61.3 GBytes 52.6 Gbits/sec receiver
CPU usage 1: 90%
CPU usage 2: 90%
CPU usage 3: 50%
CPU usage 4: 50%
MEM usage 1: 2.7M
MEM usage 2: 2.7M
MEM usage 3: 2.7M
MEM usage 4: 2.7M