* Lai Jiangshan ([email protected]) wrote: > We can aggressively grow a ht,
What allows us to state that agressive grow is OK ? > but we should conservatively shrink a ht. > > When we try to shrink the ht after a deletion, > but if a growing is required after it, we should > stop this shrink. > > But it is more complicated to implement it, so we use more > conservative strategy to shrink a ht to gain simple code: > > We stop to (lazy) shrink when we found growing is > in progress. > > Signed-off-by: Lai Jiangshan <[email protected]> > --- > rculfhash.c | 29 ++++++++++++++++++++++++++++- > 1 files changed, 28 insertions(+), 1 deletions(-) > > diff --git a/rculfhash.c b/rculfhash.c > index c12ee10..5ff832d 100644 > --- a/rculfhash.c > +++ b/rculfhash.c > @@ -1797,6 +1797,33 @@ void cds_lfht_resize_lazy_count(struct cds_lfht *ht, > unsigned long size, > if (!(ht->flags & CDS_LFHT_AUTO_RESIZE)) > return; > > - resize_target_update_count(ht, count); > + count = max(count, ht->min_alloc_size); > + if (count == size) > + return; > + > + if (count > size) { /* lazy grow */ > + if (resize_target_grow(ht, count) >= count) > + return; > + } else { /* lazy shrink */ > + for (;;) { > + unsigned long s; > + > + s = uatomic_cmpxchg(&ht->t.resize_target, size, count); you could remove the empty lines in this code segment. > + > + if (s == size) > + break; > + > + /* growing is/(was just) in progress */ > + if (s > size) > + return; > + > + /* some other thread do shrink for me*/ missing space above. > + if (s <= count) > + return; Keeping the behavior of size check (change to patch 2) will probably affect this. Thanks, Mathieu > + > + size = s; > + } > + } > + > __cds_lfht_resize_lazy_launch(ht); > } > -- > 1.7.4.4 > -- Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com _______________________________________________ ltt-dev mailing list [email protected] http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
