VOGONS


DOSBox file I/O slow

Topic actions

First post, by bn

User metadata
Rank Newbie
Rank
Newbie

Hi,

I have a DOS database application that uses flat files for data storage which is extremely fast on native DOS and NTVDM under Windows and very slow under DOSBox. I could track it down to the basic file I/O being slow in DOSBox and I hope that this is the right forum to raise this issue.

I have written a simple Pascal test program (source code below, exe available on request) that writes a sequence of 1 million 4byte integers to a file and then reads them back randomly 1 million times. Under NTVDM, times are 4 seconds for writing and 8 seconds in total. Under DOSBox, times are 19 seconds for writing and 67 seconds in total.

There is not much variation in the figures even when I use very different DOSBox settings. The results apply both for local disk access and network shares.

Any idea where to look for reasons for the slow performance?

Best regards,
Boris

program IOPerfTest;

uses
Dos;


type
tRec= record
id: Longint
end;

var
F: file of tRec;
r: tRec;
t0: Real;
i,j: Longint;

const
fn= 'ioprftst.dat';
N= 1000000;
M= 1000000;

function t: real;
var
h,m,s,s100: word;
begin
gettime(h,m,s,s100);
t:= s100/100.+s+m*60.0+h*3600.0-t0;
end;

procedure log(const msg: string);
begin
writeln(t:7:2,':',msg);
end;

begin
writeln('IO Performance Test');
t0:= 0; t0:= t;
log('start');
assign(f, fn);
rewrite(f);
log('writing values...');
for i:= 0 to N-1 do
begin
r.ID:= i;
write(f, r);
end;
log('done');
log('reading values...');
for j:= 0 to M-1 do
begin
i:= trunc(random*M);
seek(f, i); read(f, r);
if r.ID<> i then log('error!');
end;
log('done');
close(f);
log('end');
readln; { Enter to finish }
end.

Reply 2 of 3, by bn

User metadata
Rank Newbie
Rank
Newbie

Sorry, I should have been more explicit above when I mentioned the various settings. I tried this before and I checked it out right now again. cpu=dynamic and cycles=max leads to a performance improvement (times are 5 and 25 seconds) but this is still quite slow on the random file read side.

Is this the typical performance degradation one suffers in the best case due to the cpu emulation?

Boris

Reply 3 of 3, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Is this the typical performance degradation one suffers in the best case due to the cpu emulation?

Yes. And it's not that the applications suffer from it, but dos games run
BECAUSE of the cpu emulation as the host cpu would be far too fast.