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:
@@ -535,6 +535,8 @@ typedef struct lfsr_bshrub {
|
|||||||
|
|
||||||
// the lfsr_ftree_t struct is a sort of proto-file
|
// the lfsr_ftree_t struct is a sort of proto-file
|
||||||
typedef struct lfsr_ftree {
|
typedef struct lfsr_ftree {
|
||||||
|
lfsr_openedmdir_t *next;
|
||||||
|
lfsr_mdir_t mdir;
|
||||||
union {
|
union {
|
||||||
lfs_soff_t size;
|
lfs_soff_t size;
|
||||||
lfsr_data_t data;
|
lfsr_data_t data;
|
||||||
@@ -547,8 +549,7 @@ typedef struct lfsr_ftree {
|
|||||||
} lfsr_ftree_t;
|
} lfsr_ftree_t;
|
||||||
|
|
||||||
typedef struct lfsr_file {
|
typedef struct lfsr_file {
|
||||||
lfsr_openedmdir_t *next;
|
lfsr_ftree_t ftree;
|
||||||
lfsr_mdir_t mdir;
|
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
lfs_off_t pos;
|
lfs_off_t pos;
|
||||||
lfs_off_t size;
|
lfs_off_t size;
|
||||||
@@ -557,8 +558,6 @@ typedef struct lfsr_file {
|
|||||||
uint8_t *buffer;
|
uint8_t *buffer;
|
||||||
lfs_size_t buffer_size;
|
lfs_size_t buffer_size;
|
||||||
|
|
||||||
lfsr_ftree_t ftree;
|
|
||||||
|
|
||||||
const struct lfs_file_config *cfg;
|
const struct lfs_file_config *cfg;
|
||||||
} lfsr_file_t;
|
} lfsr_file_t;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user