RunCPM_VGA32 icon indicating copy to clipboard operation
RunCPM_VGA32 copied to clipboard

Slow file operation.

Open SergeyDr opened this issue 2 years ago • 3 comments

Hello, Testing this project on TTGO VGA32, I had mentioned that all file operation in CPM very slow.

After code checking found that for each operation with file host make "open file", "read/write operation" and "close file" CPM can make file operations with 128 bytes block only. So such algorithm become dramatically slow.

For ex. MBASIC has size 24k. So simply load it in memory take 24k /128b = 192 operation. 192 time it's open and close file MBASIC.COM during loads in memory. And, as a result, MBASIC loads 3.6 sec. The same situation with write files... I suppose such strategy also not good for SD cards...

So, there are need some cashing for removing additional open and close file operation. Really CPM very rear use more than 3 file simultaneously and cashing for 10 opened file pointers I think would be enough.

SergeyDr avatar Feb 27 '23 08:02 SergeyDr

@SergeyDr I did asked the original RunCPM author in the RunCPM-ESP32-Channel on Discord - maybe he got an idea: https://discord.com/channels/609020936225685514/726783380783628301

guidol70 avatar Mar 12 '23 14:03 guidol70

This one is interesting and had a reason to exist. As far as I remember, CP/M didn't really have the concept of an "open" file. It was just some flag it kept in the FCB I guess. So, in theory, you could just fill a FCB with a file information and execute a read/write procedure without even "opening" the file. On modern OS this becomes more complicated, as the OS keeps track of which files are open, and prevents such behavior (and I do not know if the Fat library we use for Arduino tracks that). If my memory doesn't fail me, and this is really the case, by controlling (caching) which files are open and which are not, we would probably prevent code from arbitrarily making a file access without previously "opening" it, therefore breaking historical compatibility with original CP/M. This is a complex issue, or at least looks complex to me. My suggestion is that we make some research on this to figure out how to implement. If this will indeed improve speed on Fat Library based devices, I am up to it.

MockbaTheBorg avatar Mar 12 '23 16:03 MockbaTheBorg

Hi again, I wrote code for caching host files for TTGO. Now MBASIC load 0,5 sec (was 3.6 sec)😊 I wrote also small program for file system speed checking. The result for seq read/write 50kb file are: Non caching Caching Write. 10s 1.s Reed. 5s. 0.6s Up to 10 times! 😊 I tried not touch the main algorithm and make changes only in file abstraction_arduino.h. Some small changes made in cpm.h and ccp.h(there was a bug working with submit files) All caching function placed in separate file and have detailed comments. The code not hardly tested and may have some bugs... So if you find it I am ready to correct ones. Working version in attached file. Testing program wrote for Aztec C. com file also included in separate folder. Hope you find it useful... 😊 RunCPM_VGA32_v6_0_26102022.zip

SergeyDr avatar Apr 17 '23 01:04 SergeyDr