# CPU Usage on large folder

**URL:** https://forum.syncthing.net/t/cpu-usage-on-large-folder/6744
**Category:** Support
**Created:** [February 9, 2016, 3:18pm UTC](https://forum.syncthing.net/t/cpu-usage-on-large-folder/6744 "2016-02-09T15:18:56Z")
**Posts on this page:** 11
**Page:** 2

<div class="post-metadata">

### Author: ![canton7](https://forum.syncthing.net/user_avatar/forum.syncthing.net/canton7/32/9528_2.png) [@canton7](https://forum.syncthing.net/u/canton7)
#### Post date: [February 11, 2016, 4:45pm UTC](https://forum.syncthing.net/t/cpu-usage-on-large-folder/6744/21 "2016-02-11T16:45:38Z")

</div>

It is the way it is, and will most likely remain the way it is, because that provides the most benefit to the most people.

---

<div class="post-metadata">

### Author: ![singpolyma](https://forum.syncthing.net/user_avatar/forum.syncthing.net/singpolyma/32/2420_2.png) [@singpolyma](https://forum.syncthing.net/u/singpolyma)
#### Post date: [February 11, 2016, 4:58pm UTC](https://forum.syncthing.net/t/cpu-usage-on-large-folder/6744/22 "2016-02-11T16:58:45Z")

</div>

I think what I’m mostly wondering is if this is currently a limitation in syncthing (such that the inotify daemon cannot tell it what it knows) or just an implementation choice in the inotify daemon

---

<div class="post-metadata">

### Author: ![AudriusButkevicius](https://forum.syncthing.net/user_avatar/forum.syncthing.net/audriusbutkevicius/32/277_2.png) [@AudriusButkevicius](https://forum.syncthing.net/u/AudriusButkevicius)
#### Post date: [February 11, 2016, 7:03pm UTC](https://forum.syncthing.net/t/cpu-usage-on-large-folder/6744/23 "2016-02-11T19:03:19Z")

</div>

A scan is only expensive if a lot of stuff has changed. Otherwise its essentially a stat call which is not expensive on most filesystems.

If you are using some fancy filesystem (btrfs for example), stat may cause high CPU usage in the kernel, not in syncthing process.

---

<div class="post-metadata">

### Author: ![singpolyma](https://forum.syncthing.net/user_avatar/forum.syncthing.net/singpolyma/32/2420_2.png) [@singpolyma](https://forum.syncthing.net/u/singpolyma)
#### Post date: [February 12, 2016, 2:53pm UTC](https://forum.syncthing.net/t/cpu-usage-on-large-folder/6744/24 "2016-02-12T14:53:15Z")

</div>

Just using ext4 here, and very little changes in the directory (mostly just renaming \< 10 files)

---

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [February 12, 2016, 7:39pm UTC](https://forum.syncthing.net/t/cpu-usage-on-large-folder/6744/25 "2016-02-12T19:39:32Z")

</div>

A maildir contains essentially all files in a single directory level, and potentially a lot of files. This is rather niche and counter to what directories were invented for in the first place. Syncthing-inotify isn’t really optimized for this use case - potentially if there was a tweakable for “number of files that need to change before we fall back to just scanning parent directory” you’d want to set that way up. As it is, unless you really need the realtime replication, I’d just set the scan interval to an hour and be done with it. I run with daily scans on my big folders…

---

<div class="post-metadata">

### Author: ![singpolyma](https://forum.syncthing.net/user_avatar/forum.syncthing.net/singpolyma/32/2420_2.png) [@singpolyma](https://forum.syncthing.net/u/singpolyma)
#### Post date: [February 12, 2016, 8:52pm UTC](https://forum.syncthing.net/t/cpu-usage-on-large-folder/6744/26 "2016-02-12T20:52:17Z")

</div>

Yeah, long time between scans is what I’m using on my laptop. Server can handle the load, and long scan time isn’t (in theory) an issue on the laptop. Just trying to understand the nature of the issues, etc, as I experiment with this.

---

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [February 12, 2016, 9:04pm UTC](https://forum.syncthing.net/t/cpu-usage-on-large-folder/6744/27 "2016-02-12T21:04:47Z")

</div>

A profile could tell, but at a guess looking at the lots and lots of files in that directory causes lots and lots of stat() calls that are not cached (because too many to cache for long) and lots and lots of database lookups. The latter are sort of expensive when we’re talking hundreds of thousands of them.

---

<div class="post-metadata">

### Author: ![singpolyma](https://forum.syncthing.net/user_avatar/forum.syncthing.net/singpolyma/32/2420_2.png) [@singpolyma](https://forum.syncthing.net/u/singpolyma)
#### Post date: [February 12, 2016, 9:16pm UTC](https://forum.syncthing.net/t/cpu-usage-on-large-folder/6744/28 "2016-02-12T21:16:28Z")

</div>

Ooh. So it does a stat on each file and compares to the last stat that is in the DB? That makes sense for why the scan is expensive.

---

<div class="post-metadata">

### Author: ![SmileyJames](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/s/58f4c7/32.png) [@SmileyJames](https://forum.syncthing.net/u/SmileyJames)
#### Post date: [February 15, 2016, 9:07pm UTC](https://forum.syncthing.net/t/cpu-usage-on-large-folder/6744/29 "2016-02-15T21:07:54Z")

</div>

I am encountering a similar issue to the one mentioned. I would like to ask if you are aware of this: [https://facebook.github.io/watchman/](https://facebook.github.io/watchman/) I am not sure if this is useful?

---

<div class="post-metadata">

### Author: ![Nutomic](https://forum.syncthing.net/user_avatar/forum.syncthing.net/nutomic/32/270_2.png) [@Nutomic](https://forum.syncthing.net/u/Nutomic)
#### Post date: [February 15, 2016, 9:51pm UTC](https://forum.syncthing.net/t/cpu-usage-on-large-folder/6744/30 "2016-02-15T21:51:07Z")

</div>

As I understand, the problem isn’t about the scan process, but about figuring out whether the scanned files are in the database. The project you linked doesn’t help with that.

---

<div class="post-metadata">

### Author: ![system](https://forum-uploads.syncthingcdn.net/original/2X/0/0b50e0a202b22ae6a67190759e8c868805b8ed9f.png) [@system](https://forum.syncthing.net/u/system)
#### Post date: [March 16, 2016, 9:52pm UTC](https://forum.syncthing.net/t/cpu-usage-on-large-folder/6744/31 "2016-03-16T21:52:55Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

[Previous page](https://forum.syncthing.net/t/cpu-usage-on-large-folder/6744.md?page=1)
