Skip to content

Watcher: No need to keep polling mtimes if already stale #523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2017

Conversation

jeremy
Copy link
Member

@jeremy jeremy commented May 18, 2017

Since #mark_stale only informs listeners of staleness if not already stale, we don't need to keep polling for mtime when we're already stale. Just stop the poller thread entirely.

That saves significant CPU/IO (i.e. laptop battery) if you have, say, an IRB console sitting open.

@jonleighton
Copy link
Member

What's the context for this change? What's the problem that the existing implementation causes?

@jeremy
Copy link
Member Author

jeremy commented May 20, 2017

Not a problem in the sense that anything is broken. Once we're marked as stale, any further checks will just mark as stale again, which no-ops if we're already stale. So: once we detect mtimes have changed, we needn't detect subsequent changes.

That saves significant CPU/IO (i.e. laptop battery) if you have, say, an IRB console sitting open.

Context is #522. I had added logging to see what the watcher is doing, and wow is it doing a ton of costly computed-mtime gathering that it just drops on the floor… since it's already stale.

@jeremy jeremy force-pushed the skip-polling-when-stale branch from 13eacb0 to 0c3f0d5 Compare May 20, 2017 23:25
@jonleighton
Copy link
Member

if you have, say, an IRB console sitting open.

Aha, that's the use case I was not thinking about. Makes sense :shipit:

@jonleighton jonleighton merged commit 795ba21 into master May 21, 2017
@kaspth kaspth deleted the skip-polling-when-stale branch May 21, 2017 11:12
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