dsda-doom icon indicating copy to clipboard operation
dsda-doom copied to clipboard

Stutter on first playback of sound effect

Open bkoropoff opened this issue 1 year ago • 6 comments

dsda-doom is prone to stuttering when a lump is first accessed, especially if the wad file is on a spinning HDD. This is likely because it memory maps wad files, so data is read from disk just in time as the program accesses the mapped region. This can cause the main thread to hang while the disk spins up/seeks on first access of a lump. Options:

  • Don't use memory mapping
  • Get the OS to prefetch the entire mapping with posix_madvise(..., POSIX_MADV_WILLNEED) or PrefetchVirtualMemory
  • Strategically prefetch just graphics/sound lumps on wad load or map load

bkoropoff avatar Jun 13 '23 03:06 bkoropoff