RamonUnch / GreenPad

Fork from roytam1 fork from original GreenPad
21 stars 0 forks source link

Use `FILE_FLAG_NO_BUFFERING` flag for opening file #110

Closed RamonUnch closed 1 year ago

RamonUnch commented 1 year ago

When calling CreateFile() in the FileR::Open() function we can specify the FILE_FLAG_NO_BUFFERING flag so that the MapViewOfFile() will simply map the file view. This dramatically reduces memory usages and allow instant execution of MapViewOfFile().

However, I tested on my DELL Latitude laptop and it is slightly slower to load large files. On My old Pentium III under Windows 98SE, it is much faster though.

I think I will enable this flag anyway, because it can improve overall performances by not polluting the cache with files that are only loaded once and it also reduces CPU usage.

@roytam1 You might be interested by this super simple patch, I would be interested to see if it works well for you.

The flags does not seem to hurt anything on Win32s 1.1, I will have to try other old Windows versions.

roytam1 commented 1 year ago

doing this on floppy will be a disaster.

BTW there is a discussion in BC about this: https://forum.scootersoftware.com/forum/beyond-compare-4-discussion/general/13496-removed-bypass-disk-cache-during-binary-comparisons-option

RamonUnch commented 1 year ago

doing this on floppy will be a disaster

Strange, why is that ? The read is be sequential anyway, we never read back into the file buffer, so what is the point of having Windows first read the whole file once before starting to decode it?

We could skip this flag for floppy drives, that is easy also we could reserve the flag for files larger than a couple MB.

EDIT: Using PCem I can confirm that it is much slower on floppy, but then again on some cases it is faster on a HDD, so I am sure loading times could be improved if we had the right read pattern.