Open Fijxu opened 2 months ago
After profiling netclient with pprof
. The heap usage showed that the func ParseHosts
was using a lot of memory. The main reason what that my hosts file has more than 400K entries (blocked domains).
https://github.com/gravitl/txeh/blob/3778c58bd69f81aa845bda0d5149532d6bc5e0bb/txeh.go#L351
$ wc -l /etc/hosts
451343 /etc/hosts
After deleting all entries and leaving only the essential ones, netclient no longer uses a huge amount of CPU and memory. This is still an issue, so if you guys are going to address it, keep this open. Does netclient really needs to parse all the entries on the hosts file?
Wow 400K entries in hosts file, never thought about it before. hosts file was used in old versions. It was abandoned already. I removed the old code in normal logic and only keep it in migrate. https://github.com/gravitl/netclient/pull/898 Please wait and verify in new release.
When using
netclient daemon
or the systemd service, the CPU and RAM usage increases until the process is killed. Sadly I have no clue why this happens. I already tried and checked a few things:iptables
netclient daemon
works perfectly on my 5 machines, no CPU usage nor high RAM usage; my laptop is the only machine with this problem."verbosity": 3
and"debug": true
logs:The high CPU usage starts at
[netclient] YYYY-MM-DD HH:MM:SS adding forwarding rule
lineI can give more debug information if I can get some insight on how to do it. Thanks!