# Very hich cpu utilization since 24 june, although BW 3 times less

**URL:** <https://forum.storj.io/t/very-hich-cpu-utilization-since-24-june-although-bw-3-times-less/26816>\
**Category:** troubleshooting\
**Tags:** freebsd, hardware\
**Created:** [June 25, 2024, 1:08pm UTC](https://forum.storj.io/t/very-hich-cpu-utilization-since-24-june-although-bw-3-times-less/26816 "2024-06-25T13:08:04Z")\
**Posts on this page:** 17\
**Page:** 3

<div class="post-metadata">

**Author:** ![Alexey](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/alexey/32/41_2.png) [@Alexey](https://forum.storj.io/u/Alexey)\
**Post date:** [June 30, 2024, 8:21am UTC](https://forum.storj.io/t/very-hich-cpu-utilization-since-24-june-although-bw-3-times-less/26816/41 "2024-06-30T08:21:26Z")

</div>

> [@brainstorm](#):
>
> Of course, it might be an issue with the libraries used by storagenode

It’s written on GO, so no dynamic linking. It’s always statically linked build time.

> [@arrogantrabbit](#):
>
> The orders database

It’s on the filesystem too for a long time.

---

<div class="post-metadata">

**Author:** ![brainstorm](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/brainstorm/32/7827_2.png) [@brainstorm](https://forum.storj.io/u/brainstorm)\
**Post date:** [June 30, 2024, 8:24am UTC](https://forum.storj.io/t/very-hich-cpu-utilization-since-24-june-although-bw-3-times-less/26816/42 "2024-06-30T08:24:35Z")

</div>

> [@Alexey](#):
>
> It’s written on GO, so no dynamic linking. It’s always statically linked build time.

Hmm what is your point ? I said nothing about dynamic linking.  
There could be a bug in in libraries used by storagenode, wether static or dynamic link is irrelevant. I am just saying it could be in code not part of the storagenode codebase.

---

<div class="post-metadata">

**Author:** ![Alexey](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/alexey/32/41_2.png) [@Alexey](https://forum.storj.io/u/Alexey)\
**Post date:** [June 30, 2024, 8:28am UTC](https://forum.storj.io/t/very-hich-cpu-utilization-since-24-june-although-bw-3-times-less/26816/43 "2024-06-30T08:28:03Z")

</div>

Perhaps. But since only your setup has this issue, I’m not convinced yet that there is a bug.  
Did you try this command?

> [@arrogantrabbit](#):
>
> You can emulate what file walker is doing approximately with `time find . -type f -print0 | xargs -0 -P 24 -n 100 stat -f "%z"`.

Did it produce the same behavior with a high CPU usage?

---

<div class="post-metadata">

**Author:** ![brainstorm](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/brainstorm/32/7827_2.png) [@brainstorm](https://forum.storj.io/u/brainstorm)\
**Post date:** [June 30, 2024, 8:38am UTC](https://forum.storj.io/t/very-hich-cpu-utilization-since-24-june-although-bw-3-times-less/26816/44 "2024-06-30T08:38:14Z")

</div>

yes, originally I identified the security scripts that walk through the whole filesystems, as causing the high CPU usage. This basically does the same.  
And the filewalker does the same as well.

I don’t know where the bug is, but to me it’s clearly a bug. Storagenode should not be so sensitive to other processes accessing files, specially by increasing CPU use. It makes no sense at all. I won’t rehash my points from my posts above but I really do not see how a simple filesystem traversal from a different process causing storagenode to spike CPU is defensible 🤷‍♂️

---

<div class="post-metadata">

**Author:** ![Alexey](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/alexey/32/41_2.png) [@Alexey](https://forum.storj.io/u/Alexey)\
**Post date:** [June 30, 2024, 8:43am UTC](https://forum.storj.io/t/very-hich-cpu-utilization-since-24-june-although-bw-3-times-less/26816/45 "2024-06-30T08:43:46Z")

</div>

How is it related to storagenode, if the same thing on the OS level produces the same behavior?  
We would not patch your OS to perform better, sorry.  
However, you likely can limit a CPU available to the jail (I’m not sure about this, I do not have a FreeBSD setup to check).

I also wonder, why your setup behave differently from @arrogantrabbit setup though.

---

<div class="post-metadata">

**Author:** ![brainstorm](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/brainstorm/32/7827_2.png) [@brainstorm](https://forum.storj.io/u/brainstorm)\
**Post date:** [June 30, 2024, 8:50am UTC](https://forum.storj.io/t/very-hich-cpu-utilization-since-24-june-although-bw-3-times-less/26816/46 "2024-06-30T08:50:01Z")

</div>

You misunderstood me.

Running a file traversal of the whole filesystem does _not_ affect anything else, even other process which BTW have similar purposes and behaviors as storagenode. Processes which are heavy bandwidth, heavy IO, disk and network.

If I run those filetraversal jobs or the one liner above when not running storagenode, nothing is affected adversely. It is only storagenode, when run at the same time, that suddenly spikes cpu 1000%. And, it is the storagenode process that takes that CPU, not any other process.

Storagenode uniquely completely bogs down CPU when some other unrelated process does a whole filesystem traversal. And the pattern so far observed, is that of busy waiting somewhere on system calls. Only storagenode is affected, not other processes.

That is clearly an issue with storagenode, not the OS.

But I am open to explanations on how that is actually an OS issue, or how it’s actually perfectly ok for a program to act like storagenode does. So far I see none.

> [@Alexey](#):
>
> I also wonder, why your setup behave differently from @arrogantrabbit setup though.

It does not. He actually sees the same behavior. He mentioned that in his setup he sees very high cpu use for 10 minutes at node startup. The reason it only lasts 10 minutes is because he has an SSD cache of metadata. So that cache already holds the metadata accessed and the whole initial scan last a shorter time. For me, without ssd cache, all those accesses go through the disk first, which have much lower IOps. So it lasts forever. He also mentioned how some have heavy IO for days. I bet cpu use also is high during that time.

---

<div class="post-metadata">

**Author:** ![Alexey](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/alexey/32/41_2.png) [@Alexey](https://forum.storj.io/u/Alexey)\
**Post date:** [June 30, 2024, 8:59am UTC](https://forum.storj.io/t/very-hich-cpu-utilization-since-24-june-although-bw-3-times-less/26816/47 "2024-06-30T08:59:52Z")

</div>

> [@brainstorm](#):
>
> Storagenode uniquely completely bogs down CPU when some other unrelated process does a whole filesystem traversal.

Oh, this one sounds like a bug. But honestly do not understand why is it happening under FreeBSD? I did the same many times on Windows/Linux and no one time I noticed such a weird behavior.

And also, why is it not happening on @arrogantrabbit’s setup?

---

<div class="post-metadata">

**Author:** ![brainstorm](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/brainstorm/32/7827_2.png) [@brainstorm](https://forum.storj.io/u/brainstorm)\
**Post date:** [June 30, 2024, 9:04am UTC](https://forum.storj.io/t/very-hich-cpu-utilization-since-24-june-although-bw-3-times-less/26816/48 "2024-06-30T09:04:05Z")

</div>

I don’t know, that is why I mentioned it might not be a bug in storagenode itself but in some libraries it uses. I can perfectly imagine that some base go code must be ported differently to different platforms, and some of that code ends up doing some busy waiting or whatever. Maybe the conditions are just right to reveal in storagenode use pattern. who knows.  
No idea, just speculation at this point.

---

<div class="post-metadata">

**Author:** ![brainstorm](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/brainstorm/32/7827_2.png) [@brainstorm](https://forum.storj.io/u/brainstorm)\
**Post date:** [June 30, 2024, 9:04am UTC](https://forum.storj.io/t/very-hich-cpu-utilization-since-24-june-although-bw-3-times-less/26816/49 "2024-06-30T09:04:52Z")

</div>

> [@Alexey](#):
>
> And also, why is it not happening on @arrogantrabbit’s setup?

> [@brainstorm](#):
>
> He actually sees the same behavior. He mentioned that in his setup he sees very high cpu use for 10 minutes at node startup. The reason it only lasts 10 minutes is because he has an SSD cache of metadata. So that cache already holds the metadata accessed and the whole initial scan last a shorter time. For me, without ssd cache, all those accesses go through the disk first, which have much lower IOps. So it lasts forever. He also mentioned how some have heavy IO for days. I bet cpu use also is high during that time.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

---

<div class="post-metadata">

**Author:** ![Alexey](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/alexey/32/41_2.png) [@Alexey](https://forum.storj.io/u/Alexey)\
**Post date:** [June 30, 2024, 9:07am UTC](https://forum.storj.io/t/very-hich-cpu-utilization-since-24-june-although-bw-3-times-less/26816/50 "2024-06-30T09:07:20Z")

</div>

We use this build process for FreeBSD:

> <https://github.com/storj/storj/blob/fb9a0a2b296032d2710abbecf51ee0b3a078c43c/Makefile#L434>

---

<div class="post-metadata">

**Author:** ![brainstorm](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/brainstorm/32/7827_2.png) [@brainstorm](https://forum.storj.io/u/brainstorm)\
**Post date:** [June 30, 2024, 9:36am UTC](https://forum.storj.io/t/very-hich-cpu-utilization-since-24-june-although-bw-3-times-less/26816/51 "2024-06-30T09:36:18Z")

</div>

BTW, I restarted yesterday storagenode with these settings

```auto
storage2.piece-scan-on-startup: true
pieces.enable-lazy-filewalker: false

```

My idea was to force it to do the filewalker process at startup and do it as fast as possible, not throttling IO and see if after that CPU use would just fall of a cliff.

It seems to have just finished the filewalking. CPU use for storagenode just went back to normal very light load.

I’ll make more experiments to confirm but so far I think my theory is right. Reason why ? no idea. I am going to setup another node to keep investigating this.

---

<div class="post-metadata">

**Author:** ![brainstorm](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/brainstorm/32/7827_2.png) [@brainstorm](https://forum.storj.io/u/brainstorm)\
**Post date:** [June 30, 2024, 9:45am UTC](https://forum.storj.io/t/very-hich-cpu-utilization-since-24-june-although-bw-3-times-less/26816/52 "2024-06-30T09:45:03Z")

</div>

Why I think this is quite important also from an economic point of view is that as soon as the cpu load went back to normal:

- my power use went down 30%
- download rate went up 100%
- storj pieces download went from 85% to 99%
- storj pieces upload went from 76% to 99%

---

<div class="post-metadata">

**Author:** ![ad329](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/ad329/32/1129_2.png) [@ad329](https://forum.storj.io/u/ad329)\
**Post date:** [July 17, 2024, 7:57am UTC](https://forum.storj.io/t/very-hich-cpu-utilization-since-24-june-although-bw-3-times-less/26816/53 "2024-07-17T07:57:13Z")

</div>

Don’t have much to contribute but just wanted to mention that I’m seeing the same issue with docker + zfs. Seems like high CPU usage (though my disks are absolutely iops constrained, I’m running 2 nodes on a raidz1 so the write iops are struggling).

---

<div class="post-metadata">

**Author:** ![ad329](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/ad329/32/1129_2.png) [@ad329](https://forum.storj.io/u/ad329)\
**Post date:** [July 17, 2024, 9:10am UTC](https://forum.storj.io/t/very-hich-cpu-utilization-since-24-june-although-bw-3-times-less/26816/54 "2024-07-17T09:10:29Z")

</div>

Out of curiosity, @brainstorm are you also iops constrained? Wondering if it has to do with that. It shouldn’t consume cpu cycles though, the scheduler should offload iowaiting so not totally sure. Might be worth profiling.

---

<div class="post-metadata">

**Author:** ![Alexey](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/alexey/32/41_2.png) [@Alexey](https://forum.storj.io/u/Alexey)\
**Post date:** [July 20, 2024, 11:52am UTC](https://forum.storj.io/t/very-hich-cpu-utilization-since-24-june-although-bw-3-times-less/26816/55 "2024-07-20T11:52:19Z")

</div>

I believe, that it’s related to a 1.105.x release:

> [@High cpu load caused by storj containers](https://forum.storj.io/t/high-cpu-load-caused-by-storj-containers/27128/15):
>
> This happens because one of the threads of GC actually hangs (enters an infinite non-productive loop). And since it’s only one thread, it can only take up one core max. But do it at 100% load non-stop. In my case, it did not even respond to requests to restart the node - all other threads shut down correctly, but there was one that did not respond to commands. /mon/ps has shown that this thread is related to the garbage collector. So I even had to kill the node process to restart - because I…

---

<div class="post-metadata">

**Author:** ![brainstorm](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/brainstorm/32/7827_2.png) [@brainstorm](https://forum.storj.io/u/brainstorm)\
**Post date:** [July 27, 2024, 12:43pm UTC](https://forum.storj.io/t/very-hich-cpu-utilization-since-24-june-although-bw-3-times-less/26816/56 "2024-07-27T12:43:19Z")

</div>

> [@Alexey](#):
>
> I believe, that it’s related to a 1.105.x release:

possible, I am currently on v1.108.3 and not seeing this issue anymore.

---

<div class="post-metadata">

**Author:** ![brainstorm](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/brainstorm/32/7827_2.png) [@brainstorm](https://forum.storj.io/u/brainstorm)\
**Post date:** [July 27, 2024, 12:45pm UTC](https://forum.storj.io/t/very-hich-cpu-utilization-since-24-june-although-bw-3-times-less/26816/57 "2024-07-27T12:45:58Z")

</div>

I do not have an SSD for the log cache etc. but those are fast SAS drives. 300-500iops  
I do not care if that part is slow, it should just not spike CPU while effectively doing nothing.

> [@ad329](#):
>
> Out of curiosity, @brainstorm are you also iops constrained? Wondering if it has to do with that. It shouldn’t consume cpu cycles though, the scheduler should offload iowaiting so not totally sure. Might be worth profiling.

[Previous page](https://forum.storj.io/t/very-hich-cpu-utilization-since-24-june-although-bw-3-times-less/26816.md?page=2)
