On Wednesday 05/08 at 15:25 -0400, Alberto Lerner wrote:
> Calvin, I don't think there is any opposition.
> But it's a tricky patch on at least two grounds.
>
> First, making this kind of decision should be
> based on further evidence besides a single
> benchmark clobbered together in a laptop.
Of course, it was more of a proof of concept sort
of thing.
> Actual hypervisors are actually very good at
> detecting the guest os doesn't really need
> attention.
Hypervisors can do some clever things, but there's
no way that select() wakeup is getting optimized
away - and that wakeup would be more expensive on
a virtualized platform, not less.
> Also, if you're spinning a mongod, how often is
> it going to stay without getting any request for
> longer than the time out? So getting more data
> about this things should make the effectiveness
> (or need) of this patch clearer.
I think you're forgetting that the timeout has
overhead even if it never happens. Consider the
following:
https://http.snarkywidgets.com/select_example.c
Below is a quick run of that code on an idle AWS
instance: (I ran this about 10 times, the numbers
were consistent).
$ gcc -std=gnu99 -O3 select_example.c
$ time ./a.out
real 0m0.964s
user 0m0.216s
sys 0m0.748s
$ gcc -std=gnu99 -O3 -DDO_TIMEOUT select_example.c
$ time ./a.out
real 0m1.454s
user 0m0.264s
sys 0m1.188s
As you can see, even when the timeout never
triggers, it has non-negligible overhead. That's a
50% performance hit. Even though it's no great
amount of time, it's worth recognizing that the
timeouts aren't by any means free.
> The second point is that it is quite common not
> to block in a select and use the timeouts to,
> for instance, trigger timed callbacks (taks that
> are in the background that can be woken up when
> the server load is not hight). We don't exactly
> do this right now but when the timeout was put
> in place, it was also with this goal in mind.
That makes sense, but the timeout would definitely
be longer than 10ms in that case, wouldn't it?
> There is also the point that that file is on the
> center of a couple of improvements we're
> planning for this cycle, related to connection
> handling (actually loss thereof). And there's
> only so much change that can be done before we
> start wondering if we're introducing one too
> many changes.
That's fair, of course. I'm happy to wait, just
wanted to know if anybody was listening. :)
Thanks very much,
Calvin