Skip to content

Conversation

ebroder
Copy link

@ebroder ebroder commented May 31, 2012

The timeout is only being used to coarsely track elapsed time, but it
causes the process to wake up unnecessarily about 100 times a second,
only for it to discover it has nothing to do and go back to sleep.

Instead, allow the process to sleep until there's work available, and
then query the system clock to figure out how much time has passed,
using a guaranteed monotonically increasing clock on Linux (where it's
available) and gettimeofday everywhere else (where it's not).

The timeout is only being used to coarsely track elapsed time, but it
causes the process to wake up unnecessarily about 100 times a second,
only for it to discover it has nothing to do and go back to sleep.

Instead, allow the process to sleep until there's work available, and
then query the system clock to figure out how much time has passed.
@ebroder
Copy link
Author

ebroder commented May 31, 2012

Thanks for the pointers, and super-fast review.

I've gone ahead and adjusted the commit to use curTimeMillis64() instead of my own thing.

I didn't think about the inShutdown thing because I've apparently gotten used to thinking in evented instead of in threads. Do you have any thoughts on how you'd want to approach that? My inclination would be a condition variable, but I don't know how to interrupt select based on a condition variable.

@ghost ghost assigned amschwerin Jun 6, 2012
@amschwerin
Copy link
Contributor

The problem is tricky. Typically, you interrupt select with a signal, but we don't currently have a facility for using Unix signals to interrupt threads. Removing these polling constructs is a goal of mine, but a lot of that work requires more redesign, and is harder to paper over than you might imagine. I think that we'll want to change some of the higher level abstractions in the process.

In the interim, could you just make this pull request about fixing up the elapsed time computation (leave the timeout in place)?

@kangas
Copy link
Contributor

kangas commented Jun 28, 2014

Hi Evan! It was great meeting you last week at MongoDB World.

I just realized you still have this pull request open in our queue. Since you cannot sign our CLA presently and this is basically the same issue as SERVER-2114 (and pull #416), I am closing this one.

Let's get your legal department talking to ours soon, and find a way for you to be cleared to contribute.

--Matt

@kangas kangas closed this Jun 28, 2014
BradBarnich pushed a commit to BradBarnich/mongo that referenced this pull request Feb 6, 2019
[BLD-638] Different version string in server and client
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants