CPU iowait due to HDD overload is lagging the video recording saved on fast SSD

This is something new to me.
Video being recorded and saved to a fast SSD, normally it affects my CPU like +10% maybe and the CPU utilization is around 20%, but when there was a high CPU iowait (likely due to a overload of the external USB data HDD), the recorded video seemed like skipping frames and freezing. During the record, i have seen the htop utility is visualizing the iowait on the CPU threads and the iowait was majority of the threads capacity.

I doubt this was caused by bottleneck on the SSD NVMe, even i have seen quite high activity 30MB read and 30MB write due to possibly swapping (most of the RAM is shown to be utilized by cache, which is OK, then it was overflowing to swap. It is quite strange to me that the cache ate majority of the RAM capacity and then was swapping to a disk, instead of freeing some cache. my swappiness is 60 and i am having zswap, $ systemd-swap:

. accept_threshold_percent 90
. compressor zstd
. enabled Y
. max_pool_percent 40
. same_filled_pages_enabled Y
. zpool z3fold
Zswap:
. . duplicate_entry 0
. . pool_limit_hit 0
. . pool_total_size 1210466304
. . reject_alloc_fail 0
. . reject_compress_poor 0
. . reject_kmemcache_fail 0
. . reject_reclaim_fail 0
. . same_filled_pages 53129
. . stored_pages 749471
. . written_back_pages 0
. . compress_ratio 39%
. . zswap_store/swap_store 3069833216/3523239936 87%

This is Arch Linux.

When i have paused some HDD tasks, the iowait portion of the CPU threads load dropped significantly and the recorded video had no issues.

QUESTION: Is there anything i can do to prevent the video being influenced by the external drive overload?
I know i can run an app using nice and ionice. Which one do you think may help, if any?
Or is there any other way to prevent it, beside buying additional drives or getting SSDs for the data? Thank you

Are you using an external USB HDD for video storage? Like reading data for rendering from an external USB disk? If so, it will always be slow due to bus speed and other issues.

No, i am using system SSD for saving that recorded video.

Video being recorded and saved to a fast SSD

I see, can you run htop and post output. That will give good idea. What kind of fs do you have? ZFS? EXT4?

Can’t tell you since you don’t say how that drive factors into things. What’s it doing and why? And have you tried using ionice to temper things, or done anything to see what effect it has?

I have not tried. What should i have been looking at in htop output?
I have replaced the HDD by SSD, so iowait does not longer seem to be the issue, so the video is not lagged. I was curious if nice or ionice should have been used or what exactly to check in tools like htop output.

@nixcraft can You please delete this topic, it does not help anyone and i no longer will be able to help debug this

For others who have posted, do not be mistaken, i thank for what you have posted.