Lazy write to disk

Report bugs or suggestions around FancyCache
Post Reply
FrozenLord
Level 3
Level 3
Posts: 11
Joined: Mon Apr 04, 2011 1:37 pm

Lazy write to disk

Post by FrozenLord »

Hi,

I'm not totally sure whether this feature is the "average write amount" - mainly because I can't find any detailed explanation of "average write amount".
What I'd really love to have is the following feature:
FC starts writing to disc, once the timeout of the defer write occurred.
However, if some different application tries to access the disk, FC throttles down a bit, to not block that application.
In summary: FC only uses idle resources for writing to the disc to not block normal operation.

The reason for this is the following:
I've got a pretty slow SSD which has no advanced controller.
Each time FC writes the deferred writes to disc, my PC is unresponsive for some minutes :(
Therefore, it would be great if FC would only use idle disc resources when writing deferred writes (even though the writing itself would take longer).

Thank you for your consideration :)
User avatar
Support
Support Team
Support Team
Posts: 3628
Joined: Sun Dec 21, 2008 2:42 am

Re: Lazy write to disk

Post by Support »

Regarding the "average write amount", please see
viewtopic.php?f=25&t=778

For the unresponsive issue while defer-writing you mentioned, actually we had tried to resove it. This is one of the reasons we provide "average write amount" option. When this option is enabled, FancyCache has its internal algorithm to balance the disk burden and try to keep it responive as possible. But some users don't like this way because generall the disk/SSD is fast enough, so we doesn't enable balance algorithm by default.
FrozenLord
Level 3
Level 3
Posts: 11
Joined: Mon Apr 04, 2011 1:37 pm

Re: Lazy write to disk

Post by FrozenLord »

The problem is that I'm already using the "average write amount" on my disk.
Still, the PC becomes unresponsive :( (EDIT: although I should mention that it is not as bad as before, but it still is unresponsive)
Could you please try to implement a different solution (for example taking into account idle resources?)
User avatar
Support
Support Team
Support Team
Posts: 3628
Joined: Sun Dec 21, 2008 2:42 am

Re: Lazy write to disk

Post by Support »

what latency do you set? How if try a longer latency?
BikeHelmet
Level 4
Level 4
Posts: 20
Joined: Thu Apr 14, 2011 10:33 am

Re: Lazy write to disk

Post by BikeHelmet »

Some older SSDs choke if you hit them with more than one request. Perfect example - the old JMF602 and JMF602 B controllers (with 2KiB and 4KiB of cache) would often lock up if they had to process more than one request. 1 request = 1ms, 2 requests = 700-3000ms. 3 requests = oh my god kill me now.

No algorithm is going to be designed that can detect that - and if it is, it probably takes away from FancyCache in other ways. IMO this is another reason to implement an advanced mode, where things like this can be tweaked:

viewtopic.php?f=26&t=759#p2145
viewtopic.php?f=26&t=780#p2144

So things on the list: Average Write Queue Depth, Average Write Trigger, Block Write Size

Since I like the idea behind Averaging writes, I'll provide examples of possible options that could be used to adjust its behaviour, and also some example values for different drives.
Average Write Max Queue Depth - the max write queue depth FancyCache will go to. This is in blocks - not in Filesystem writes.
Average Write Pref Queue Depth - the preferred queue depth FancyCache tries to go to. This is in blocks - not in Filesystem writes.
Average Write Trigger Time - The amount of time the drive must be "idle" for writes to be queued.
Average Write Trigger - The amount of data that must be exceeded for the drive to not be considered "idle".
Max Block Write Size - The maximum block write size.
Pref Block Write Size - The preferred block write size. (to avoid impacting responsiveness)
Sucky SSD: (50-150MB/sec sequential, 0.2MB/sec 4k, 1 - 3000ms access times)
Average Write Max Queue Depth - 1
Average Write Pref Queue Depth - 1
Average Write Trigger Time - 100ms
Average Write Trigger - 128KiB
Max Block Write Size - 256KiB
Pref Block Write Size - 16KiB
The SSD must be idle (read/write less than 128KiB in 100ms) for the averaging writes to kick in. (Or if the write cache is full, that will trigger it) Then FancyCache tries to write one 16-256KiB block, and waits for the drive to be idle again.


Average HDD: (100-150MB/sec sequential, 0.5 - 1MB/sec 4k, 10 - 13ms access times)
Average Write Max Queue Depth - 6
Average Write Pref Queue Depth - 2
Average Write Trigger Time - 30ms
Average Write Trigger - 128KiB
Max Block Write Size - 2048KiB
Pref Block Write Size - 512KiB
The HDD must be idle (read/write less than 128KiB in 30ms) for the averaging writes to kick in. (Or if the write cache is full, that will trigger it) Then FancyCache tries to write 2-6 blocks up to 2048KiB in size. If the blocks are larger, less writes are queued. If the blocks are smaller, it gets closer to the max queue depth. Then FancyCache waits for the drive to be idle again.


Good SSD: (200MB/sec sequential, 10MB/sec 4k, 0.1 - 0.4ms access times)
Average Write Max Queue Depth - 200
Average Write Pref Queue Depth - 4
Average Write Trigger Time - 4ms
Average Write Trigger - 64KiB
Max Block Write Size - 2048KiB
Pref Block Write Size - 256KiB
The SSD must be idle (read/write less than 64KiB in 4ms) for the averaging writes to kick in. (Or if the write cache is full, that will trigger it) Then FancyCache tries to write 4-200 blocks up to 2048KiB in size. If the blocks are larger, less writes are queued. If the blocks are smaller, it gets closer to the max queue depth. Then FancyCache waits for the drive to be idle again.


Great SSD: (600MB/sec sequential, 40MB/sec 4k, 0.1 - 0.4ms access times)
Average Write Max Queue Depth - 400
Average Write Pref Queue Depth - 20
Average Write Trigger Time - 4ms
Average Write Trigger - 128KiB
Max Block Write Size - 4096KiB
Pref Block Write Size - 512KiB
The SSD must be idle (read/write less than 128KiB in 4ms) for the averaging writes to kick in. (Or if the write cache is full, that will trigger it) Then FancyCache tries to write 20-400 blocks up to 4096KiB in size. If the blocks are larger, less writes are queued. If the blocks are smaller, it gets closer to the max queue depth. Then FancyCache waits for the drive to be idle again.


The algorithm would have to understand that it's trying to balance out the number of writes against the amount of data, to avoid an unresponsive system. Low queue depths tell it that it's dealing with a HDD or bad controller, while allowing high max queue depths tells it the drive can handle it. High max block write size indicates high sequential speeds, but FancyCache does have to factor in that time is spent writing and scale back the write queue depth accordingly.

Maybe FancyCache already does something like this - but being able to tweak the raw values would help us fine tune the behaviour we want to our hardware. We'd do the experimenting for you and report back on what works for our hardware, so your coders don't have to.
Last edited by BikeHelmet on Tue Jun 21, 2011 2:14 am, edited 1 time in total.
-BikeHelmet
User avatar
Nina
Level 4
Level 4
Posts: 38
Joined: Sat Jan 29, 2011 2:21 pm

Re: Lazy write to disk

Post by Nina »

@BikeHelmet Image
User avatar
Support
Support Team
Support Team
Posts: 3628
Joined: Sun Dec 21, 2008 2:42 am

Re: Lazy write to disk

Post by Support »

:) Great!
Thank you, BikeHelmet.
Post Reply