Added LFS_REVDBG, tweaked LFS_REVNOISE

This tweaks a number of extended revision count things:

- Added LFS_REVDBG, which adds debug info to revision counts.

  This initializes the bottom 12 bits of every revision count with a
  hint based on rbyd type, which may be useful when debugging:

  - 68 69 21 v0 (hi!.) => mroot anchor
  - 6d 72 7e v0 (mr~.) => mroot
  - 6d 64 7e v0 (md~.) => mdir
  - 62 74 7e v0 (bt~.) => file btree node
  - 62 6d 7e v0 (bm~.) => mtree node

  This may be overwritten by the recycle counter if it overlaps, worst
  case the recycle counter takes up the entire revision count, but these
  have been chosen to at least keep some info if partially overwritten.

  To make this work required the LFS_i_INMTREE hack (yay global state),
  but a hack for debug info isn't the end of the world.

  Note we don't have control over data blocks, so there's always a
  chance they end up containing what looks like one of the above
  revision counts.

- Renamed LFS_NOISY -> LFS_REVNOISE

- LFS_REVDBG and LFS_REVNOISE are incompatible, so using both asserts.

  This also frees up the theoretical 0x00000030 state for an additional
  rev mode in the future.

- Adopted LFS_REVNOISE (and LFS_REVDBG) in btree nodes as well.

  If you need rev noise, you probably want it in all rbyds/metadata
  blocks, not just mdirs.

---

This had no effect on the default code size, but did affect
LFS_REVNOISE:

                    code          stack          ctx
  before:          35688           2440          640
  after:           35688 (+0.0%)   2440 (+0.0%)  640 (+0.0%)

  revnoise before: 35744           2440          640
  revnoise after:  35880 (+0.4%)   2440 (+0.0%)  640 (+0.0%)

  default:         35688           2440          640
  revdbg:          35912 (+0.6%)   2448 (+0.3%)  640 (+0.0%)
  revnoise:        35880 (+0.5%)   2440 (+0.0%)  640 (+0.0%)
This commit is contained in:
Christopher Haster
2025-04-21 13:45:36 -05:00
parent 7cd4c1f12f
commit 96eb38c8c2
6 changed files with 262 additions and 47 deletions
+14 -5
View File
@@ -26,8 +26,11 @@
// LFS_BIGGEST enables all opt-in features
#ifdef LFS_BIGGEST
#ifndef LFS_NOISY
#define LFS_NOISY
#ifndef LFS_REVDBG
#define LFS_REVDBG
#endif
#ifndef LFS_REVNOISE
#define LFS_REVNOISE
#endif
#ifndef LFS_CKPROGS
#define LFS_CKPROGS
@@ -192,10 +195,16 @@ extern "C"
// Some ifdef conveniences
#ifdef LFS_NOISY
#define LFS_IFDEF_NOISY(a, b) (a)
#ifdef LFS_REVDBG
#define LFS_IFDEF_REVDBG(a, b) (a)
#else
#define LFS_IFDEF_NOISY(a, b) (b)
#define LFS_IFDEF_REVDBG(a, b) (b)
#endif
#ifdef LFS_REVNOISE
#define LFS_IFDEF_REVNOISE(a, b) (a)
#else
#define LFS_IFDEF_REVNOISE(a, b) (b)
#endif
#ifdef LFS_CKPROGS