From 459071597b3694c9fa5f353e24f8bfd686df1343 Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Thu, 8 Nov 2018 23:06:19 -0500 Subject: [PATCH] fs: make operator<() for search ioctl inline Perf blames this operator for >1% of instructions with -O2, and 70% of instructions without -O2. Let the compiler inline the function. Signed-off-by: Zygo Blaxell --- include/crucible/fs.h | 6 ++++++ lib/fs.cc | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/crucible/fs.h b/include/crucible/fs.h index 79f7e75..05ee5e1 100644 --- a/include/crucible/fs.h +++ b/include/crucible/fs.h @@ -169,6 +169,12 @@ namespace crucible { bool operator<(const BtrfsIoctlSearchHeader &that) const; }; + // Perf blames this function for a few percent overhead; move it here so it can be inline + inline bool BtrfsIoctlSearchHeader::operator<(const BtrfsIoctlSearchHeader &that) const + { + return tie(objectid, type, offset, len, transid) < tie(that.objectid, that.type, that.offset, that.len, that.transid); + } + ostream & operator<<(ostream &os, const btrfs_ioctl_search_header &hdr); ostream & operator<<(ostream &os, const BtrfsIoctlSearchHeader &hdr); diff --git a/lib/fs.cc b/lib/fs.cc index f45b84c..4275f99 100644 --- a/lib/fs.cc +++ b/lib/fs.cc @@ -756,12 +756,6 @@ namespace crucible { return offset + len; } - bool - BtrfsIoctlSearchHeader::operator<(const BtrfsIoctlSearchHeader &that) const - { - return tie(objectid, type, offset, len, transid) < tie(that.objectid, that.type, that.offset, that.len, that.transid); - } - bool BtrfsIoctlSearchKey::do_ioctl_nothrow(int fd) {