Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F3 speed at 50% of h2testw speed under Windows 7 SP1 64 bit #188

Open
r2dd2 opened this issue Oct 30, 2022 · 20 comments
Open

F3 speed at 50% of h2testw speed under Windows 7 SP1 64 bit #188

r2dd2 opened this issue Oct 30, 2022 · 20 comments

Comments

@r2dd2
Copy link

r2dd2 commented Oct 30, 2022

Using the same hardware configuration I am able to reach a write speed of roughly 120 MByte/sec under Windows 7 SP1 64 bit on a WD 4TB disk in a docking station (WD40EFZX) connected to one USB 3.0 port on a Thinkpad T440p.
f3write only yields 60 Mbyte/sec.
There is just one primary partition on the drive formated as NTFS.

As I am hearing a certain repeating pattern of head movement of the drive under Linuxmint 21 (Kernel 5.15, has Paragon driver support for NTFS) as opposed to the smooth continuous sound of the disk under Windows 7, I guessed it must be a buffer issue.

When I increased the buffer MAX_BUF from 2MB to 4 MB the write speed increased from <= 60 MByte/sec to between 60 and 70 MByte/sec. A further increase to 8 MB yielded a RAM access error.

What do i have to do to increase MAX_BUF to 16 MB or even 128 MB?

@AltraMayor
Copy link
Owner

Try to adjust the parameter --stack when you compile F3 on Windows. See details on the README.rst file.

@r2dd2
Copy link
Author

r2dd2 commented Nov 3, 2022

I am running and compiling F3 under linux.

AltraMayor added a commit that referenced this issue Nov 8, 2022
The write buffer passed to the operating system has previously
been limited to MAX_BUFFER_SIZE.  This commit makes it dynamically
sized in order to reach maximum writing speeds.

See details on issue #188.
@AltraMayor
Copy link
Owner

Could you test pull request #190? I expect it to solve your problem.

AltraMayor added a commit that referenced this issue Nov 8, 2022
The write buffer passed to the operating system has previously
been limited to MAX_BUFFER_SIZE.  This commit makes it dynamically
sized in order to reach maximum writing speeds.

See details on issue #188.
@r2dd2
Copy link
Author

r2dd2 commented Nov 8, 2022

I am running #190 using the same hardware/software setup as before. Now speed varies between 60 MByte/sec and 80 MByte/sec. The sound of the harddrive is not smooth yet unfortunately.

@AltraMayor
Copy link
Owner

AltraMayor commented Nov 9, 2022

You can try to comment everything in flush_chunk() in the file f3write.c and return 0; to check if what's holding f3write back is the data synchronization with the disk.

Notice that the implementations of NTFS in Linux and Windows are not identical, so that can also account for part of the difference. You can verify this possibility using another file system format.

@r2dd2
Copy link
Author

r2dd2 commented Nov 9, 2022

By commenting out everything in flush_chunk() and returning 0, the write speed more than doubled and varies between 150 and 170 MByte/sec. Is this version operating correctly despite having commented out the flush_chunk() function?
By the way, when compiling there are lots of warning now.

@AltraMayor
Copy link
Owner

AltraMayor commented Nov 9, 2022

Given your result, I think that h2testw is not pushing written data to the disk, so its reported write speed is how fast Windows can manage its internal caches. In contrast, f3write waits for the disk to write large chunks of data. Thus, the reported write speeds are not comparable. Furthermore, when h2testw ends, one cannot immediately remove the drive because not everything has been written to the disk. On the other hand, when f3write ends, one can remove the drive as soon as the operating system is done with its disconnecting protocol.

The modified f3write is correct, but some data is not written to the disk when it ends.

Anyway, your investigation has led to an improvement in the buffer that f3write passes to the operating system. I'll extend that improvement to f3read and eventually merge it.

@r2dd2
Copy link
Author

r2dd2 commented Nov 9, 2022

f3read has no speed issue:

Validating file 3724.h2w ... 2097152/ 0/ 0/ 0
Validating file 3725.h2w ... 2097152/ 0/ 0/ 0
Validating file 3726.h2w ... 1766424/ 0/ 0/ 0

Data OK: 3.64 TB (7813657624 sectors)
Data LOST: 0.00 Byte (0 sectors)
Corrupted: 0.00 Byte (0 sectors)
Slightly changed: 0.00 Byte (0 sectors)
Overwritten: 0.00 Byte (0 sectors)
Average reading speed: 147.75 MB/s

'===============================================
for comparison: erasing a drive with ddrescue
'===============================================
p@LM21:~/Downloads/f3-8.0$ sudo ddrescue --force /dev/zero /dev/sdc
GNU ddrescue 1.26
Press Ctrl-C to interrupt
ipos: 4000 GB, non-trimmed: 0 B, current rate: 63373 kB/s
opos: 4000 GB, non-scraped: 0 B, average rate: 155 MB/s
non-tried: 9223 PB, bad-sector: 0 B, error rate: 0 B/s
rescued: 4000 GB, bad areas: 0, run time: 7h 8m 24s
pct rescued: 0.00%, read errors: 0, remaining time: n/a
time since last successful read: n/a
Copying non-tried blocks... Pass 1 (forwards)
ddrescue: /dev/sdc: Write error: No space left on device

I will let f3write run till the end. Tomorrow I will invoke f3read to see how the failure to write the last bytes (kind of write hole) is reflected in the output of f3read.

AltraMayor added a commit that referenced this issue Nov 10, 2022
The write and read buffers passed to the operating system have
previously been limited to MAX_BUFFER_SIZE.  This commit makes
them dynamically sized in order to reach maximum writing and
reading speeds.

See details on issue #188.
@AltraMayor
Copy link
Owner

AltraMayor commented Nov 10, 2022

I updated f3read anyway; could you test it? The code is in the updated pull request #190.

@r2dd2
Copy link
Author

r2dd2 commented Nov 10, 2022

I am testing the new f3read now.

The previous f3read was already fast:
Validating file 3723.h2w ... 2097152/ 0/ 0/ 0
Validating file 3724.h2w ... 2097152/ 0/ 0/ 0
Validating file 3725.h2w ... 2097152/ 0/ 0/ 0
Validating file 3726.h2w ... 1766424/ 0/ 0/ 0

Data OK: 3.64 TB (7813657624 sectors)
Data LOST: 0.00 Byte (0 sectors)
Corrupted: 0.00 Byte (0 sectors)
Slightly changed: 0.00 Byte (0 sectors)
Overwritten: 0.00 Byte (0 sectors)
Average reading speed: 144.86 MB/s

I had run it to see if there were any errors shown as you said that the last bytes or buffers would not be written.

The current test should be ready in 8h as the files written with f3write using a dynamic buffer and flushing disabled are still on my drive.

@AltraMayor
Copy link
Owner

AltraMayor commented Nov 11, 2022

Notice that the errors will only show up if you've removed the drive before the operating system had a chance to flush its cache onto the drive. If you ran f3read following f3write without removing the drive, the operating system would not even need to write its cache since it can read its cache to give a copy back f3read. And the operating system would've had enough time to write its cache onto the drive anyway.

My main point before was that h2testw would not account for the extra time needed to measure the drive's write speed more accurately. Therefore, the measurements of the write speed that h2testw and f3write obtain are not directly comparable.

@r2dd2
Copy link
Author

r2dd2 commented Nov 11, 2022

There is no relevant change in speed by using dynamic buffers in f3read in my configuration:
'===============================================================
Validating file 3724.h2w ... 2097152/ 0/ 0/ 0
Validating file 3725.h2w ... 2097152/ 0/ 0/ 0
Validating file 3726.h2w ... 1766424/ 0/ 0/ 0

Data OK: 3.64 TB (7813657624 sectors)
Data LOST: 0.00 Byte (0 sectors)
Corrupted: 0.00 Byte (0 sectors)
Slightly changed: 0.00 Byte (0 sectors)
Overwritten: 0.00 Byte (0 sectors)
Average reading speed: 143.34 MB/s
'===============================================================
[....
Notice that the errors will only show up if you've removed the drive before the operating system had a chance to flush its cache onto the drive.
...]
Understood. I was using h2testw and intended using f3read/f3write to test as many sectors of a HDD or SSD.

[...
If you ran f3read following f3write without removing the drive, the operating system would not even need to write its cache since it can read its cache to give a copy back f3read
...]

I think you mean to say: The operating system would not even need to read the drive since there is still a cached copy to return to f3read.
But with a 4 TB drive compared to a small flash drive the latest cached write operations would have been overwritten when starting f3read reaches the end of the 4TB.

Please let me know once the new version is out and I will retest it on another 4TB drive that I want to test before using it.
I am happing about the stade that F3 has reached know!

@AltraMayor
Copy link
Owner

I've merged pull request #190.

@r2dd2
Copy link
Author

r2dd2 commented Nov 12, 2022

I downloaded f3-master.zip from https://github.com/AltraMayor/f3 but there is no speed gain anymore when running f3write. The forced buffer flushing still seems to be active. Is that intended?

@AltraMayor
Copy link
Owner

AltraMayor commented Nov 14, 2022

Pull request #190 only includes the dynamic buffer. Your comment states that pull request #190 improves the write speed on your system.

As I explained above, the write speeds that h2testw reports are not comparable to F3's write measurements since they measure two different things. F3's write measurement is much closer to what the write speed is. To make this point, I describe an experiment I ran on my system in the following paragraphs.

I ran f3write as it is in the repository on one of my test drives as follows:

$ date; ./f3write -s 1 -e 1 /media/michel/MYLINUXLIVE/; date
Mon 14 Nov 2022 02:07:34 PM EST
F3 write 8.0
Copyright (C) 2010 Digirati Internet LTDA.
This is free software; see the source for copying conditions.

Free space: 1.74 GB
Creating file 1.h2w ... OK!                        
Free space: 762.52 MB
Average writing speed: 2.87 MB/s
Mon 14 Nov 2022 02:13:31 PM EST

As you can see, the average writing speed was 2.87 MB/s, and it took 5 minutes and 57 seconds to finish. If you multiply this speed rate and time, you obtain 1GB of written data.

Then I prepared the environment to run f3write without synching data to the drive with the commands below:

$ rm /media/michel/MYLINUXLIVE/1.h2w
$ sync

And repeated my first measurement with an f3write without data synchronization:

$ date; ./f3write -s 1 -e 1 -f /media/michel/MYLINUXLIVE/; sync; date
Mon 14 Nov 2022 02:14:18 PM EST
F3 write 8.0
Copyright (C) 2010 Digirati Internet LTDA.
This is free software; see the source for copying conditions.

Free space: 1.74 GB
Creating file 1.h2w ... OK!                         
Free space: 762.52 MB
Average writing speed: 540.37 MB/s
Mon 14 Nov 2022 02:20:58 PM EST

Notice that I added sync, so the time measurement here accounts for the time the operating system takes to write its buffers to the drive.

While the write speed of 540.37 MB/s is impressive, it is far from reality. Not only did the operation take 6 minutes and 40 seconds, but for this speed and time, f3write should've written a whopping 211GB of data!

@r2dd2
Copy link
Author

r2dd2 commented Nov 14, 2022

Pull request #190 only includes the dynamic buffer. Your comment states that pull request #190 improves the write speed on your system.

I did not say so.

Above I wrote:
I am running #190 using the same hardware/software setup as before. Now speed varies between 60 MByte/sec and 80 MByte/sec. The sound of the harddrive is not smooth yet unfortunately.

That was followed by:
By commenting out everything in flush_chunk() and returning 0, the write speed more than doubled and varies between 150 and 170 MByte/sec. Is this version operating correctly despite having commented out the flush_chunk() function?
By the way, when compiling there are lots of warning now.
'=============================================================================

Thanks for preparing the long answer! I understand what you want to say. I wrote the answer as user "r2d3" to the following question:
https://superuser.com/questions/1744826/100-times-faster-hdd-speeds-is-this-real-does-primocache-application-really-wo

Regarding your example:

02:20:58

  • 02:14:18
    = 6:40 = 400 sec

1,74e9 Byte / 400 sec =4,35 MByte/sec

My assumption was that the latest average writing speed should be defined as (total bytes written) / (total time elapsed).
I am confused that your program is showing a write speed at least 100 times higher.
I appears that the operating system is performing the sync call but returning to the caller before having the caches flushed so that the final time stamp is taking too early.

Maybe I am using your program out of scope!
I am using h2testw as a proxy for a surface test on a HDD, not on USB stick sized flash storage. I want to test as many sectors as possible. I will post an issue for that.

My RAM is 4GB, the operating linux system resides on a 16 GB USB pen drive and the HDD has a size of 4 TB = 4000 GB.
As opposed to little USB pen drives caching has only a limited effect due to the size relationship between the HDD and the rest of storage.

USB pen drives do not have any rotating parts so it seems to me that flushing caches do not degrade the write speed.
HDDs do have rotating parts and interfering sync commands seem to degrade the write speed - I assume.

@AltraMayor
Copy link
Owner

Pull request #190 only includes the dynamic buffer. Your comment states that pull request #190 improves the write speed on your system.

I did not say so.

Above I wrote: I am running #190 using the same hardware/software setup as before. Now speed varies between 60 MByte/sec and 80 MByte/sec. The sound of the harddrive is not smooth yet unfortunately.

In your opening post, you wrote "When I increased the buffer MAX_BUF from 2MB to 4 MB the write speed increased from <= 60 MByte/sec to between 60 and 70 MByte/sec." Therefore, I assumed that f3write was doing less than 60 MB/s on your system. And you quoted above that speeds after #190 went between 60 to 80 MB/s.

@r2dd2
Copy link
Author

r2dd2 commented Nov 14, 2022

You are right. Compared to the initial situation #190 did improve write speed even in the synced environment, and it was less than 60 MB/s before.

@AltraMayor
Copy link
Owner

Thanks for preparing the long answer! I understand what you want to say. I wrote the answer as user "r2d3" to the following question: https://superuser.com/questions/1744826/100-times-faster-hdd-speeds-is-this-real-does-primocache-application-really-wo

Thank you for helping others.

Regarding your example:

02:20:58

  • 02:14:18
    = 6:40 = 400 sec

1,74e9 Byte / 400 sec =4,35 MByte/sec

1GB = 2^30 = 1.074e9 not 1,74e9

1.074e9 / 400 = 2,685,000 B/s

My assumption was that the latest average writing speed should be defined as (total bytes written) / (total time elapsed). I am confused that your program is showing a write speed at least 100 times higher. I appears that the operating system is performing the sync call but returning to the caller before having the caches flushed so that the final time stamp is taking too early.

I haven't measured it, but some of the time is the operating system pushing its buffers to the drive at command sync, so f3write does not see the total time.

Maybe I am using your program out of scope! I am using h2testw as a proxy for a surface test on a HDD, not on USB stick sized flash storage. I want to test as many sectors as possible. I will post an issue for that.

What's confusing you is that h2testw is not accounting for the cache of the operating system, so its write speed is not realistic.

@AltraMayor
Copy link
Owner

AltraMayor commented Nov 14, 2022

My RAM is 4GB, the operating linux system resides on a 16 GB USB pen drive and the HDD has a size of 4 TB = 4000 GB. As opposed to little USB pen drives caching has only a limited effect due to the size relationship between the HDD and the rest of storage.

USB pen drives do not have any rotating parts so it seems to me that flushing caches do not degrade the write speed. HDDs do have rotating parts and interfering sync commands seem to degrade the write speed - I assume.

Although flash drives do not have spinning discs, they have different write speeds for random and sequential writes analogous to hard discs. When a file is synced, the file system has to update the data on the disc and update the corresponding metadata of the file; the latter operation likely creates random accesses. So there may be a measurable degradation here.

If you can make a valid argument for f3write to have an option not to synch the written data, I'm okay with adding this feature. But you haven't made such an argument and have not been that constructive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants