oddbdatabase::writefile slow when writing to a mapped drive
oddbdatabase::writefile slow when writing to a mapped drive
when writing a dxf file to a mapped drive, the performance is very, very slow relative to the local hard disk. i'd expect it to be a little slower but the differential i'm seeing is like 5 seconds local versus 3 minutes to a mapped drive. i'm on windows xp pro with service pack 2. is there something i need to do in the code or is it something with windows xp?
thanks in advance for any help.
dd uses odstreambuf interface for file output. oddbsystemservices::createfile() returns a pointer to object implementing this interface.
exsystemservices::createfile() returns pointer to sample implementation of this interface (see examples/exservices folder).
this is how optimization for different platforms/usage can be implemented.
on windows file output is implemented via writefile() function.
dxf output results in multiple calls to writefile() with small chunks of data. probably writefile() working with mapped drive works slowly in such case and adding a buffering in odstreambuf implementation could help.
on the other hand it may slow down writing to local drive because windows has its own buffering for local drives...
sergey slezkin
thanks sergey for the quick reply. i implemented a buffering scheme and that cured the problem with the mapped drives. thanks for your advice.
after your reply i looked into the problem once more. by default odwrfilebuf(file_name) opens the file with sharing mode denyno. in such case windows can't have local cache (buffer) for mapped drive file (the file may be modified by other computer). as a result file operations are unbuffered and synchronose. if mapped drive file is locked exclusively (denyreadwrite) theoretically windows can have local file buffer.
one of below modifications may help (enable file buffering at system level):
odfilebuf.h
code:
//odwrfilebuf(const odchar file_path) {open(file_path);}
odwrfilebuf(const odchar file_path) {open(file_path, oda::ksharedenyreadwrite);}
or change default value of sharing mode parameter in odwrfilebuf

en()
or in application code:
code:
//odwrfilebuf file(file_name);
odwrfilebuf file;
file.open(file_name, oda::ksharedenyreadwrite);
sergey slezkin
i gave denyreadwrite a shot thinking that if it worked, a simpler solution is better than my home-grown buffering.
it didn't seem to help.
a simple file through my translator produces a 2,243 kb dxf file. it takes 5 seconds to the local disk and 1 minute 10 seconds to a mapped drive using either denyreadwrite or denyno. with my internal buffering scheme, it takes just slightly longer than 5 seconds to write to the mapped drive.
anyways, i've got a solution that works and i'm happy but probably like you, still curious as to why this is so darn slow.