Comments (12)
The code to set up watches recursively in inotifywatch is here:
https://github.com/rvoicilas/inotify-tools/blob/master/libinotifytools/src/inotifytools.c#L1289
from notify.
If you run the inotifywatch
program for, say, 30 seconds, how does it fare?
from notify.
Note that 100k+ watches is probably an edge-case... Was this for testing, or are you doing this regularly?
from notify.
As far as I can tell, the code you linked does a simple recursive directory walk. We delegate ours to the Walkdir crate, but the base implementation is pretty much the same.
from notify.
As with @hannobraun upstream at inotify-rs, I think hitting the limit on watches is understandable and expected in this case. The bug remains that you're seeing 100% CPU usage, so that's what should be focused on, I think.
from notify.
If you run the inotifywatch program for, say, 30 seconds, how does it fare?
It runs fine with barely any CPU usage.
$ time inotifywatch ~ -r -t 30
Establishing watches...
Finished establishing watches, now collecting statistics.
total access modify close_write close_nowrite open moved_from moved_to create filename
324 114 0 0 105 105 0 0 0
....
real 0m33.266s
user 0m0.879s
sys 0m2.384s
from notify.
Note that 100k+ watches is probably an edge-case... Was this for testing, or are you doing this regularly?
I'd like to run a daemon that watches all files in $HOME
. Most desktop search clients do this.
With inotify, you do not need to add a watch to a file if you're watching the parent directory.
When a directory is monitored, inotify will return events for the directory itself, and for files inside the directory.
source: man inotify
from notify.
Yes, I think we do only watch directories unless specifically asked ;) (and
even then, at first we refused to watch single files).
I'm not sure desktop searches actually do this, rather I think they keep an
index that they update by crawling regularly. On Gnome, for example, the
tracker
service's logs can be seen doing that — I occasionally have to
kill it when it gets stuck on large files that change while it's looking at
them.
Even then, the 100% cpu usage is certainly a bug, and that inotifywatch
manages it just fine is a testament to that.
This may not get fixed until the great refactor of #62 and related, mind,
unless the CPU sink is identified...
On Sun, 22 May 2016, 19:17 Jos van den Oever [email protected]
wrote:
Note that 100k+ watches is probably an edge-case... Was this for testing,
or are you doing this regularly?I'd like to run a daemon that watches all files in $HOME. Most desktop
search clients do this.With inotify, you do not need to add a watch to a file if you're watching
the parent directory.When a directory is monitored, inotify will return events for the
directory itself, and for files inside the directory.source: man inotify
—
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#69 (comment)
from notify.
From reading the code, it seems that you are putting a watch on every file. Simply adding a filter there with is_dir() would reduce the memory load and perhaps also the cpu load.
https://github.com/passcod/rsnotify/blob/master/src/inotify/mod.rs#L102
from notify.
Ah, you're right. This must have slipped through a refactor. I'll fix
tomorrow.
On Mon, 23 May 2016, 02:37 Jos van den Oever [email protected]
wrote:
From reading the code, it seems that you are putting a watch on every
file. Simply adding a filter there with is_dir() would reduce the memory
load and perhaps also the cpu load.https://github.com/passcod/rsnotify/blob/master/src/inotify/mod.rs#L102
—
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#69 (comment)
from notify.
#74 changes rsnotify so it only watches directories.
from notify.
I've found that the example code is wrong. There is no 100% cpu user. Here is a fixed example. I'll close this issue.
extern crate notify;
use std::sync::mpsc::Receiver;
use std::sync::mpsc::sync_channel;
use std::thread;
use notify::{RecommendedWatcher, Watcher};
use std::sync::mpsc::channel;
fn watch() -> notify::Result<()> {
// Create a channel to receive the events.
let (tx, rx) = channel();
// Automatically select the best implementation for your platform.
// You can also access each implementation directly e.g. INotifyWatcher.
let mut watcher: RecommendedWatcher = try!(Watcher::new(tx));
// Add a path to be watched. All files and directories at that path and
// below will be monitored for changes.
try!(watcher.watch("/home/oever"));
loop {
// You'll probably want to do that in a loop. The type to match for is
// notify::Event, look at src/lib.rs for details.
match rx.recv() {
Ok(notify::Event{path:Some(path),op:Ok(op)}) => {
println!("{:?} {:?}", op, path);
},
Err(e) => println!("watch error {}", e),
_ => ()
}
}
}
fn main() {
if let Err(err) = watch() {
println!("Error!: {:?}", err)
}
}
from notify.
Related Issues (20)
- Debouncers don't implement Debug HOT 3
- Is there someway to make debounce-watcher be async? HOT 3
- release with bumped `bitflags` and `filetime` version HOT 2
- (even more) license clarifications: non-standard Artistic-2.0 license HOT 6
- Potential Double Free Issue HOT 2
- Use KqueueWatcher as RecommendedWatcher for iOS
- Breaking Changes v7 HOT 7
- notify crate not actually including license text HOT 2
- Catch no events after saving a watching file with Vim editor HOT 1
- How to write unit tests that exercise a watcher? HOT 3
- Filtering out `log` logs HOT 2
- 【with tokio】After executing `git checkout .` command and then modifying the file, unable to get response to file changes
- Advice for multiple watchers of the same path(s) HOT 2
- How do you dynamically observe files in a directory and log a new file as it appears HOT 1
- My program stops getting events after some time HOT 2
- Watch code is not run inside helper function HOT 2
- `notify-debouncer-full` / `-mini` always enable `notify` default features
- Proposal: Change the serialization format of events HOT 2
- Inconsistent behaviors when root node changes HOT 3
- inotify backend: MOVE_SELF event keeps watch and reports incorrect path HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from notify.