Skip to content

Commit

Permalink
lib/commit: Add devino_cache_hits to txn stats
Browse files Browse the repository at this point in the history
I found this useful while hacking on rpm-ostree but I think it might be
useful enough to upstream. This stat is really helpful for validating
that a pipeline is hitting the devino cache sweet spot.

Closes: #1772
Approved by: cgwalters
  • Loading branch information
jlebon authored and rh-atomic-bot committed Nov 5, 2018
1 parent 1dcebe8 commit 8eac5be
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/libostree/ostree-repo-commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -3338,6 +3338,9 @@ write_content_to_mtree_internal (OstreeRepo *self,
if (!glnx_shutil_rm_rf_at (dfd_iter->fd, name, cancellable, error))
return FALSE;
}
g_mutex_lock (&self->txn_lock);
self->txn.stats.devino_cache_hits++;
g_mutex_unlock (&self->txn_lock);
return TRUE; /* Early return */
}
}
Expand Down Expand Up @@ -3469,6 +3472,10 @@ write_content_to_mtree_internal (OstreeRepo *self,
if (!ostree_mutable_tree_replace_file (mtree, name, loose_checksum,
error))
return FALSE;

g_mutex_lock (&self->txn_lock);
self->txn.stats.devino_cache_hits++;
g_mutex_unlock (&self->txn_lock);
}
/* Next fast path - we can "adopt" the file */
else if (can_adopt)
Expand Down
3 changes: 2 additions & 1 deletion src/libostree/ostree-repo.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,9 @@ struct _OstreeRepoTransactionStats {
guint content_objects_total;
guint content_objects_written;
guint64 content_bytes_written;
guint devino_cache_hits;

guint64 padding1;
guint padding1;
guint64 padding2;
guint64 padding3;
guint64 padding4;
Expand Down
1 change: 1 addition & 0 deletions src/ostree/ot-builtin-commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
g_print ("Metadata Written: %u\n", stats.metadata_objects_written);
g_print ("Content Total: %u\n", stats.content_objects_total);
g_print ("Content Written: %u\n", stats.content_objects_written);
g_print ("Content Cache Hits: %u\n", stats.devino_cache_hits);
g_print ("Content Bytes Written: %" G_GUINT64_FORMAT "\n", stats.content_bytes_written);
}
else
Expand Down
3 changes: 2 additions & 1 deletion tests/test-basic-user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ assert_file_has_content ls.txt "^-006.. ${newuid} ${newgid} .*/baz/cow"

# But --devino-canonical should override that
$OSTREE commit ${COMMIT_ARGS} --owner-uid ${newuid} --owner-gid ${newgid} \
-I -b test2-devino-test --tree=dir=test2-checkout
-I -b test2-devino-test --table-output --tree=dir=test2-checkout > out.txt
$OSTREE ls test2-devino-test /baz/cow > ls.txt
assert_file_has_content ls.txt "^-006.. ${myuid} ${mygid} .*/baz/cow"
assert_file_has_content out.txt "Content Cache Hits: [1-9][0-9]*"

$OSTREE refs --delete test2-{linkcheckout,devino}-test
echo "ok commit with -I"

0 comments on commit 8eac5be

Please sign in to comment.