From d37f91650709b865329805170daefa8dd0078f91 Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Sun, 29 Jun 2025 23:32:40 -0400 Subject: [PATCH] tempfile: don't need to update the inode if the flags don't change A small performance optimization, given that we are constantly clobbering the file with new content. Signed-off-by: Zygo Blaxell --- src/bees.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/bees.cc b/src/bees.cc index d22fe19..80523a5 100644 --- a/src/bees.cc +++ b/src/bees.cc @@ -509,10 +509,14 @@ BeesTempFile::resize(off_t offset) // and we don't open FS_NOCOW_FL files for dedupe. BEESTRACE("Getting FS_COMPR_FL and FS_NOCOMP_FL on m_fd " << name_fd(m_fd)); int flags = ioctl_iflags_get(m_fd); + const auto orig_flags = flags; + flags |= FS_COMPR_FL; flags &= ~(FS_NOCOMP_FL | FS_NOCOW_FL); - BEESTRACE("Setting FS_COMPR_FL and clearing FS_NOCOMP_FL | FS_NOCOW_FL on m_fd " << name_fd(m_fd) << " flags " << to_hex(flags)); - ioctl_iflags_set(m_fd, flags); + if (flags != orig_flags) { + BEESTRACE("Setting FS_COMPR_FL and clearing FS_NOCOMP_FL | FS_NOCOW_FL on m_fd " << name_fd(m_fd) << " flags " << to_hex(flags)); + ioctl_iflags_set(m_fd, flags); + } // That may have queued some delayed ref deletes, so throttle them bees_throttle(resize_timer.age(), "tmpfile_resize");