Extended lfsr_ftree_t to include the opened-mdir

Now that bshrubs are limited to files, we might as well lean into it.

Instead of relying on extra traversals through our attr-list, we now
rely on bsprouts/bshrubs always existing in the opened mdir list. This
is a much more robust way to deduplicate bsprout/bshrub compaction
operations. The previous implementation already had a bug since
bsprout/bshrub calculation was forgotten from lfsr_mdir_estimate_.

This is a direct tradeoff of code and RAM. Though note the previous
impl was incomplete and would likely need a bit more code:

            code          stack
  before:  33184           2944
  after:   32980 (-0.6%)   3000 (+1.9%)
This commit is contained in:
Christopher Haster
2023-12-30 14:10:36 -06:00
parent ad522fb619
commit 724eb02cea
2 changed files with 216 additions and 253 deletions
+3 -4
View File
@@ -535,6 +535,8 @@ typedef struct lfsr_bshrub {
// the lfsr_ftree_t struct is a sort of proto-file
typedef struct lfsr_ftree {
lfsr_openedmdir_t *next;
lfsr_mdir_t mdir;
union {
lfs_soff_t size;
lfsr_data_t data;
@@ -547,8 +549,7 @@ typedef struct lfsr_ftree {
} lfsr_ftree_t;
typedef struct lfsr_file {
lfsr_openedmdir_t *next;
lfsr_mdir_t mdir;
lfsr_ftree_t ftree;
uint32_t flags;
lfs_off_t pos;
lfs_off_t size;
@@ -557,8 +558,6 @@ typedef struct lfsr_file {
uint8_t *buffer;
lfs_size_t buffer_size;
lfsr_ftree_t ftree;
const struct lfs_file_config *cfg;
} lfsr_file_t;