epoll: Don't iterate all the fds when using epoll#5
epoll: Don't iterate all the fds when using epoll#5xiaosuo wants to merge 1 commit intoossrs:masterfrom
Conversation
|
Please merge it |
|
|
I have merge this PR to https://github.com/ossrs/state-threads/tree/features/xiaosuo/epoll |
|
重新看了ST的调度和IO事件处理的代码,看懂了你说的问题在哪里,以及主要优化的场景,我记录在了这里:#13 (comment) ST在收到事件后,会遍历io_q,因为st对于fd的记录只记录了events,而没有记录哪些协程(_st_pollq_t)在侦听这个fd,因为一个协程可能会用 如果FD很多时,有大量等待IO的fd时,就会触发这个性能瓶颈,可以看到 由于这个修改涉及较多,我觉得还是应该先完善ST的UTest,然后再修改这个问题。
|
| _st_pollq_t *pq; | ||
| _st_pollq_t **pqs; | ||
| }; | ||
| int pq_cnt; |
There was a problem hiding this comment.
_st_epolldata. evtlist.epoll_data.ptr是可以放自定义指针的。
可能更适合放_st_pollq_t的信息,可以存放协程的链表_st_clist_t。
typedef union epoll_data {
void *ptr;
int fd;
uint32_t u32;
uint64_t u64;
} epoll_data_t;
struct epoll_event {
uint32_t events; /* Epoll events */
epoll_data_t data; /* User data variable */
};
There was a problem hiding this comment.
#[[[[[**_```
> ~~~~~~~~``~~committed ~~``~~~~~~~~
For #4