From 76705d10c626a66cc77f3ec294f4f98bef95aeb5 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 14 Jul 2009 18:31:28 +0200 Subject: Consolidate gencache also every 100 writes in a single process --- source3/lib/gencache.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c index 6496ad3ed6..ee1f4b70b3 100644 --- a/source3/lib/gencache.c +++ b/source3/lib/gencache.c @@ -121,6 +121,7 @@ bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob, TDB_DATA databuf; char* val; time_t last_stabilize; + static int writecount; if (tdb_data_cmp(string_term_tdb_data(keystr), last_stabilize_key()) == 0) { @@ -162,6 +163,18 @@ bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob, return false; } + /* + * Every 100 writes within a single process, stabilize the cache with + * a transaction. This is done to prevent a single transaction to + * become huge and chew lots of memory. + */ + writecount += 1; + if (writecount > lp_parm_int(-1, "gencache", "stabilize_count", 100)) { + gencache_stabilize(); + writecount = 0; + goto done; + } + /* * Every 5 minutes, call gencache_stabilize() to not let grow * gencache_notrans.tdb too large. @@ -180,6 +193,7 @@ bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob, gencache_stabilize(); } +done: return ret == 0; } -- cgit