tdb: Inline the common part of tdb_oob
authorVolker Lendecke <vl@samba.org>
Sun, 4 Aug 2019 16:26:05 +0000 (18:26 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 6 Aug 2019 21:49:27 +0000 (21:49 +0000)
When you set

in tdbtorture.c to make it more similar to locking.tdb use,

bin/tdbtorture -m -n 1 -l 100000 -s

becomes twice as fast. This is a pretty extreme case, but all other
tests that I did improve significantly as well.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/tdb/common/io.c
lib/tdb/common/tdb_private.h

index 28e808143a2dd966fe9d89411e6eea664207a0e3..0de0dabd82760d6ca29bfedae3595f4e5974bf92 100644 (file)
@@ -667,15 +667,9 @@ int tdb_expand(struct tdb_context *tdb, tdb_off_t size)
        return -1;
 }
 
-int tdb_oob(struct tdb_context *tdb, tdb_off_t off, tdb_len_t len, int probe)
+int _tdb_oob(struct tdb_context *tdb, tdb_off_t off, tdb_len_t len, int probe)
 {
-       int ret;
-
-       if (likely((off + len >= off) && (off + len <= tdb->map_size))) {
-               return 0;
-       }
-
-       ret = tdb->methods->tdb_oob(tdb, off, len, probe);
+       int ret = tdb->methods->tdb_oob(tdb, off, len, probe);
        return ret;
 }
 
index 2bed8200f94aa651a55f0e63625db90277519380..29790434211775649f1772dfeac34c0151db2de2 100644 (file)
@@ -304,7 +304,19 @@ void *tdb_convert(void *buf, uint32_t size);
 int tdb_free(struct tdb_context *tdb, tdb_off_t offset, struct tdb_record *rec);
 tdb_off_t tdb_allocate(struct tdb_context *tdb, int hash, tdb_len_t length,
                       struct tdb_record *rec);
-int tdb_oob(struct tdb_context *tdb, tdb_off_t off, tdb_len_t len, int probe);
+
+int _tdb_oob(struct tdb_context *tdb, tdb_off_t off, tdb_len_t len, int probe);
+
+static inline int tdb_oob(
+       struct tdb_context *tdb, tdb_off_t off, tdb_len_t len, int probe)
+{
+       if (likely((off + len >= off) && (off + len <= tdb->map_size))) {
+               return 0;
+       }
+       return _tdb_oob(tdb, off, len, probe);
+}
+
+
 int tdb_ofs_read(struct tdb_context *tdb, tdb_off_t offset, tdb_off_t *d);
 int tdb_ofs_write(struct tdb_context *tdb, tdb_off_t offset, tdb_off_t *d);
 int tdb_lock_record(struct tdb_context *tdb, tdb_off_t off);