mcap/modules/Default_Allocator/version.jai
Musa Mahmood 22cad98500 [0.1.15] Startup: a catalog cache, the catalog on the background threads, rpmalloc, and [startup] timings
The catalog is kept in .catalog-cache in the library, each entry with the size and modified time of
the file it was read from; a start takes the entries whose file is unchanged from it and reads only
the rest. It is saved once the catalog is complete and has changed (at most every 30 s) and at
shutdown. After a reboot the catalog was complete 145 ms after launch, against 3.5 s reading every
file.

The catalog loads on the background Thread_Group, every worker of it, instead of the four preview
workers. rpmalloc (modules/Default_Allocator, 2.0.1-jai.16) takes the place of Jai's single locked
heap: entries from the cache 380 -> 50 ms, and reading the files now scales with threads.
thread_idle is called where workers idle. check_targets.jai checks other OSes with Jai's own
allocator, as rpmalloc runs at compile time with the target's OS layer.

-cold drops the library from the system's file cache first; -no-catalog-cache and -catalog-threads N
are for measuring. [startup] log lines time the listing, the first frame, the cache, the first
preview and the complete catalog.
2026-10-13 07:26:42 +01:00

49 lines
2.3 KiB
Plaintext

// The version of this port, the same for both flavours (rpmalloc2 and Default_Allocator).
//
// VERSION is upstream's version followed by this port's revision. Raise VERSION_REVISION with every
// change to a file that install.jai installs: an installed copy whose revision is lower is behind,
// and install.jai updates it. Raise it here, in VERSION, and in CAPS_VERSION_STRING in module.jai and
// Default_Allocator/module.jai; compile-time asserts fail the build until all four agree. To see what
// an installed copy is, read this file in it, or the CAPS name its allocator reports
// ("rpmalloc 2.0.1-jai.N (Jai port)").
VERSION :: "2.0.1-jai.16";
VERSION_REVISION :: 16;
RPMALLOC_VERSION :: "2.0.1"; // The upstream rpmalloc release this is a port of.
#assert #run version_is(VERSION, RPMALLOC_VERSION, VERSION_REVISION)
"VERSION must be RPMALLOC_VERSION \"-jai.\" VERSION_REVISION";
#scope_module
// For the compile-time version asserts, here and in both module.jai files. #jai not tprint: they run
// as the target's code, and the x64 tprint uses SIMD assembly that a compiler on another CPU cannot
// execute (a Linux x64 build on Apple silicon failed). Plain loops run anywhere, and nothing allocates.
// Is `version` exactly upstream "-jai." revision?
version_is :: (version: string, upstream: string, revision: int) -> bool {
PREFIX :: "-jai.";
if !text_starts(version, 0, upstream) || !text_starts(version, upstream.count, PREFIX) return false;
at := upstream.count + PREFIX.count;
if at >= version.count return false;
n := 0;
for i: at..version.count-1 {
c := version[i];
if c < #char "0" || c > #char "9" return false;
n = n * 10 + (c - #char "0");
}
return n == revision;
}
// Is `text` exactly before, middle, after joined?
text_is :: (text: string, before: string, middle: string, after: string) -> bool {
if text.count != before.count + middle.count + after.count return false;
return text_starts(text, 0, before) && text_starts(text, before.count, middle) && text_starts(text, before.count + middle.count, after);
}
text_starts :: (text: string, at: int, part: string) -> bool {
if at + part.count > text.count return false;
for 0..part.count-1 if text[at + it] != part[it] return false;
return true;
}