From: Stefan Metzmacher Date: Thu, 30 Jun 2022 10:39:18 +0000 (+0000) Subject: s3:dbwrap_watch: call dbwrap_watched_trigger_wakeup() outside of the low level record... X-Git-Tag: ldb-2.6.1~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5c7e2e27385a4730ff8674650700bd25b77f975;p=thirdparty%2Fsamba.git s3:dbwrap_watch: call dbwrap_watched_trigger_wakeup() outside of the low level record lock This gives a nice speed up, as it's unlikely for the waiters to hit contention. The following test with 256 commections all looping with open/close on the same inode (share root) is improved drastically: smbtorture //127.0.0.1/m -Uroot%test smb2.create.bench-path-contention-shared \ --option='torture:bench_path=' \ --option="torture:timelimit=60" \ --option="torture:nprocs=256" From some like this: open[num/s=8800,avslat=0.021445,minlat=0.000095,maxlat=0.179786] close[num/s=8800,avslat=0.021658,minlat=0.000044,maxlat=0.179819] to: open[num/s=10223,avslat=0.017922,minlat=0.000083,maxlat=0.106759] close[num/s=10223,avslat=0.017694,minlat=0.000040,maxlat=0.107345] BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125 Signed-off-by: Stefan Metzmacher Reviewed-by: Jeremy Allison Reviewed-by: Ralph Boehme Autobuild-User(master): Ralph Böhme Autobuild-Date(master): Tue Jul 26 14:32:35 UTC 2022 on sn-devel-184 --- diff --git a/source3/lib/dbwrap/dbwrap_watch.c b/source3/lib/dbwrap/dbwrap_watch.c index 96eaefc1a41..e5b11aa124e 100644 --- a/source3/lib/dbwrap/dbwrap_watch.c +++ b/source3/lib/dbwrap/dbwrap_watch.c @@ -143,7 +143,6 @@ struct db_watched_ctx { struct db_watched_record { struct db_record *rec; struct server_id self; - struct messaging_context *msg_ctx; struct { struct db_record *rec; TDB_DATA initial_value; @@ -211,6 +210,8 @@ static NTSTATUS dbwrap_watched_storev(struct db_record *rec, const TDB_DATA *dbufs, int num_dbufs, int flags); static NTSTATUS dbwrap_watched_delete(struct db_record *rec); +static void dbwrap_watched_trigger_wakeup(struct messaging_context *msg_ctx, + struct dbwrap_watcher *watcher); static int db_watched_record_destructor(struct db_watched_record *wrec); static void db_watched_record_init(struct db_context *db, @@ -233,7 +234,6 @@ static void db_watched_record_init(struct db_context *db, *wrec = (struct db_watched_record) { .rec = rec, .self = messaging_server_id(msg_ctx), - .msg_ctx = msg_ctx, .backend = { .rec = backend_rec, .initial_value = backend_value, @@ -422,7 +422,13 @@ static void db_watched_record_fini(struct db_watched_record *wrec) static int db_watched_record_destructor(struct db_watched_record *wrec) { + struct db_record *rec = wrec->rec; + struct db_watched_ctx *ctx = talloc_get_type_abort( + rec->db->private_data, struct db_watched_ctx); + db_watched_record_fini(wrec); + TALLOC_FREE(wrec->backend.rec); + dbwrap_watched_trigger_wakeup(ctx->msg, &wrec->wakeup.watcher); return 0; } @@ -480,6 +486,8 @@ static NTSTATUS dbwrap_watched_do_locked(struct db_context *db, TDB_DATA key, DBG_DEBUG("dbwrap_watched_do_locked_fn returned\n"); + dbwrap_watched_trigger_wakeup(state.msg_ctx, &wrec.wakeup.watcher); + return NT_STATUS_OK; } @@ -562,13 +570,6 @@ static void dbwrap_watched_trigger_wakeup(struct messaging_context *msg_ctx, } } -static void dbwrap_watched_record_wakeup( - struct db_watched_record *wrec) -{ - dbwrap_watched_record_prepare_wakeup(wrec); - dbwrap_watched_trigger_wakeup(wrec->msg_ctx, &wrec->wakeup.watcher); -} - static NTSTATUS dbwrap_watched_record_storev( struct db_watched_record *wrec, const TDB_DATA *dbufs, int num_dbufs, int flags) @@ -581,7 +582,7 @@ static NTSTATUS dbwrap_watched_record_storev( NTSTATUS status; size_t add_count = 0; - dbwrap_watched_record_wakeup(wrec); + dbwrap_watched_record_prepare_wakeup(wrec); wrec->backend.initial_valid = false; wrec->force_fini_store = false;