Welcome! Log In Create A New Profile

Advanced

Re: why delta only include the execution time of ngx_process_events not ngx_event_process_posted (Zhang Chao) (Valentin V. Bartenev)

Posted by yang chen 
Thank you very much, but there is another question, if delta larger than
1ms, it will invole the ngx_event_expire_timers, why not 2ms or others? how
do you get the value?
if there are much events comming for 30s, and epoll_wait return quickly
(linux) which less than 1ms in each circle,
and the ngx_event_expire_timers will not be excecuted for 30s?
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
On Tuesday, 7 November 2017 14:36:47 MSK yang chen wrote:
> Thank you very much, but there is another question, if delta larger than
> 1ms, it will invole the ngx_event_expire_timers, why not 2ms or others? how
> do you get the value?
> if there are much events comming for 30s, and epoll_wait return quickly
> (linux) which less than 1ms in each circle,
> and the ngx_event_expire_timers will not be excecuted for 30s?
>

ngx_event_expire_timers() doesn't care about delta at all. It uses absolute
time and all timers have an absolute time when they have to be triggered.
The function triggers all the timers with absolute time less or equal than
the current time. This delta check is just an optimization.

I suggest you to read the code of the function. It's hard to understand the
logic, if you read only the part of it and don't have the whole picture in
the mind.

wbr, Valentin V. Bartenev

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
On Tuesday, 7 November 2017 18:02:44 MSK Valentin V. Bartenev wrote:
> On Tuesday, 7 November 2017 14:36:47 MSK yang chen wrote:
> > Thank you very much, but there is another question, if delta larger than
> > 1ms, it will invole the ngx_event_expire_timers, why not 2ms or others? how
> > do you get the value?
> > if there are much events comming for 30s, and epoll_wait return quickly
> > (linux) which less than 1ms in each circle,
> > and the ngx_event_expire_timers will not be excecuted for 30s?
> >
>
> ngx_event_expire_timers() doesn't care about delta at all. It uses absolute
> time and all timers have an absolute time when they have to be triggered.
> The function triggers all the timers with absolute time less or equal than
> the current time. This delta check is just an optimization.
>
> I suggest you to read the code of the function. It's hard to understand the
> logic, if you read only the part of it and don't have the whole picture in
> the mind.
>

Or, maybe I misunderstand your question.

ngx_current_msec is updated once in the loop.

In short it looks like this:

loop {
delta = time;
update(time);
delta = time - delta;

if (delta) {
expire_timers();
}
}

Eventually, the time shift will be 1ms or more.

wbr, Valentin V. Bartenev

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login