Make c0sk flush linger a bit to try and piggyback on a naturally occurring flush to try to avoid creating tiny kvsets...
@@ -1265,6 +1265,32 @@ again:
if (genp) {
*genp = c0kvms_gen_read(old);
c0kvms_ingest_delay_set(old, 0);
+
+ /* Caller intends to wait on this flush to be persisted. To ameliorate
+ * the generation of small kvsets we linger around a bit in hopes of
+ * piggybacking upon a naturally occuring flush. This works well if
+ * the ingest rate is high. If the ingest rate is low it simply
+ * serves to limit the sync frequency to roughly dur_intvl_ms.
+ */
+ if (!self->c0sk_closing) {
+ long waitmax = self->c0sk_kvdb_rp->dur_intvl_ms;
+ long delay = min_t(long, waitmax / 10 + 1, 100);
+
+ while ((waitmax -= delay) > 0) {
+ struct c0_kvmultiset *cur;
+
+ usleep(delay * 1000);
+
+ rcu_read_lock();
+ cur = c0sk_get_first_c0kvms(&self->c0sk_handle);
+ rcu_read_unlock();
+
+ if (cur != old) {
+ c0kvms_putref(old);
+ return 0;
+ }
+ }
+ }
}
err = c0sk_queue_ingest(self, old, new);
