You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Idle CPU and memory usage in v0.44.0 — possible room for further optimization? #92
Hi, thanks again for the performance improvements in recent releases.
On v0.44.0 I’m seeing the cmdr background process sit at 2–3% CPU consistently, usually in the top few processes on my system (above Chrome/Edge/vscode). Memory usage is around ~594MB.
A couple of questions:
Is cmdr keeping the full index in memory, and is there room to reduce the footprint?
Is there room to further reduce idle CPU usage (e.g., target <1% when backgrounded)?
Out of curiosity, what work is the daemon doing while idle that requires 2–3% CPU?
Not reporting a bug — just trying to understand whether additional optimizations are feasible.
Head's up that I'm actively working on this one, with priority.
One of the most important things for me about Cmdr is that it should treat user resources (CPU, RAM, disk storage and disk I/O) with respect.
Re: your specific questions:
Is cmdr keeping the full index in memory, and is there room to reduce the footprint?
It is not keeping the full index in memory. And there is some room to reduce the footprint. I don't think it'll go under 200 MB of steady RAM use, but I'm aiming for the 200–300 MB range when there is no active indexing/search/transfer is going on. All of those things do need some extra RAM, but it's fine because you as the user want those thing in those moments. But for the baseline/steady state, I don't want anything about 300 MB.
Is there room to further reduce idle CPU usage (e.g., target <1% when backgrounded)?
Yes! Unfortunately, there is no single source of high baseline CPU usage, so nothing that I could just magically cut back or create a config item for or something. It's many small things that add up. But there are still a few low-hanging fruits. Two examples: 1. we poll mDNS too frequently to find new SMB shares and 2. there are some stray threads around indexing in some cases. These are almost clear wins to get rid of. Then there are a few product calls, one of which is reducing the indexing feature to only contain certain folders by default. I really loved the idea in the beginning to index the entire drive, but over the months, I've found this unnecessary, and I'd rather have the index use less disk, and less CPU to follow file system changes.
Overall, I absolutely agree with <1% as the healthy target.
Out of curiosity, what work is the daemon doing while idle that requires 2–3% CPU?
Technical correction: there is no daemon, it's all the main app. And for the answer itself, see point 2 above.
I hope this gives you some comfort for the time being that you at least know a bit of what's under the hood, and that we're on the same page on the targets, and that I'm working on improving this.
Hey again @jimtng! Here's another quick progress report!
I've worked on this a lot in the past two days. Here are my highlights for you:
CPU: The UI side is now ~4× cheaper at idle (~1.5% → ~0.4% of a core on my machine), and it stops updating while the window is hidden. The main process is still ~2.5% though. Still found no single hotspot there, just ~30 threads adding up, so I'll keep working on this.
RAM: I've found ~50 MB of junk that was a plain oversight to leave in memory. Cmdr now starts at around 200 MB, but it goes up to ~315 MB after 10–20 min idle, which is not nice, and after about 25 hours, I measured~700 MB, so something is clearly leaky. What I know so far is that at least half of that 700 MB is kept by the allocator, not real data.
Overall, the best improvement has been the UI one. It used to redraw both panes quite often, even when nothing on screen changed. Now it only redraws when something you see actually changes.
I'll release the these partial improvements soon (will definitely be better than the current version!) and will keep working on this with priority.
Then my best next ideas are:
Reuse threads in the indexer: The indexer starts a new thread for every folder it walks (spawned ~29k threads in 40 min on my laptop 😅). I think this is a big part of why the allocator holds so much memory, so I hope this is the key to that extra ~350 MB on long-running instances.
Memory doesn't go back down after searching. Search uses about 500 MB of RAM to load the index in memory for the selected disk. This is fine because when you search, you wanna search and you wanna search fast, so transient extra ~500 MB RAM use is aceptable. The problem is that the cache should go away 30 sec after closing the search dialog (deliberate cache purge to free up the RAM) but it doesn't.
Only look for SMB servers when the user wants it. Right now we browse all the time. This is a small but constant CPU cost.
Get aggregate CPU use data in diagnostics, so I can measure real installs anonymously (incl. yours, if you opt in to analytics) instead of optimizing for my own laptop.
I'm tracking the details in docs/notes/performance/README.md.
Will release this within the next days, and keep you posted.
Did a whole bunch more and v0.48.0 is a lot better! I've just checked it after a half day of running, CPU hovers around 0.6% with total use of 7 minutes, and memory is at ~350 MB. Could be less, but significantly better than it was. Still working on this one..
Here's a note, mostly to myself, with the detail behind v0.48.0, and where I am against the two targets.
Done
Search is ~4–6× faster for most queries (one-letter ones ~2×).
A search right after the indexer walked a folder now catches up with only the new stuff instead of reloading the whole index. ~1.4 s → ~0.1 s for such searches, and ~600 MB less RAM use (!) at the peak.
Looking for SMB servers (mDNS) only runs when something needs it, like the Servers view. An idle Cmdr runs no discovery threads at all now.
Free-space polling got way cheaper. With indexing off, the main process went from ~0.77% to ~0.14% of a core at idle. This was a big one that I didn't expect before looking into it.
The indexer finds a folder's subfolders ~6,000× faster (!) in huge folders (~60 ms → ~10 µs on a 92,000-file one). The cost was adding a new index that takes up about ~5 MB disk for the typical drive.
The indexer now reuses its threads instead of creating ~29k of them in 40 minutes (97–99% fewer). Actually, I hoped this was the memory hog, but it wasn't, memory didn't move. But I kept it because it's nicer this way.
Where we stand
Idle RAM: The 200-300 target met for standard situations. It's ~263–273 MB with indexing on, and ~195 MB with indexing off (on my dev Mac, which is a heavy case).
RAM after bursts of work: Not yet. After a round of searches and opening a few huge folders, it settles at ~400–500 MB and stays there. The real data goes back to ~100 MB within 30 s; the rest is the memory allocator holding on to free space. Working on this one now.
Idle CPU: ~0.2% with indexing off, ~0.8-1.2% with indexing on.
What's left for this issue
Make the allocator give memory back after bursts. This is the whole remaining RAM gap. Don't know yet how much we'll win.
Explain the rest of the memory on a long-running v0.48.0.
Search's background refresh still rebuilds everything every 30 s while you keep searching. Fixing it cuts the peak while searching (not sure yet how much it helps after).
UI-side CPU while indexing: ~0.7% now, could drop by up to ~0.5%.
The UI process grows over days (~140 → ~260 MB). Need to find out why first.
One SMB share at multiple addresses (for example LAN + VPN) becomes multiple indexes. Only matters with that setup.
A small system call on every indexer update that we can skip for the boot disk.
I moved everything else (nice-to-haves that don't move these numbers) to their own issues, so this one closes when the list above is done.
Made a few more, final improvements (switched to macOS's system memory allocator, ships in the next release). At this point, the targets I set are met or right on the line:
Idle RAM: ~250 MB with indexing on, ~200 MB with it off.
RAM after bursts of work: settles back to ~250 MB after 30 sec or so. (This will ship in v0.49.0)
Idle CPU: ~0.14% with indexing off, ~0.8–1.2% with indexing.
There's still stuff I could shave off, and I've written it down for later. But I don't know of anything meaningfully wasteful anymore, and it all went into yak shaving now. If Cmdr ever eats more than it should on your machine, please reopen this or file a new one, it really helps! Thanks again for the nudge, this made Cmdr much better. :)
Great work on the optimization! The memory usage spiked up during search (perfectly reasonable) and went right back down again a few moments after. The CPU usage is also quite low.
Activity
vdavid commentedon Sep 21, 2026
Head's up that I'm actively working on this one, with priority.
One of the most important things for me about Cmdr is that it should treat user resources (CPU, RAM, disk storage and disk I/O) with respect.
Re: your specific questions:
Is cmdr keeping the full index in memory, and is there room to reduce the footprint?
Is there room to further reduce idle CPU usage (e.g., target <1% when backgrounded)?
Out of curiosity, what work is the daemon doing while idle that requires 2–3% CPU?
I hope this gives you some comfort for the time being that you at least know a bit of what's under the hood, and that we're on the same page on the targets, and that I'm working on improving this.
perf(index): the index's folder-size updates reach only the listings …
feat(memory): `memory_diagnostics` splits the Rust heap into live dat…
perf(media-index): the importance score cache drops from ~31 MiB to ~…
perf(listing): a pane stops refetching its rows when a change touched…
vdavid commentedon Sep 23, 2026
Hey again @jimtng! Here's another quick progress report!
I've worked on this a lot in the past two days. Here are my highlights for you:
Overall, the best improvement has been the UI one. It used to redraw both panes quite often, even when nothing on screen changed. Now it only redraws when something you see actually changes.
I'll release the these partial improvements soon (will definitely be better than the current version!) and will keep working on this with priority.
Then my best next ideas are:
I'm tracking the details in docs/notes/performance/README.md.
Will release this within the next days, and keep you posted.
jimtng commentedon Sep 23, 2026
Thanks for working on this! I wish I knew rust! This project is giving me motivation to learn it
perf(network): mDNS browses only while something needs it, so an idle…
perf(index): the writer finds a folder's child dirs off a partial ind…
docs(perf): the performance hub shows current main's numbers and a re…
vdavid commentedon Sep 29, 2026
Did a whole bunch more and v0.48.0 is a lot better! I've just checked it after a half day of running, CPU hovers around 0.6% with total use of 7 minutes, and memory is at ~350 MB. Could be less, but significantly better than it was. Still working on this one..
jimtng commentedon Sep 29, 2026
Thank you!
docs(perf): #92's follow-up list now holds only items that can move i…
vdavid commentedon Sep 29, 2026
Here's a note, mostly to myself, with the detail behind v0.48.0, and where I am against the two targets.
Done
Where we stand
What's left for this issue
I moved everything else (nice-to-haves that don't move these numbers) to their own issues, so this one closes when the list above is done.
docs(perf): macOS runs on the system allocator; say where the Rust he…
docs(perf): idle CPU with indexing on straddles the 1% target in prod…
docs(perf): SMB alias dedupe moves out of #92 into #335, with the Ser…
docs(perf): #92 is closed with the targets met or at the line; the ne…
vdavid commentedon Sep 30, 2026
Made a few more, final improvements (switched to macOS's system memory allocator, ships in the next release). At this point, the targets I set are met or right on the line:
There's still stuff I could shave off, and I've written it down for later. But I don't know of anything meaningfully wasteful anymore, and it all went into yak shaving now. If Cmdr ever eats more than it should on your machine, please reopen this or file a new one, it really helps! Thanks again for the nudge, this made Cmdr much better. :)
jimtng commentedon Oct 2, 2026
Great work on the optimization! The memory usage spiked up during search (perfectly reasonable) and went right back down again a few moments after. The CPU usage is also quite low.