ShadowsocksR-Live / shadowsocksr-native

翻墙 从容穿越党国敏感日 ShadowsocksR (SSRoT) native implementation for all platforms, GFW terminator
https://github.com/ShadowsocksR-Live/shadowsocksr-native/wiki
GNU General Public License v3.0
2.74k stars 765 forks source link

未有代理连接时,树莓派4客户端 cpu 30% #191

Closed ygao9999 closed 3 years ago

ygao9999 commented 3 years ago

Debian / Ubuntu

sudo su # using root account

sudo apt-get update -y sudo apt-get upgrade -y sudo apt-get install --no-install-recommends build-essential autoconf libtool asciidoc xmlto -y sudo apt-get install git gcc g++ gdb cmake automake -y sudo apt-get -f install -y

cd / # switch to root directory

git clone https://github.com/ShadowsocksR-Live/shadowsocksr-native.git mv shadowsocksr-native ssr-n # rename shadowsocksr-native to ssr-n cd ssr-n # enter ssr-n directory. git submodule update --init git submodule foreach -q 'git checkout $(git config -f $toplevel/.gitmodules submodule.$name.branch || echo master)'

build ShadowsocksR-native

mkdir build && cd build cmake .. && make

make install

/bin/cp -rfa src/ssr-* /usr/bin

树莓派4 官方系统32位 未有代理连接时,树莓派4客户端 cpu 一直在30%

ssrlive commented 3 years ago

没有测试环境,你能否帮助查看一下各线程的调用栈,看是哪里在空转?

ygao9999 commented 3 years ago

不知如何操作,给出指令,我可以试一下。

ygao9999 commented 3 years ago

在https://gitter.im/ShadowsocksR-Live/Lobby 联系你,可好?

ssrlive commented 3 years ago

哪里联系都一样。就是用 gdb 命令将软件加载进调试器,运行过程中停下来,看看每个线程的调用栈。这要会 gdb 调试器基本操作。 gdb 启动命令如下格式

gdb --args /usr/bin/ssr-client -c /etc/ssr-native/config.json
ygao9999 commented 3 years ago

Command name abbreviations are allowed if unambiguous. (gdb) run Starting program: /usr/bin/ssr-client -c /etc/ssr-native/config.json [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1". ssr-client 2021/01/15 10:56 info ShadowsocksR native client

ssr-client 2021/01/15 10:56 info remote server appl**:443 ssr-client 2021/01/15 10:56 info method aes-128-ctr ssr-client 2021/01/15 10:56 info password bb** ssr-client 2021/01/15 10:56 info protocol origin ssr-client 2021/01/15 10:56 info obfs plain ssr-client 2021/01/15 10:56 info
ssr-client 2021/01/15 10:56 warn over TLS yes ssr-client 2021/01/15 10:56 info over TLS domain ssr-client 2021/01/15 10:56 info over TLS path
ssr-client 2021/01/15 10:56 info
ssr-client 2021/01/15 10:56 info udp relay yes

[New Thread 0xb6d77460 (LWP 3940)] [New Thread 0xb6576460 (LWP 3941)] [New Thread 0xb5d75460 (LWP 3942)] [New Thread 0xb5574460 (LWP 3943)] ssr-client 2021/01/15 10:56 info listening on 0.0.0.0:1080

ssrlive commented 3 years ago

许久没用 gdb,基本命令我都忘了,你找个教程看看吧。然后再报告。

ygao9999 commented 3 years ago

pi@raspberrypi:~ $ ps aux |grep ssr pi 4171 82.4 0.0 38344 2712 ? Rsl 11:11 11:56 /usr/bin/ssr-client -d -c /etc/ssr-native/config.json pi 4216 0.0 0.0 7796 536 pts/1 S+ 11:26 0:00 grep --color=auto ssr pi@raspberrypi:~ $ gdb GNU gdb (Raspbian 8.2.1-2) 8.2.1 Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "arm-linux-gnueabihf". Type "show configuration" for configuration details. For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/. Find the GDB manual and other documentation resources online at: http://www.gnu.org/software/gdb/documentation/.

For help, type "help". Type "apropos word" to search for commands related to "word". (gdb) attach 4171 Attaching to process 4171 [New LWP 4172] [New LWP 4173] [New LWP 4174] [New LWP 4175] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1". 0xb6e1d9d0 in epoll_wait (epfd=, events=0xbe841208, maxevents=1024, timeout=0) at ../sysdeps/unix/sysv/linux/epoll_wait.c:30 30 ../sysdeps/unix/sysv/linux/epoll_wait.c: 没有那个文件或目录. (gdb) info threads Id Target Id Frame

ygao9999 commented 3 years ago

(gdb) thread 1 [Switching to thread 1 (Thread 0xb6fc8010 (LWP 4171))]

0 0xb6e1d9d0 in epoll_wait (epfd=, events=0xbe841208, maxevents=1024, timeout=0) at ../sysdeps/unix/sysv/linux/epoll_wait.c:30

30 in ../sysdeps/unix/sysv/linux/epoll_wait.c (gdb) bt

0 0xb6e1d9d0 in epoll_wait (epfd=, events=0xbe841208, maxevents=1024, timeout=0) at ../sysdeps/unix/sysv/linux/epoll_wait.c:30

1 0x00089608 in uv.io_poll ()

2 0x000766dc in uv_run ()

3 0x0003c9a0 in ssr_run_loop_begin (cf=0x1632180, feedback_state=0x3dcc0 , p=0x0) at /ssr-n/src/client/listener.c:133

4 0x0003d8cc in main (argc=4, argv=0xbe8455d4) at /ssr-n/src/client/main.c:140

ssrlive commented 3 years ago

卧槽!难道是 libuv 的问题? “树莓派4 官方系统32位” 是哪个 Linux 发行版?

ygao9999 commented 3 years ago

树莓派4 官方系统32位

Raspbian

ssrlive commented 3 years ago

我这里在Windows下工作时占13%CPU,你观察多点时间看情况啥样。

image

ygao9999 commented 3 years ago

杀掉ssr cpu是1, 运行ssr-client是30%,工作时31%,没有明显变化。

ssrlive commented 3 years ago

我也没头绪了,我去看看 libuv 社区……

ssrlive commented 3 years ago

找到原因了。稍后修复。

ssrlive commented 3 years ago

搞完。你测试一把?

ygao9999 commented 3 years ago

牛逼了,问题解决。