What's new

USB and swap file - performance consideration?

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Simon W

Regular Contributor
Should one be particularly concerned re. the performance of a USB stick used both in various amtm-launched installs and as a swap file?

I've just used an old one I found laying around for testing, should I consider replacing or is it much of a muchness?

Since the RT-AX88U runs at just over 45% RAM free anyway, I wouldn't want possibly reduce performance with a swap file on a sub-par drive, especially as under normal operation (eg. without bonus scripts etc) no swap file would be necessary.
 
I've used 5 or 6-year-old USB drives and a 500GB USB SSD, the only noticeable difference is when installing/updating scripts.

When the router is just using the drive, all are effectively the same, even if the faster drives/SSD 'win' in a direct comparison.

I use Ext4 w/journalling and a 2GB swap file all done via amtm. :)
 
Under normal (no scripts) operation there shouldn't be any need for a swap file (otherwise the router wouldn't work for a typical customer).

Ideally you don't want swap to be used at all. It should only be necessary in exceptional situations, like downloading and sorting a large ad-blocking list. You can keep an eye on the swap file usage in the GUI or by using the free command.
 
With 8K to 20K IP's being blocked in a 24 hour period, Skynet is a must and the new 'normal'. Skynet requires a minimum of a 1GB swap file. I see no reason to lower the 2GB I use. :)

An additional point. I suggest using USB 2.0 even in a USB 3.0 port to ensure the 2.4GHz radio isn't adversely affected, as a 'default' recommendation. However, I test actual hardware (router, clients and USB drive) in use and switch to USB 3.0 mode if there are no issues with a specific setup. For example, with an RT-AX88U and a Patriot Elite 256GB USB drive, USB 3.0 mode in the USB 3.0 port causes no issues for me and gives me a more responsive amtm experience. :)
 
With 8K to 20K IP's being blocked in a 24 hour period, Skynet is a must and the new 'normal'. Skynet requires a minimum of a 1GB swap file. I see no reason to lower the 2GB I use. :)

An additional point. I suggest using USB 2.0 even in a USB 3.0 port to ensure the 2.4GHz radio isn't adversely affected, as a 'default' recommendation. However, I test actual hardware (router, clients and USB drive) in use and switch to USB 3.0 mode if there are no issues with a specific setup. For example, with an RT-AX88U and a Patriot Elite 256GB USB drive, USB 3.0 mode in the USB 3.0 port causes no issues for me and gives me a more responsive amtm experience. :)
The firewall would have dropped most if not all of that traffic anyway...
 
I was curious myself as I use a USB 2.0 key what impact was it having on performance with all the logging/swap/etc.

Seems not an issue. Just doing:

Code:
cat /sys/block/sda/stat                                                                                                                     
    4409      398   969938   215865   146164    98340  5940042 36435363        0  7982604 36651195
I can see from the 9 item that my in_flight number is 0. And I checked it a few times, and it was always 0. Meaning to me at least that my disk is able to keep up for normal operation.

#9 = in_flight requests number of I/Os currently in flight


https://www.kernel.org/doc/Documentation/block/stat.txt
 
I replaced my previous unfamiliar-branded USB flash drives with the latest Samsung flash drives and the speed increase when managing the scripts and creating the swap file is amazing (e.g., 20 minutes to create the 2GB swap can be done now in about a minute). However, the reason I changed mine was because I was getting high CPU usage (frequently shooting up to 100%) and someone on this forum suggested that replacing my flash drive for something faster might help to solve the problem. All I can say is that since using the Samsung flash drives, I haven't had any CPU problems. Is that just a coincidence? - I have no idea.
 
I replaced my previous unfamiliar-branded USB flash drives with the latest Samsung flash drives and the speed increase when managing the scripts and creating the swap file is amazing (e.g., 20 minutes to create the 2GB swap can be done now in about a minute). However, the reason I changed mine was because I was getting high CPU usage (frequently shooting up to 100%) and someone on this forum suggested that replacing my flash drive for something faster might help to solve the problem. All I can say is that since using the Samsung flash drives, I haven't had any CPU problems. Is that just a coincidence? - I have no idea.

USB 3.0? Or 2.0?


Sent from my iPhone using Tapatalk
 
USB 3.0? Or 2.0?


Sent from my iPhone using Tapatalk
The previous flash drives were USB 2.0. The Samsung flash drives are USB 3.1.
 
@TheLyppardMan, I would guess 'no', not a coincidence. :)

They need to be of a certain speed/quality, but once there, compared to even the fastest SSD any increased 'performance' is lost when used in any current router available for consumers.

What we would need is for the router (CPU explicitly) to be able to use an SSD connection (SATAIII would be a huge upgrade, and PCIe x4 would be overkill) and an appropriate/replaceable SSD too. But not even commercially available routers have that capability yet, afaik. :)

What the latest USB drives offer is not only faster speeds for the biggest files but rather, faster and more consistent speeds for the tiniest files. This is what makes them perform so much faster in their 'router roles'. ;)
 
Should one be particularly concerned re. the performance of a USB stick used both in various amtm-launched installs and as a swap file?

I've just used an old one I found laying around for testing, should I consider replacing or is it much of a muchness?

Since the RT-AX88U runs at just over 45% RAM free anyway, I wouldn't want possibly reduce performance with a swap file on a sub-par drive, especially as under normal operation (eg. without bonus scripts etc) no swap file would be necessary.

If one is going to use a swap drive (and I fail to see why)

With Flash (USB, SD Card, etc) - every write is actually two writes - one to erase a block of addresses, and another to write the data back to that block of addresses. You only get so many writes to flash before a block dies...

USB Sticks are the bottom market for flash in general... and they're not intended for this purpose....
 
@sfx2000, the new ones are intended to be used like that. :)

Particularly the higher capacity models which is effectively an SSD and not just 'dumb' nand. ;)
 
If one is going to use a swap drive (and I fail to see why)

I'm inclined to agree with you - I'm sure the router has in most cases more than enough RAM to carry out it's tasks - assuming you are not pushing this envelope with add-ons.

Some questions:
  1. With a swap file enabled, presumably it will only be used once the RAM is full / to offload low priority cache to - ie. that it won't have a negative impact on performance until such a point of the real RAM becoming depleted?
  2. What's the fail state - ie. if a USB stick dies, is it a simple case of reboot and away you go sans a swap file (and admittedly likely a few errors from other scripts referencing elsewhere on the now dead USB stick)?
 
Routers do not have enough ram, that is why a swap file is needed. :)

Even if only required once every 24 hrs when an update is performed on some (big) lists, for example.

Even with my RT-AX88U with 1GB ram and a few scripts running, swap file usage could hit almost 500MB and 'free ram' be as low as 12MB.

When routers are sold or able to be upgraded to 4GB RAM or more, a swap file may superfluous then. Right now, it can only help. And they are definitely needed.
 
Routers do not have enough ram, that is why a swap file is needed. :).
Asus routers do have enough RAM if you use them as they were designed. Stop running third party scripts and see how much swap you're using (i.e. none). If you deliberately choose to modify your router with unofficial software that requires more resources than the router has then that's a problem of your own making.

Even if only required once every 24 hrs when an update is performed on some (big) lists, for example.

Even with my RT-AX88U with 1GB ram and a few scripts running, swap file usage could hit almost 500MB and 'free ram' be as low as 12MB
QED
 
Asus routers do have enough RAM if you use them as they were designed. Stop running third party scripts and see how much swap you're using (i.e. none). If you deliberately choose to modify your router with unofficial software that requires more resources than the router has then that's a problem of your own making.
Horses for courses :) though I have to say I agree - keep things simple / as designed and you know where you stand. Which is what brought me to Merlin = fixes and tweaks as opposed to wholesale additions.

My interest in this area has been simply for the lightweight add-ons Connmon and spdMerlin - both handy in some troubleshooting I've been doing recently (over a period of days and weeks) and I can see their long term benefit. I also like the amtm wrapper that is now installed with the firmware by default.. however in using it to install Connmon and spdMerlin has required Entware and a swap file. Personally, I plan to stop here :)
 
@ColinTaylor agreed. But what fun would that be if we only ran the scripts that OEM's offer (i.e. none)? :)

That's (almost) like saying we only need 4GB of ram on a PC when a browser can use 10GB or more on its own. Are we only supposed to browse with a single tab? And/or only do things one at a time? At least on most PC's, we have the option to increase the ram capacity. :)

Sorry, I'm not sure what is signified by 'QED'?
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top