tom-seddon/b2

Disk I/O performance and responsiveness

egrath opened this issue · 4 comments

It seems that the disk drive emulation has some issues as it's rather slow.

Take the following BASIC program for example:

   10REM ** DISK BENCHMARK TESTING
   20@%=&20109
   30MINT%=2000
   40PRINT "WRITING ";(MINT%*5)/1024; " KB TO DISK"
   50ST%=TIME
   60FILE%=OPENOUT("TESTDAT")
   70FOR I=0 TO MINT%
   80  R%=RND
   90  PRINT# FILE%,R%
  100  IF (I MOD 64)=0 THEN PRINT ".";
  110NEXT I
  120PRINT ""
  130CLOSE# FILE%
  140DUR%=(TIME-ST%)/100
  150PRINT "TOOK ";DUR%;" SECONDS (";(MINT%*5/1024)/DUR%;" KB/SECOND)"
  160*DELETE "TESTDAT"
  170

It writes out 2000 integers (1000 bytes) to a file. Running this on b2 takes around 68 seconds, even tough the application prints out a duration of 15 seconds. During the run of the program, b2 is completely unresponsive. It makes no difference if DFS or ADFS is used, nor what model of BBC computer is emulated.

Running the same program on other emulators, yields different results:

b-em: real runtime = 15 seconds, display runtime = 15 seconds
beebem: real runtime = 17 seconds, display runtime = 17 seconds
jsbeeb: real runtime = 18 seconds, display runtime = 18 seconds

I assume this is with the direct disk image option? I've reproduced this on Windows. Apologies, the poor write performance had escaped my notice - it's not supposed to be this bad.

I think I know how to address this. Though performance is always going to be worse (to some extent) than the normal disk image option, as direct disk images are deliberately accessed for every read or write rather than being buffered in memory. This means other programs can see b2's changes and it can see theirs.

Yes you are right - only happens with direct disk. If using the memory buffered one, speed is about the same as with the other emulators.

Thanks for pointing this out!

I've made a prerelease version with the disk options updated. Much improved speed for direct disk images, and some UI renaming: direct disk images are now just described as disk images (and are therefore considered the default), and in-memory disk images are explicitly described as such.

Documentation (such as it is - it needs improvement!) for this prerelease here: https://github.com/tom-seddon/b2/blob/b2-20240411-011127-47f5644-prerelease/doc/Overview.md#load-a-disc

Prerelease build here: https://github.com/tom-seddon/b2/releases/tag/b2-20240411-011127-47f5644-prerelease

Tested out the new changes - disk performance is on par with the other emulators now. Thank you very much for the quick solving of the issue!