{"action":"created","issue":{"url":"https://api.github.com/repos/passcod/rsnotify/issues/69","repository_url":"https://api.github.com/repos/passcod/rsnotify","labels_url":"https://api.github.com/repos/passcod/rsnotify/issues/69/labels{/name}","comments_url":"https://api.github.com/repos/passcod/rsnotify/issues/69/comments","events_url":"https://api.github.com/repos/passcod/rsnotify/issues/69/events","html_url":"https://github.com/passcod/rsnotify/issues/69","id":156108931,"number":69,"title":"100% CPU usage on high (100k+) number of watches","user":{"login":"vandenoever","id":608417,"avatar_url":"https://avatars.githubusercontent.com/u/608417?v=3","gravatar_id":"","url":"https://api.github.com/users/vandenoever","html_url":"https://github.com/vandenoever","followers_url":"https://api.github.com/users/vandenoever/followers","following_url":"https://api.github.com/users/vandenoever/following{/other_user}","gists_url":"https://api.github.com/users/vandenoever/gists{/gist_id}","starred_url":"https://api.github.com/users/vandenoever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vandenoever/subscriptions","organizations_url":"https://api.github.com/users/vandenoever/orgs","repos_url":"https://api.github.com/users/vandenoever/repos","events_url":"https://api.github.com/users/vandenoever/events{/privacy}","received_events_url":"https://api.github.com/users/vandenoever/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/passcod/rsnotify/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/passcod/rsnotify/labels/os-linux","name":"os-linux","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-05-21T16:02:39Z","updated_at":"2016-05-22T06:35:17Z","closed_at":null,"body":"I've tried the example on my $HOME directory with 125k folders.\r\n\r\n```rust\r\nfn watch() {\r\n  // Create a channel to receive the events.\r\n  let (tx, rx) = channel();\r\n\r\n  // Automatically select the best implementation for your platform.\r\n  // You can also access each implementation directly e.g. INotifyWatcher.\r\n  let w: Result<RecommendedWatcher, Error> = Watcher::new(tx);\r\n\r\n  match w {\r\n    Ok(mut watcher) => {\r\n      // Add a path to be watched. All files and directories at that path and\r\n      // below will be monitored for changes.\r\n      let mut r = watcher.watch(\"/home/oever\");\r\n      while let Ok(()) = r {\r\n          // You'll probably want to do that in a loop. The type to match for is\r\n          // notify::Event, look at src/lib.rs for details.\r\n          match rx.recv() {\r\n            Ok(notify::Event{path:Some(path),op:Ok(op)}) => {\r\n                println!(\"{:?} {:?}\", op, path);\r\n            },\r\n            Err(e) => println!(\"watch error {}\", e),\r\n            _ => ()\r\n          }\r\n          println!(\"next round\");\r\n          r = watcher.watch(\"/home/oever/src\");\r\n      }\r\n      if let Err(err) = r {\r\n          println!(\"Error?: {:?}\", err);\r\n      }\r\n    },\r\n    Err(err) => println!(\"Error!: {:?}\", err)\r\n  }\r\n}\r\n```\r\nprints out\r\n```\r\nError?: Io(Error { repr: Os { code: 28, message: \"No space left on device\" } })\r\n```\r\nThe error occurred in the watch() loop. Inotify had plenty of handles left:\r\n```bash\r\n$ cat /proc/sys/fs/inotify/max_user_watches\r\n524288\r\n```\r\nWhen I increase the number of allowed watches to 2.5M, then this error does not occur, but rsnotify does take up 100% cpu continuously.\r\n\r\nI've compared with `inotifywatch ~ -r`. This program only needs only a watch per directory. It can set the watches very quickly. Only 3.2 seconds on my laptop with SSD. I've timed this with\r\n```bash\r\ntime inotifywatch ~ -r -t 1\r\n```\r\nThis sets watches on all directories in the home folder and continues to run for 1 second after it has done that."},"comment":{"url":"https://api.github.com/repos/passcod/rsnotify/issues/comments/220816989","html_url":"https://github.com/passcod/rsnotify/issues/69#issuecomment-220816989","issue_url":"https://api.github.com/repos/passcod/rsnotify/issues/69","id":220816989,"user":{"login":"passcod","id":155787,"avatar_url":"https://avatars.githubusercontent.com/u/155787?v=3","gravatar_id":"","url":"https://api.github.com/users/passcod","html_url":"https://github.com/passcod","followers_url":"https://api.github.com/users/passcod/followers","following_url":"https://api.github.com/users/passcod/following{/other_user}","gists_url":"https://api.github.com/users/passcod/gists{/gist_id}","starred_url":"https://api.github.com/users/passcod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/passcod/subscriptions","organizations_url":"https://api.github.com/users/passcod/orgs","repos_url":"https://api.github.com/users/passcod/repos","events_url":"https://api.github.com/users/passcod/events{/privacy}","received_events_url":"https://api.github.com/users/passcod/received_events","type":"User","site_admin":false},"created_at":"2016-05-22T06:35:17Z","updated_at":"2016-05-22T06:35:17Z","body":"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."}}
{"actor":{"display_login":"passcod"}}