acl-dev / acl

C/C++ server and network library, including coroutine,redis client,http/https/websocket,mqtt, mysql/postgresql/sqlite client with C/C++ for Linux, Android, iOS, MacOS, Windows, etc..
https://acl-dev.cn
GNU Lesser General Public License v3.0
2.83k stars 937 forks source link

Some doubts #335

Closed pengwang7 closed 3 months ago

pengwang7 commented 3 months ago

`

ifdef SYS_UNIX

int select(int nfds, fd_set readfds, fd_set writefds, fd_set exceptfds, struct timeval timeout) { return acl_fiber_select(nfds, readfds, writefds, exceptfds, timeout); }

endif

if defined(SYS_UNIX) && !defined(DISABLE_HOOK)

int poll(struct pollfd *fds, nfds_t nfds, int timeout) { return acl_fiber_poll(fds, nfds, timeout); }

endif

1.这个DISABLE_HOOK宏对select/epoll不生效, 能说明下用意吗?

2.ARGV实现中, 存在STRDUP与mem_free混用的情况, 在DEBUG_MEM下是否会有统计异常的情况, 是否应该是mem_strdup与mem_free一起使用?

3.在IO非常密集的业务下,使用libfiber是否能够减少IO收发延时?对比thread peer epoll理论上有性能上的优势吗? `

zhengshuxin commented 3 months ago

1、DISABLE_HOOK 应该是把select/epoll 漏掉了,没有什么特殊的含义; 2、ARGV中的STRDUP确实应换成mem_strdup以便做内存统计; 3、libfiber 本质上是提升连接并发能力,至于IO收发延时取决于系统的IO API;你的thread peer epoll请详细说明一下。

pengwang7 commented 3 months ago

就是每个IO线程都有自己的epoll 在大规模UDP转发的业务背景下, libfiber对比上面的提到的有并发上的优势吗? 现在使用过程中感觉API非常简单好用,就是不知道理论上进行对比是否有优势

zhengshuxin commented 3 months ago

libfiber是每个线程一个epoll,所以性能还不错;另外,基于libfiber编写的网络服务可以支持大并发,为了支持更大的并发,还可以启用协程共享栈模式以减少内存占用。关于libfiber的特点和使用可以参考: https://acl-dev.cn/2020/06/05/about_fiber/ https://acl-dev.cn/2019/04/07/fiber/ https://acl-dev.cn/2016/07/06/fiber_web/

pengwang7 commented 3 months ago

好的, 感谢!