ab39a8fde9
kiwibd has been used extensively in external benchmarks, it makes sense to make it the default bd for the bench runner: - test_runner - defaults to emubd - more testing features - bench_runner - defaults to kiwibd - lighter-weight disks The benefit of kiwibd is the disk is just one big blob of RAM, so basically no overhead. This is important when benchmarking on multi-GiB disks. emubd is much heavy, but as a tradeoff can do quite a bit more: bad-block simulation, wear simulation, snapshotting, etc. --- In theory the bd used by each runner can be controlled at compile-time by defining -DBENCH_EMUBD, etc, but I have a feeling no one will ever use this.
120 lines
6.4 KiB
C
120 lines
6.4 KiB
C
// littlefs bench runner defines
|
|
|
|
|
|
// preconfigured defines that control how benches run
|
|
#ifdef BENCH_DEFINE
|
|
// name value (overridable)
|
|
BENCH_DEFINE(READ_SIZE, 1 )
|
|
BENCH_DEFINE(PROG_SIZE, 1 )
|
|
BENCH_DEFINE(BLOCK_SIZE, 4096 )
|
|
BENCH_DEFINE(BLOCK_COUNT, DISK_SIZE/BLOCK_SIZE )
|
|
BENCH_DEFINE(DISK_SIZE, 1024*1024 )
|
|
BENCH_DEFINE(BLOCK_RECYCLES, -1 )
|
|
BENCH_DEFINE(RCACHE_SIZE, LFS3_MAX(16, READ_SIZE) )
|
|
BENCH_DEFINE(PCACHE_SIZE, LFS3_MAX(16, PROG_SIZE) )
|
|
BENCH_DEFINE(FCACHE_SIZE, 16 )
|
|
BENCH_DEFINE(LOOKAHEAD_SIZE, 16 )
|
|
BENCH_DEFINE(GC_FLAGS, LFS3_GC_GC )
|
|
BENCH_DEFINE(GC_STEPS, 0 )
|
|
BENCH_DEFINE(GC_LOOKAHEAD_THRESH, -1 )
|
|
BENCH_DEFINE(GC_LOOKGBMAP_THRESH, -1 )
|
|
BENCH_DEFINE(GC_PREERASE_COUNT, -1 )
|
|
BENCH_DEFINE(GC_COMPACT_THRESH, 0 )
|
|
BENCH_DEFINE(SHRUB_SIZE, BLOCK_SIZE/4 )
|
|
BENCH_DEFINE(FRAGMENT_SIZE, LFS3_MIN(BLOCK_SIZE/8, 512) )
|
|
BENCH_DEFINE(CRYSTAL_THRESH, BLOCK_SIZE/8 )
|
|
BENCH_DEFINE(LOOKGBMAP_THRESH, BLOCK_COUNT/4 )
|
|
BENCH_DEFINE(ERASE_VALUE, 0xff )
|
|
// the default timings here are based on NOR flash, specifically
|
|
// w25q64jv:
|
|
//
|
|
// https://www.winbond.com/resource-files/W25Q256JV%20SPI%20RevQ%2002072025%20Plus.pdf
|
|
//
|
|
// note one thing unique to NOR flash is the extreme erase cost
|
|
//
|
|
// FR=104 MHz, quad prog (9.6 ns * 8/4)
|
|
// => +~19 ns for bus (not read!)
|
|
//
|
|
// readed=40ns/B fR=50 MHz, quad read (20 ns * 8/4)
|
|
// progged=1582ns/B tPP=0.4 ms, page=256 (0.4 ms / 256 + bus)
|
|
// erased=10986ns/B tSE=45 ms, sector=4096 (45 ms / 4096)
|
|
//
|
|
// reads=0ns (no transaction cost)
|
|
// progs=400000ns tPP=0.4 ms, page=256
|
|
// erases=45000000ns tSE=45 ms, sector=4096
|
|
// readed=40ns/B fR=50 MHz, quad read (20 ns * 8/4)
|
|
// progged=1484ns/B tPP=0.4 ms (((4096/256)*0.4 ms - 0.4 ms)/4096 + bus)
|
|
// erased=0ns/B (no per-byte cost)
|
|
//
|
|
#ifdef BENCH_SIMPLE
|
|
BENCH_DEFINE(READS_TIMING, 0 )
|
|
BENCH_DEFINE(PROGS_TIMING, 0 )
|
|
BENCH_DEFINE(ERASES_TIMING, 0 )
|
|
BENCH_DEFINE(READED_TIMING, 40 )
|
|
BENCH_DEFINE(PROGGED_TIMING, 1582 )
|
|
BENCH_DEFINE(ERASED_TIMING, 10986 )
|
|
#else
|
|
BENCH_DEFINE(READS_TIMING, 0 )
|
|
BENCH_DEFINE(PROGS_TIMING, 400000 )
|
|
BENCH_DEFINE(ERASES_TIMING, 45000000 )
|
|
BENCH_DEFINE(READED_TIMING, 40 )
|
|
BENCH_DEFINE(PROGGED_TIMING, 1484 )
|
|
BENCH_DEFINE(ERASED_TIMING, 0 )
|
|
#endif
|
|
#ifndef BENCH_KIWIBD
|
|
BENCH_DEFINE(ERASE_CYCLES, 0 )
|
|
BENCH_DEFINE(BADBLOCK_BEHAVIOR, LFS3_EMUBD_BADBLOCK_PROGERROR )
|
|
BENCH_DEFINE(POWERLOSS_BEHAVIOR, LFS3_EMUBD_POWERLOSS_ATOMIC )
|
|
BENCH_DEFINE(BD_SEED, 0 )
|
|
#endif
|
|
#endif
|
|
|
|
|
|
// struct lfs3_cfg fields
|
|
#ifdef BENCH_CFG
|
|
BENCH_CFG(read_size, READ_SIZE )
|
|
BENCH_CFG(prog_size, PROG_SIZE )
|
|
BENCH_CFG(block_size, BLOCK_SIZE )
|
|
BENCH_CFG(block_count, BLOCK_COUNT )
|
|
BENCH_CFG(block_recycles, BLOCK_RECYCLES )
|
|
BENCH_CFG(rcache_size, RCACHE_SIZE )
|
|
BENCH_CFG(pcache_size, PCACHE_SIZE )
|
|
BENCH_CFG(fcache_size, FCACHE_SIZE )
|
|
BENCH_CFG(lookahead_size, LOOKAHEAD_SIZE )
|
|
#ifdef LFS3_GBMAP
|
|
BENCH_CFG(gc_lookgbmap_thresh, GC_LOOKGBMAP_THRESH )
|
|
BENCH_CFG(lookgbmap_thresh, LOOKGBMAP_THRESH )
|
|
#endif
|
|
#ifdef LFS3_PREERASE
|
|
BENCH_CFG(gc_preerase_count, GC_PREERASE_COUNT )
|
|
#endif
|
|
#ifdef LFS3_GC
|
|
BENCH_CFG(gc_flags, GC_FLAGS )
|
|
BENCH_CFG(gc_steps, GC_STEPS )
|
|
#endif
|
|
BENCH_CFG(gc_lookahead_thresh, GC_LOOKAHEAD_THRESH )
|
|
BENCH_CFG(gc_compact_thresh, GC_COMPACT_THRESH )
|
|
BENCH_CFG(shrub_size, SHRUB_SIZE )
|
|
BENCH_CFG(fragment_size, FRAGMENT_SIZE )
|
|
BENCH_CFG(crystal_thresh, CRYSTAL_THRESH )
|
|
#endif
|
|
|
|
|
|
// struct lfs3_*bd_cfg fields
|
|
#ifdef BENCH_BDCFG
|
|
BENCH_BDCFG(erase_value, ERASE_VALUE )
|
|
BENCH_BDCFG(reads_timing, READS_TIMING )
|
|
BENCH_BDCFG(progs_timing, PROGS_TIMING )
|
|
BENCH_BDCFG(erases_timing, ERASES_TIMING )
|
|
BENCH_BDCFG(readed_timing, READED_TIMING )
|
|
BENCH_BDCFG(progged_timing, PROGGED_TIMING )
|
|
BENCH_BDCFG(erased_timing, ERASED_TIMING )
|
|
#ifndef BENCH_KIWIBD
|
|
BENCH_BDCFG(erase_cycles, ERASE_CYCLES )
|
|
BENCH_BDCFG(badblock_behavior, BADBLOCK_BEHAVIOR )
|
|
BENCH_BDCFG(powerloss_behavior, POWERLOSS_BEHAVIOR )
|
|
BENCH_BDCFG(seed, BD_SEED )
|
|
#endif
|
|
#endif
|
|
|