Tweaked SHRUBCOMMIT to infer alloc from block address
Turns out we don't need SHRUBALLOC, as we can infer if we need to reset
the shrub based on if it already exists in our mdir. Not in mdir =>
needs to alloc/reset.
This saves an internal tag and a bit of code:
code stack
before: 33770 2600 (+0.0%)
after: 33746 (-0.1%) 2600 (+0.0%)
This commit is contained in:
@@ -836,9 +836,8 @@ enum lfsr_tag {
|
|||||||
// in-device only tags, these should never get written to disk
|
// in-device only tags, these should never get written to disk
|
||||||
LFSR_TAG_INTERNAL = 0x0800,
|
LFSR_TAG_INTERNAL = 0x0800,
|
||||||
LFSR_TAG_MOVE = 0x0800,
|
LFSR_TAG_MOVE = 0x0800,
|
||||||
LFSR_TAG_SHRUBALLOC = 0x0801,
|
LFSR_TAG_SHRUBCOMMIT = 0x0801,
|
||||||
LFSR_TAG_SHRUBCOMMIT = 0x0802,
|
LFSR_TAG_SHRUBTRUNK = 0x0802,
|
||||||
LFSR_TAG_SHRUBTRUNK = 0x0803,
|
|
||||||
|
|
||||||
// some in-device only tag modifiers
|
// some in-device only tag modifiers
|
||||||
LFSR_TAG_RM = 0x8000,
|
LFSR_TAG_RM = 0x8000,
|
||||||
@@ -6146,7 +6145,7 @@ static int lfsr_mdir_commit__(lfs_t *lfs, lfsr_mdir_t *mdir,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// compact our bshrub
|
// compact our shrub
|
||||||
err = lfsr_shrub_compact(lfs, &rbyd_, &shrub,
|
err = lfsr_shrub_compact(lfs, &rbyd_, &shrub,
|
||||||
&shrub);
|
&shrub);
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -6224,24 +6223,21 @@ static int lfsr_mdir_commit__(lfs_t *lfs, lfsr_mdir_t *mdir,
|
|||||||
|
|
||||||
// shrub tags append a set of attributes to an unrelated trunk
|
// shrub tags append a set of attributes to an unrelated trunk
|
||||||
// in our rbyd
|
// in our rbyd
|
||||||
} else if (attrs[i].tag == LFSR_TAG_SHRUBALLOC
|
} else if (attrs[i].tag == LFSR_TAG_SHRUBCOMMIT) {
|
||||||
|| attrs[i].tag == LFSR_TAG_SHRUBCOMMIT) {
|
const lfsr_shrubcommit_t *shrubcommit = attrs[i].cat;
|
||||||
const lfsr_shrubcommit_t *bshrubcommit = attrs[i].cat;
|
|
||||||
|
|
||||||
// SHRUBALLOC is roughly the same as SHRUBCOMMIT but also
|
// reset shrub if it doesn't live in our block, this happens
|
||||||
// resets the shrub, we need to do this here so bshrub root
|
// when converting from a btree
|
||||||
// extensions are atomic
|
if (shrubcommit->shrub->blocks[0] != rbyd_.blocks[0]) {
|
||||||
if (attrs[i].tag == LFSR_TAG_SHRUBALLOC) {
|
shrubcommit->shrub->blocks[0] = rbyd_.blocks[0];
|
||||||
bshrubcommit->shrub->blocks[0] = rbyd_.blocks[0];
|
shrubcommit->shrub->trunk = LFSR_RBYD_ISSHRUB | 0;
|
||||||
bshrubcommit->shrub->trunk = LFSR_RBYD_ISSHRUB | 0;
|
shrubcommit->shrub->weight = 0;
|
||||||
bshrubcommit->shrub->weight = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// commit to shrub
|
||||||
int err = lfsr_shrub_commit(lfs, &rbyd_,
|
int err = lfsr_shrub_commit(lfs, &rbyd_,
|
||||||
bshrubcommit->shrub,
|
shrubcommit->shrub, shrubcommit->rid,
|
||||||
bshrubcommit->rid,
|
shrubcommit->attrs, shrubcommit->attr_count);
|
||||||
bshrubcommit->attrs,
|
|
||||||
bshrubcommit->attr_count);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@@ -10559,9 +10555,7 @@ static int lfsr_bshrub_commit(lfs_t *lfs, lfsr_file_t *file,
|
|||||||
// commit to shrub
|
// commit to shrub
|
||||||
int err = lfsr_mdir_commit(lfs, &file->o.mdir, LFSR_ATTRS(
|
int err = lfsr_mdir_commit(lfs, &file->o.mdir, LFSR_ATTRS(
|
||||||
LFSR_ATTR_SHRUBCOMMIT(
|
LFSR_ATTR_SHRUBCOMMIT(
|
||||||
(alloc)
|
LFSR_TAG_SHRUBCOMMIT, 0,
|
||||||
? LFSR_TAG_SHRUBALLOC
|
|
||||||
: LFSR_TAG_SHRUBCOMMIT, 0,
|
|
||||||
&file->bshrub_.u.bshrub, bid,
|
&file->bshrub_.u.bshrub, bid,
|
||||||
attrs, attr_count)));
|
attrs, attr_count)));
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user