mirror of
https://github.com/Zygo/bees.git
synced 2025-05-18 05:45:45 +02:00
bees: time tmpfile create and copy operations
Add time spent in file create and copy operations to the stats. Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
parent
59660cfc00
commit
f01c20f972
12
src/bees.cc
12
src/bees.cc
@ -426,6 +426,7 @@ BeesTempFile::create()
|
|||||||
BEESNOTE("creating temporary file in " << m_ctx->root_path());
|
BEESNOTE("creating temporary file in " << m_ctx->root_path());
|
||||||
BEESTOOLONG("creating temporary file in " << m_ctx->root_path());
|
BEESTOOLONG("creating temporary file in " << m_ctx->root_path());
|
||||||
|
|
||||||
|
Timer create_timer;
|
||||||
DIE_IF_MINUS_ONE(m_fd = openat(m_ctx->root_fd(), ".", FLAGS_OPEN_TMPFILE, S_IRUSR | S_IWUSR));
|
DIE_IF_MINUS_ONE(m_fd = openat(m_ctx->root_fd(), ".", FLAGS_OPEN_TMPFILE, S_IRUSR | S_IWUSR));
|
||||||
BEESCOUNT(tmp_create);
|
BEESCOUNT(tmp_create);
|
||||||
|
|
||||||
@ -433,6 +434,8 @@ BeesTempFile::create()
|
|||||||
// Resolves won't work there anyway. There are lots of tempfiles
|
// Resolves won't work there anyway. There are lots of tempfiles
|
||||||
// and they're short-lived, so this ends up being just a memory leak
|
// and they're short-lived, so this ends up being just a memory leak
|
||||||
// m_ctx->blacklist_add(BeesFileId(m_fd));
|
// m_ctx->blacklist_add(BeesFileId(m_fd));
|
||||||
|
|
||||||
|
// Put this inode in the cache so we can resolve it later
|
||||||
m_ctx->insert_root_ino(m_fd);
|
m_ctx->insert_root_ino(m_fd);
|
||||||
|
|
||||||
// Set compression attribute
|
// Set compression attribute
|
||||||
@ -445,6 +448,9 @@ BeesTempFile::create()
|
|||||||
|
|
||||||
// Always leave first block empty to avoid creating a file with an inline extent
|
// Always leave first block empty to avoid creating a file with an inline extent
|
||||||
m_end_offset = BLOCK_SIZE_CLONE;
|
m_end_offset = BLOCK_SIZE_CLONE;
|
||||||
|
|
||||||
|
// Count time spent here
|
||||||
|
BEESCOUNTADD(tmp_create_ms, create_timer.age() * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -458,11 +464,15 @@ BeesTempFile::resize(off_t offset)
|
|||||||
THROW_CHECK2(invalid_argument, m_end_offset, offset, m_end_offset < offset);
|
THROW_CHECK2(invalid_argument, m_end_offset, offset, m_end_offset < offset);
|
||||||
|
|
||||||
// Truncate
|
// Truncate
|
||||||
|
Timer resize_timer;
|
||||||
DIE_IF_NON_ZERO(ftruncate(m_fd, offset));
|
DIE_IF_NON_ZERO(ftruncate(m_fd, offset));
|
||||||
BEESCOUNT(tmp_resize);
|
BEESCOUNT(tmp_resize);
|
||||||
|
|
||||||
// Success
|
// Success
|
||||||
m_end_offset = offset;
|
m_end_offset = offset;
|
||||||
|
|
||||||
|
// Count time spent here
|
||||||
|
BEESCOUNTADD(tmp_resize_ms, resize_timer.age() * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
BeesTempFile::BeesTempFile(shared_ptr<BeesContext> ctx) :
|
BeesTempFile::BeesTempFile(shared_ptr<BeesContext> ctx) :
|
||||||
@ -531,6 +541,7 @@ BeesTempFile::make_copy(const BeesFileRange &src)
|
|||||||
auto end = m_end_offset + src.size();
|
auto end = m_end_offset + src.size();
|
||||||
resize(end);
|
resize(end);
|
||||||
|
|
||||||
|
Timer copy_timer;
|
||||||
BeesFileRange rv(m_fd, begin, end);
|
BeesFileRange rv(m_fd, begin, end);
|
||||||
BEESTRACE("copying to: " << rv);
|
BEESTRACE("copying to: " << rv);
|
||||||
BEESNOTE("copying " << src << " to " << rv);
|
BEESNOTE("copying " << src << " to " << rv);
|
||||||
@ -556,6 +567,7 @@ BeesTempFile::make_copy(const BeesFileRange &src)
|
|||||||
src_p += len;
|
src_p += len;
|
||||||
dst_p += len;
|
dst_p += len;
|
||||||
}
|
}
|
||||||
|
BEESCOUNTADD(tmp_copy_ms, copy_timer.age() * 1000);
|
||||||
|
|
||||||
// We seem to get lockups without this!
|
// We seem to get lockups without this!
|
||||||
if (did_block_write) {
|
if (did_block_write) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user