我们在使用腾讯云的时候,当我们网络udp包比较密集的时候,会出现cpu 的sys大于50%
从perf上看是是close操作造成的,从strace看, YDService有频繁的close操作,但我们的程序没有频繁close文件,有1s 1000次左右的写日志,udp会一直频繁的收发
- 69.33% 69.33% seaboxsql [kernel.kallsyms] [k] native_queued_spin_lock_slowpath
- 69.11% 0
- 27.41% __libc_close
int_signal
do_notify_resume
task_work_run
____fput
__fput
fsnotify
fanotify_handle_event
fsnotify_add_event
_raw_qspin_lock
- queued_spin_lock_slowpath
27.41% native_queued_spin_lock_slowpath
+ 14.80% __libc_close
+ 14.60% __libc_close
+ 4.52% __libc_close
+ 3.95% __libc_close
+ 3.83% __libc_close
把云镜服务YDService, YDEdr, YDLive 停掉问题解决
cpu 96核, 我们的程序大约100个线程
指针是const的。不幸的是,编译器仍然不知道结果是否是const指针的别名。始终可以使用非const指针作为常量指针。例如,许多函数将一个const char(即字符串)指针作为参数,但是如果你愿意的话,可以把它传给一个非const指针
#include <inttypes.h>
intmax_t strtoimax(const char * restrict nptr,
char ** restrict endptr, int base);
--- snip ---