From: Alex Zhuravlev Date: Wed, 18 Dec 2024 12:24:14 +0000 (+0300) Subject: LU-18576 obdclass: do not update llog's timestamp each time X-Git-Tag: 2.16.51~1 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=a648540cc8c36f789516d2a44e9ffc84ec30a87f;p=fs%2Flustre-release.git LU-18576 obdclass: do not update llog's timestamp each time updating llog's timestamp on every record doesn't makes sense as we save seconds and introduces performance penalty (upto 15% in microbenchmark). it should be enough to update it every second. the results, in msec per record inserted: 32K records into a plain llog: mtime update: yes no 1 thread 2421 2137 4 threads 1941 1687 120K records into a catalog: mtime update yes no 1 thread 3007 2765 4 threads 2012 1744 Fixes: e33d196b93 ("LU-17309 llog: set timestamp on llog objects at creation time") Signed-off-by: Alex Zhuravlev Change-Id: I0178ba7071ce39668550b4faa5e1e86397c8a89d Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57510 Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger Reviewed-by: kg.xu Tested-by: jenkins Tested-by: Maloo --- diff --git a/lustre/include/lustre_log.h b/lustre/include/lustre_log.h index f1c5053..392564b 100644 --- a/lustre/include/lustre_log.h +++ b/lustre/include/lustre_log.h @@ -294,6 +294,7 @@ struct llog_handle { int lgh_max_size; bool lgh_destroyed; + unsigned long lgh_timestamp; }; /* llog_osd.c */ diff --git a/lustre/obdclass/llog.c b/lustre/obdclass/llog.c index 10d7748..d6509e0 100644 --- a/lustre/obdclass/llog.c +++ b/lustre/obdclass/llog.c @@ -1321,6 +1321,7 @@ int llog_write(const struct lu_env *env, struct llog_handle *loghandle, struct llog_thread_info *lgi = llog_info(env); bool need_cookie; bool update_attr; + unsigned long timestamp; int rc; ENTRY; @@ -1347,9 +1348,12 @@ int llog_write(const struct lu_env *env, struct llog_handle *loghandle, * size/block needs to be written anyway; 2) update for catalog * since this doesn't happen very often */ - update_attr = (idx == LLOG_NEXT_IDX || - (loghandle->lgh_hdr && - loghandle->lgh_hdr->llh_flags & LLOG_F_IS_CAT)); + timestamp = ktime_get_real_seconds(); + + update_attr = (timestamp != loghandle->lgh_timestamp) && + (idx == LLOG_NEXT_IDX || + (loghandle->lgh_hdr && + loghandle->lgh_hdr->llh_flags & LLOG_F_IS_CAT)); if (update_attr) dt_declare_attr_set(env, loghandle->lgh_obj, NULL, th); @@ -1373,8 +1377,9 @@ int llog_write(const struct lu_env *env, struct llog_handle *loghandle, rc = llog_write_rec(env, loghandle, rec, NULL, idx, th); } if (rc == 0 && update_attr) { + loghandle->lgh_timestamp = timestamp; lgi->lgi_attr.la_valid = LA_MTIME; - lgi->lgi_attr.la_mtime = ktime_get_real_seconds(); + lgi->lgi_attr.la_mtime = timestamp; dt_attr_set(env, loghandle->lgh_obj, &lgi->lgi_attr, th); } diff --git a/lustre/obdclass/llog_cat.c b/lustre/obdclass/llog_cat.c index 3f423df..bb476c5 100644 --- a/lustre/obdclass/llog_cat.c +++ b/lustre/obdclass/llog_cat.c @@ -604,10 +604,13 @@ retry: if (rc == -ENOSPC && llog_is_full(loghandle)) rc = -ENOBUFS; } else { - /* no overhead since inode size needs to be written anyway */ - lgi->lgi_attr.la_valid = LA_MTIME; - lgi->lgi_attr.la_mtime = ktime_get_real_seconds(); - dt_attr_set(env, loghandle->lgh_obj, &lgi->lgi_attr, th); + unsigned long timestamp = ktime_get_real_seconds(); + if (timestamp != loghandle->lgh_timestamp) { + loghandle->lgh_timestamp = timestamp; + lgi->lgi_attr.la_valid = LA_MTIME; + lgi->lgi_attr.la_mtime = timestamp; + dt_attr_set(env, loghandle->lgh_obj, &lgi->lgi_attr, th); + } } up_write(&loghandle->lgh_lock);