Issue Details (XML | Word | Printable)

Key: CORE-4913
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Vlad Khorsun
Reporter: Jan Hejda
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Firebird Core

Database backup using Nbackup is getting slow when directed to NAS over SMB protocol

Created: 24/Aug/15 06:35 AM   Updated: 24/Jun/17 11:57 AM
Component/s: NBACKUP
Affects Version/s: 2.5.0, 2.5.1, 2.5.2, 2.1.5 Update 1, 2.5.2 Update 1, 3.0 Alpha 1, 3.0 Alpha 2, 2.1.6, 2.5.3, 3.0 Beta 1, 2.1.7, 2.5.3 Update 1, 2.5.4, 3.0 Beta 2, 3.0 RC1, 2.5.5, 3.0 RC2, 4.0 Initial
Fix Version/s: 4.0 Alpha 1, 3.0.3

Environment: Windows Server 2003 32 bit, 1Gbit ethernet, NAS QNAP ts-439 RAID 5

QA Status: Cannot be tested
Test Specifics: Platform (Windows/Linux) specific


 Description  « Hide
After a few years of running well, the backup of 60GB database suddenly slowed down during one month from 2.5 hours to 24 hours.
It was slow only for that Linux based NAS, the speed for Windows shared directories was about 2.5 hours.
After below described change I achieved the speed allowing the same backup to be done within 40 minutes.

In the function void nbackup::create_backup() in the function call CreateFile I changed the flag GENERIC_WRITE to GENERIC_READ | GENERIC_WRITE.
The reason for the change is described in MSDN (https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx):
   When an application creates a file across a network, it is better to use GENERIC_READ | GENERIC_WRITE for dwDesiredAccess than to use GENERIC_WRITE alone. The resulting code is faster, because the redirector can use the cache manager and send fewer SMBs with more data. This combination also avoids an issue where writing to a file across a network can occasionally return ERROR_ACCESS_DENIED.


 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Vlad Khorsun added a comment - 13/Jun/17 02:19 PM
I can confirm significant performance boost with this change.

Backup of 0 level of ~5GB database via 1Gb network

before the change:

time elapsed 336 sec
page reads 647392
page writes 647392

after the change:

time elapsed 83 sec
page reads 647392
page writes 647392

FB 3.0.3, Win7 x64, SSD, Net 1Gb, NAS QNAP TS-251 RAID1