DjScribbles / GamePipe

An application that automates the movement of Steam games from drive to drive or computer to computer
GNU General Public License v2.0
196 stars 12 forks source link

[Game move performance] Stream buffer size too small #16

Closed f1ac closed 7 years ago

f1ac commented 7 years ago

It seems buffer size of 16Kb is used for read and write streams. It makes CPU load huge and decreases copy speed. I think a buffer of several Mb would increase performance significantly.

f1ac commented 7 years ago

Did a quick test with stream buffer increased to 1Mb. CPU usage dropped from 70% to 10-20%, copy speed increased just a little bit, but this is hugely dependent on actual HDD/SSD used.

DjScribbles commented 7 years ago

Is this with the latest version? Some significant changes were made this week to help CPU efficiency, but this wasn't one of them.

On Jan 14, 2017 2:10 PM, "f1ac" notifications@github.com wrote:

Did a quick test with stream buffer increased to 1Mb. CPU usage dropped from 70% to 10-20%, copy speed increased just a little bit, but this is hugely dependent on actual HDD/SSD used.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/DjScribbles/GamePipe/issues/16#issuecomment-272645840, or mute the thread https://github.com/notifications/unsubscribe-auth/AB-ONILSIoKYBAAQQ1HDQ4TlrjbAv0r7ks5rSR2cgaJpZM4LjtOn .

f1ac commented 7 years ago

Yes, I've just downloaded latest master an hour ago. Still testing, but it seems the larger the buffer, the less load on CPU. Dropped to about 5% on 8Mb.

DjScribbles commented 7 years ago

I'm doing some testing of this on my end now, my one major concern is that I don't want to hurt the transfer speed of smaller files (which are already pretty slow).

Terraria is my go-to workload for this kind of testing, I'm getting the following results (in the order shown): [16KB Buffer]Completed local move of Terraria. Transferring 10362 files, 209.6MB total, in 00:00:54.1973316 (averaging 3.9MB/sec). [8MB Buffer]Completed local move of Terraria. Transferring 10362 files, 209.6MB total, in 00:00:53.3557974 (averaging 3.9MB/sec). [8MB Buffer]Completed local move of Terraria. Transferring 10362 files, 209.6MB total, in 00:00:52.6110731 (averaging 4MB/sec). [16KB Buffer]Completed local move of Terraria. Transferring 10362 files, 209.6MB total, in 00:00:41.0708827 (averaging 5.1MB/sec). [16KB Buffer]Completed local move of Terraria. Transferring 10362 files, 209.6MB total, in 00:00:40.2548157 (averaging 5.2MB/sec).

(Starting to suspect some chaching is helping out, I moved another 2GB game before these next two) [8MB Buffer]Completed local move of Terraria. Transferring 10362 files, 209.6MB total, in 00:01:47.4919216 (averaging 1.9MB/sec). [8MB Buffer]Completed local move of Terraria. Transferring 10362 files, 209.6MB total, in 00:00:53.1413978 (averaging 3.9MB/sec).

Transferring the 2GB game, I definitely saw a substantial improvement in CPU and transfer speed, but I'm going to toy around with file size to see if I can do a Math.Min(8MB, fileSize).

The transfer of Terraria that hit 1.9MB/s seems to indicate that it would be best to smartly size the buffer.

f1ac commented 7 years ago

From storage reviews it seems that 64-256Kb buffer is enough to max out performance of modern SSDs, larger values up to 1-8Mb will only reduce CPU usage. Even larger values seem to decrease speed/increase load in some tests, probably due to the fact such transfer sizes don't fit CPU cache. All this is valid for large files, small ones will reduce performance and buffer size probably does not matter in this case. OS and disk cache will tamper with tests, so I would suggest to use large (>10Gb) games with small amount of large files. Games featuring huge amount of small files could not be helped.

DjScribbles commented 7 years ago

I've added code to set the buffer size to the size of the file (up to the maximum buffer size), which I was already computing early on to sort the work-load. The results look pretty awesome even in the Terraria test, CPU usage appears much lower even with the small files.

I tried out a 16MB buffer while transferring The Witcher 3 (50GB, with some very large files), and am seeing about 0.5-3% CPU usage. I tried the same transfer with an 8MB buffer, and got roughly the same results, and similar transfer speeds, so I think I think I'll draw the line at 8MB.

DjScribbles commented 7 years ago

Thanks for reporting this, this is a big improvement. It will show up in the next release.