SD stores data in files, and each file is one of two types: a directory file or a dynamic file. The two have different on-disk layouts, different performance characteristics, and different rules for what can read them.
Directory files#
A directory file is an ordinary Windows folder with one file per record. The record id is the file name.
| On disk | %USERPROFILE%\SDCoreSolo\user_accounts\sduser\<filename>\ |
| Record id | the file name |
| Readable by | any Windows program (Notepad, Excel, etc.) |
| Record ids | matched case insensitively |
The bp file is a directory file. The dictionaries, and on a managed computer
global.bp.out, are directory files too.
A file put in the directory from outside under a name SD's own naming cannot produce (a
bare %, say) is a record SD cannot read by its name: list, count and reformat
report it as 'name' invalid name. A name holding a slash, and
. and .., are not found, and SD does not look outside the file's own directory.
dir_dict, in the installation directory, is a ready-made dictionary for a directory file whose records are
plain text. Make the file without a dictionary (or delete.file its dictionary), then set field 3 of its VOC
entry to @sdsys/dir_dict. Besides @id it has three items, each of which asks the operating system about
the record's file: days (days since the record was modified), dtm (the date and time of the last
modification, as 16-10-2026 13:45:02) and owner (the user name that owns it). They work through the
internal function !dirinfo, which reaches only records of a file the caller has open.
SD writes directory file records with CR+LF line endings so that Windows programs can open them. Reading handles CR+LF, LF, and CR on its own.
Dynamic files#
A dynamic file is stored in SD's own binary format. It has a hash-based group structure and resizes automatically as data grows or shrinks.
| On disk | binary files in the account directory |
| Record id | up to MAXIDLEN, which is 63 by default |
| Readable by | SD only |
| Group size | set by GRPSIZE in sd.conf, 4 KB by default (a file keeps the size it was made with) |
| Resizing | automatic, at a load of 80% to grow and 50% to shrink |
Group structure#
A dynamic file is divided into groups. Each group is a bucket holding the
records that hash to it. analyze.file reports the structure of a real file:
:analyze.file zzauditf
Account : /cygdrive/c/Users/you/SDCoreSolo/user_accounts/sduser
File name : zzauditf
Path name : /cygdrive/c/Users/you/SDCoreSolo/user_accounts/sduser/ZZAUDITF
Type : Dynamic, version 2
Group size : 2 (2048 bytes)
Large record size : 1638
Minimum modulus : 1
Current modulus : 1
Load factors : 80 (split), 50 (merge), 0 (current)
File size (bytes) : 6144 (4096 + 2048)
The modulus is the number of groups. A newly created file starts at 1.
It grows one group at a time#
This is the part most worth understanding, because the obvious guess is wrong.
The file does not double. When the load passes the split factor, SD adds one group and redistributes the records of one existing group into it. When the load falls below the merge factor, one group is merged away. The modulus therefore moves by one in either direction and is not a power of two.
Two consequences follow:
| Growth is incremental | there is no pause while a large file is rebuilt, because no resize ever touches more than two groups |
| The cost is spread | a file that grows steadily splits steadily, rather than stalling at each doubling |
minimum modulus is the floor: merging never takes the file below it. Set it
with configure.file when you know a file will refill after being cleared.
Overflow#
When a group holds more data than fits in its primary buffer, further buffers are chained to it. That chain is overflow, and it has to be scanned on every read that lands in that group, so heavy overflow shows up as slow reads.
Overflow is normal in small amounts. It becomes a problem when a group holds records that will not fit however the file is sized — the large record size in the listing above is the threshold at which a record is stored separately instead.
analyze.file reports the distribution; fstat reports read and write
statistics.
The dictionary file#
Every data file has a companion dictionary, named <FILENAME>.DIC in the same
account directory. create.file makes both parts and says so:
:create.file zzauditf
Created DICT part as ZZAUDITF.DIC
Created DATA part as ZZAUDITF
Added default '@ID' record to dictionary
delete.file removes both, and the VOC entry with them. The dictionary defines
the fields for the query processor. See
SD Dictionaries - Structure and
SD Dictionaries - Conversions.
The sub-file structure#
An account directory contains:
<FILENAME> |
the data part (a folder for a directory file, binary for a dynamic one) |
<FILENAME>.DIC |
the dictionary part |
voc |
the account's VOC |
bp |
BASIC source |
bp.out |
the compiled objects |
$hold |
deferred print output |
$svlists |
saved select lists, reached through the VOC name $savedlists |
File analysis#
analyze.file customers
analyze.file customers statistics
fstat customers on
analyze.file |
the file's structure — type, group size, modulus, load factors and size, as shown above. statistics adds the group distribution, a histogram of record lengths and a histogram of group utilization: how many groups use up to 10%, 20% … 100% of their size, and how many are over 100%, which means they have overflow blocks. A group is counted with its overflow blocks, so a heavily overflowed file shows its groups in the last bar. The report stops at each page; answer S to see it all |
fstat |
read and write counts. It is a switch: fstat file on starts collecting, off stops, and fstat alone reports. fstat global covers every file and fstat reset clears the counters |
fstat collects nothing until it is turned on, so a report immediately after
an on is empty rather than wrong.
sdfix, the file check tool (sdfix.exe in the program folder of SD Core Solo for Windows, SDCoreSolo\usr\bin in your user folder; run on a file that nobody has open), has a
-Z option: it walks the groups as -C does and clears the dead space at the
end of each — the bytes after the used part of a block, where a deleted record's old text can still be.
It says Dead space cleared in n block(s), a second run says 0, and no record changes. Clearing makes the
file compress better and stops old text lingering in a backup; it is not needed for the file to work.
Creating and configuring files#
create.file customers
create.file orders directory
create.file dict customers
configure.file customers default
create.file name |
a dynamic file, which is the default. directory makes a directory file instead, and dict creates only the dictionary part |
delete.file name |
removes the data part, the dictionary part and the VOC entry. dict or data removes only one part |
clear.file name |
empties a file, keeping its structure. dict or data selects a part |
configure.file name |
changes group size and load factors. default puts them back |
There is no static file type. The two types are directory and dynamic.
delete.file refuses voc and $acc, and the refusal does not depend on
the case you type them in.