quakeforge/libs/util
Bill Currie 0ebb0717b0 [zone] Add failing test cases
The tests fail as they exercise how the cache *SHOULD* work rather than
how it does now.

The tests do currently pass for the pending work I've done on the cache
system, but while working on it, I remembered why I reworked cache
allocation...

The essential problem is that sounds are loaded into the cache, which is
fine for synchronous output targets, but has proven to be a minefield
for asynchronous output targets (JACK, ALSA).

The reason for the minefield is the hunk takes priority over the cache,
and is free to move cache blocks around, and *even dispose of them
entirely* in order to satisfy memory allocations from either end of the
hunk. Doing this in an entirely single-threaded process (as DOS Quake
was) is perfectly safe, as the users of the cache just reload the
pointer each time, and bail if it's null (meaning the block has been
freed), or even cause the data to be reloaded if possible (I'm a little
fuzzy on the details for that as I didn't write that code). However, in
multi-threaded code, especially real-time (JACK, possibly ALSA), it's a
recipe for disaster. The 4cab5b90e6 commit was a (mostly) successful
attempt to mitigate the problem by allocating the cache blocks from the
high-hunk (thus minimizing any movement caused by low-hunk allocations),
it resulted in cache allocates and regular high-hunk allocations somehow
getting intertwined: while investigating just how much memory ad_tears
needs (somewhere between 192MB and 256MB), I got "trashed sentinel"
errors and upon investigation, I found what looks very suspiciously like
audio data written across a hunk control block.

I've decided that the cache allocation *algorithm* should be reverted to
how it was originally designed by Id (details will remain "modern"), but
while working on the tests, I remembered why I had done the changes in
the first place (above story). Thus the work on reverting the cache
allocation can't go in until I get sound memory management independent
of the cache. The tests are going in now so I have a constant reminder :)
2022-06-03 12:52:59 +09:00
..
test [zone] Add failing test cases 2022-06-03 12:52:59 +09:00
bsearch.c [util] Add fuzzy and reentrant bsearch 2021-06-01 18:53:53 +09:00
bspfile.c [util] Allow zero-sized lumps to be at end of file 2022-05-26 12:35:50 +09:00
buildnum.c Nuke the rcsid stuff. 2012-04-22 10:56:32 +09:00
cbuf.c Massive whitespace cleanup. 2012-05-22 08:23:22 +09:00
cexpr-lex.l [cexpr] Add optional error message prefix string 2022-04-24 19:15:22 +09:00
cexpr-lib.c [cexpr] Add support for casting plitems 2021-12-24 06:45:13 +09:00
cexpr-parse.y [cexpr] Expose cexpr assignment 2022-04-24 19:15:22 +09:00
cexpr-type.c [cexpr] Allow assignment of double to float 2022-04-24 19:15:22 +09:00
cexpr-vars.c [hash] Rename the publicly visible hashlink_t to hashctx_t 2022-05-12 18:02:01 +09:00
checksum.c Massive whitespace cleanup. 2012-05-22 08:23:22 +09:00
cmd.c [cvar] Make cvars properly typed 2022-04-24 19:15:22 +09:00
cmem.c Fix some null pointer shenanigans 2022-03-31 00:25:22 +09:00
crc.c Nuke the rcsid stuff. 2012-04-22 10:56:32 +09:00
cvar.c [cvar] Plug a pile of memory leaks 2022-05-12 19:58:18 +09:00
dirent.c Massive whitespace cleanup. 2012-05-22 08:23:22 +09:00
dstring.c [build] Autoconfiscate printf format attribute 2021-03-27 19:52:59 +09:00
fendian.c Nuke the rcsid stuff. 2012-04-22 10:56:32 +09:00
fnmatch.c Nuke the rcsid stuff. 2012-04-22 10:56:32 +09:00
getopt.c Massive whitespace cleanup. 2012-05-22 08:23:22 +09:00
getopt1.c Massive whitespace cleanup. 2012-05-22 08:23:22 +09:00
hash.c [hash] Clean up some duplicate code 2022-05-12 18:52:36 +09:00
heapsort.c [util] Add functions for binary heaps 2021-08-02 12:44:08 +09:00
idparse.c Fix incorrect parsing of comments. 2013-01-16 10:31:02 +09:00
info.c [util] Make hunk (optionally) thread-safe 2021-07-29 11:43:27 +09:00
link.c Nuke the rcsid stuff. 2012-04-22 10:56:32 +09:00
llist.c Nuke the rcsid stuff. 2012-04-22 10:56:32 +09:00
Makemodule.am [cexpr] Add a small library with some useful functions 2021-12-24 06:45:12 +09:00
math.S Add GNU-stack notes to assembly files 2021-06-13 10:12:03 -04:00
mathlib.c [model] Move plane info into mnode_t, and visframe out 2022-05-22 12:41:23 +09:00
mdfour.c Clean up after removal of uint32.h 2020-02-29 16:11:07 +09:00
mersenne.c [util] Add mtwist float random number functions 2021-12-24 06:45:13 +09:00
msg.c [util] Write some tests for utf8 r/w 2021-07-27 23:29:14 +09:00
pakfile.c [util] Make hash-tables semi-thread-safe 2020-03-25 15:43:16 +09:00
plist.c [hash] Rename the publicly visible hashlink_t to hashctx_t 2022-05-12 18:02:01 +09:00
plugin.c [plugin] Pull plugin from list before calling its shutdown 2022-05-13 09:50:24 +09:00
qargs.c [cvar] Make cvars properly typed 2022-04-24 19:15:22 +09:00
qendian.c Fix a pile of double semicolons 2021-01-09 20:42:23 +09:00
qsort_r.c [util] Add strndup and reentrant quicksort 2021-03-27 20:03:39 +09:00
quakefs.c [quakefs] Ensure fs_sharepath and fs_userpath are never empty 2022-04-24 19:15:22 +09:00
quakeio.c Remove a redundant va_start/va_end pair. 2016-01-03 18:38:41 +09:00
riff.c Fix a bunch of dead increments. 2018-09-09 11:12:04 +09:00
script.c Make script much friendlier to use 2020-02-26 09:39:03 +09:00
segtext.c [util] Make hash-tables semi-thread-safe 2020-03-25 15:43:16 +09:00
set.c [util] Minimize set growth 2021-08-11 12:31:03 +09:00
simd.c [simd] Split out the ivec implementations 2022-01-02 16:02:57 +09:00
sizebuf.c [util] Make hunk (optionally) thread-safe 2021-07-29 11:43:27 +09:00
string.c [util] Add strndup and reentrant quicksort 2021-03-27 20:03:39 +09:00
sys.c [sys] Add some developer flags for cache/hunk/zone 2022-06-03 12:04:27 +09:00
sys_ia32.S Add GNU-stack notes to assembly files 2021-06-13 10:12:03 -04:00
va.c [util] Make va return const char * 2021-03-29 17:24:30 +09:00
ver_check.c Nuke the rcsid stuff. 2012-04-22 10:56:32 +09:00
wad.c [wad] Return 0 if no wad file is loaded 2022-05-08 23:56:11 +09:00
wadfile.c [util] Make hash-tables semi-thread-safe 2020-03-25 15:43:16 +09:00
zone.c [zone] Add failing test cases 2022-06-03 12:52:59 +09:00