Commit 3744db9f authored by Simon Proven's avatar Simon Proven
Browse files

Found a major inefficiency in the handling of file creation, closing of files...

Found a major inefficiency in the handling of file creation, closing of files and other uses of the NextFree function.  In the case of file creation, the problem was particularly bad on large free space maps, as the function was of order N^2 on the size of the map, when the disc was nearly full.  As the disc gets fuller, the problem gets worse; with 1400 zones in the map, N^2 is very large indeed.  This resulted in *cdir sometimes taking 1sec.

Now, a new function NextFree_Quick exists which performs similarly to NextFree,
but does not consider free spaces in zones beyond the current zone.  This
can be used by functions which need only examine free spaces in a given zone,
such as is the case in ClaimFreeSpace where it is stepping throigh zones to
find a single gap large enough for the entire file.

For other functions which work on a single zone, the speedup is less dramatic,
of the order N instead of N^2.
parent eab91c13
;>Version Version file for FileCore
GBLS version
version SETS "3.13"
version SETS "3.14"
GBLA Version
Version SETA 313
Version SETA 314
GBLS date
date SETS "16 Apr 1998"
date SETS "06 May 1998"
GBLL test_version
......
......@@ -1781,10 +1781,12 @@ GrowBigDir ROUT
ADD R8, R11, R7 ; next object
Pull "R7"
MOV R11, R9
BL NextFree ; (R10,R11->R9,R11)
BL NextFree_Quick ; (R10,R11->R9,R11)
BCS %FT35 ; exhausted, so no gap
CMPS R11, R8 ; is it a gap
BEQ %FT40
35
[ DebugXg
DLINE "can't shorten"
]
......@@ -2124,10 +2126,12 @@ ShrinkBigDir ROUT
ADD R8, R11, R7 ; next object
Pull "R7"
MOV R11, R9
BL NextFree ; (R10,R11->R9,R11)
BL NextFree_Quick ; (R10,R11->R9,R11,Z,C)
BCS %FT35
CMPS R11, R8 ; is it a gap
BEQ %FT40
35
[ DebugX :LOR: DebugXg
DLINE "can't shorten"
]
......
......@@ -104,10 +104,10 @@ Debug2D switch F ;DiscOp SWI call processing
Debug3 switch F ;disc accesses
Debug3L switch F ;low level discops into parent
Debug4 switch F ;disc and drive record operations
Debug5 switch F ;old free space map operations
Debug5 switch T ;old free space map operations
Debug6 switch F ;pathname and directory operations
Debug6f switch F ; FindDiscByName
Debug7 switch T ;OsFile operations
Debug7 switch F ;OsFile operations
Debug8 switch F ;File Level Disc Ops
Debug9 switch F ;Misc useful routines
DebugA switch F ;OsFun operations
......@@ -121,9 +121,9 @@ DebugBs switch F ;Open file new map allocated size
DebugBt switch F ;Random access file I/O terse
DebugC switch F ;Directory cache
DebugD switch F ;Scatter buffer
DebugE switch F ;new free space map
DebugE switch T ;new free space map
DebugEa switch F ;new free space map random extension
DebugEx switch F ; verbose new free space map
DebugEx switch T ; verbose new free space map
DebugEs switch F ; debugging of SortDir use in NewClaimFree
DebugF switch F ;new free space map auto compact
DebugFx switch F ;new free space map: check for this bug
......@@ -142,7 +142,7 @@ DebugMt switch F ; MultiFS extensions (terse)
DebugN switch F ; Disc insertion / request for insertion thread
DebugO switch F ; MultiFS extensions - formatting SWIs
DebugP switch F ; Process activation/deactivation
DebugQ switch T ; *-commands
DebugQ switch F ; *-commands
DebugR switch F ; reentrance
DebugU switch F ; UpCall
Debugb switch F ; break key action updates
......@@ -154,7 +154,7 @@ DebugXg switch F ; debug long filenames - growin dirs
DebugXm switch F ; debug long filenames - memory problems
DebugXb switch F ; debug long filenames - binary chop dir search
DebugXr switch F ; debug long filenames - rename
DebugXd switch T ; debug long filenames - directory names
DebugXd switch F ; debug long filenames - directory names
DebugCW switch F ; debug write cacheing of dirs
......
......@@ -127,7 +127,7 @@ WhatDiscCommon
BL SetVOnR0
[ Debug4 :LOR: DebugL
LDR lr, [r5, #RootDir]
LDR lr, [r3, #RootDir]
DREG lr, "RootDir on Exit WhatDisc is: "
DREG R1, "<WhatDisc(Drv=",cc
......@@ -580,6 +580,10 @@ DetermineDiscType ROUT
BL DoSwiDiscardReadSectorsCache
TEQP pc, r7
[ DebugL
DREG R5, "Disc rec ptr now: "
]
Pull "r0,r1,r3,r4,r7,r11,pc"
LTORG
......@@ -840,6 +844,13 @@ MountDiscOnDrive ROUT
STR r0, [r5, #DiscName+2]
STR r0, [r5, #DiscName+6]
[ BigDir
LDR lr, [r5, #RootDir]
BIC lr, lr, #DiscBits
ORR lr, lr, r2, LSL #(32-3)
STR lr, [r5, #RootDir]
]
; Make sure this disc is thought to be used
MOV r0, r2
BL UpdatePriority
......
......@@ -277,13 +277,13 @@ AllocWork1 # 0
BL InitZoneFree ;(R0,R10->R11)
MOV R2,#0
12
BL NextFree ;(R10,R11->R9, R11,Z,C)
BL NextFree_Quick ;(R10,R11->R9, R11,Z,C)
BCS %FT14 ;zone done
[ BigMaps
BLNE FreeRdLenBits ;(R10,R11->R7)
BL FreeRdLenBits ;(R10,R11->R7)
|
BLNE RdLenBits ;(R10,R11->R7)
BL RdLenBits ;(R10,R11->R7)
]
BCS %FT14 ;zone done
ADD R5, R5, R7
ADD R2, R2, R7,LSL #9
ADD R2, R2,#1
......
......@@ -1439,6 +1439,61 @@ NextFree ROUT
; ==============
; NextFree_Quick
; ==============
;entry
; R10 -> map start
; R11 map ptr to space
;exit
; C set <=> exhausted or started new zone
; R9 map ptr to predecessor of next space
; R11 map ptr to next space, unless started new zone or exhausted
NextFree_Quick ROUT
[ BigMaps
Push "R0,R8,LR"
|
Push "R8,LR"
]
[ DebugE
DREG R10, "NextFree(map:",cc
DREG R11, ", map ptr:",cc
DLINE ")"
]
[ BigMaps
BL FreeRdLinkBits ;(R10,R11->R8,Z)
|
BL RdLinkBits ;(R10,R11->R8,Z)
]
BEQ %FT10 ;zone done
MOV R9, R11
ADDS R11,R11,R8 ;Z=0, C=0
05
[ DebugE
DREG R9, "<-NextFree(prev:",cc
DREG R11, ", this:",cc
BCC %FT01
DLINE ", next zone",cc
01
BNE %FT02
DLINE ", map end",cc
02
DLINE ")"
]
[ BigMaps
Pull "R0,R8,PC"
|
Pull "R8,PC"
]
10
CMPS PC, #0 ;Z=0, C=1
B %BT05
; =============
; RdLenLinkBits
; =============
......
......@@ -932,7 +932,7 @@ MyCloseFile ROUT
]
ADDHI R1, R11,R5
MOV R11,R9
BL NextFree ;(R10,R11->R9,R11,Z,C)
BL NextFree_Quick ;(R10,R11->R9,R11,Z,C)
TEQS R11,R4 ;does next gap join end of frag
[ BigMaps
BLEQ FreeRdLenBits ;(R10,R11->R7)
......
......@@ -451,6 +451,9 @@ LayoutBootBlock ROUT
LDR lr, [r0, #LowSector]
STR lr, [r4, #DefectStruc + LowSector]
LDR lr, [r0, #RootDir]
[ DebugL
DREG lr, "Setting RootDir to (FormSWIs, 439): "
]
STR lr, [r4, #DefectStruc + RootDir]
[ BigDisc
......
......@@ -57,6 +57,10 @@ IdentifyDisc ROUT
LDR r9, [r5, #RootDir]
AND r9, r9, #DiscBits
[ DebugL
DREG r9, "Rootdir internally starts as: "
]
; Generate an initial root dir address
MOV r1, r0, ASL #(32-3)
EOR r1, r1, #bit31 ; Convert to external numbering
......@@ -82,7 +86,7 @@ IdentifyDisc ROUT
STR lr, [r5, #RootDir]
[ DebugL
DLINE "Restoring internal disc numbering of RootDir: "
DREG lr, "Restoring internal disc numbering of RootDir: "
]
50
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment