ck_hs: More aggressive clean-up in ck_hs_gc.

* Reset maximum value when doing full scan.
* Reset per-slot bounds to 0 when possible.
ck_pring
Samy Al Bahra 11 years ago
parent a2fa6e8bb3
commit e8969ad66f

@ -501,16 +501,22 @@ ck_hs_gc(struct ck_hs *hs, unsigned long cycles, unsigned long seed)
unsigned long size = 0; unsigned long size = 0;
unsigned long i; unsigned long i;
struct ck_hs_map *map = hs->map; struct ck_hs_map *map = hs->map;
unsigned int maximum = map->probe_maximum; unsigned int maximum;
CK_HS_WORD *bounds = NULL; CK_HS_WORD *bounds = NULL;
if (cycles == 0 && map->probe_bound != NULL) { if (cycles == 0) {
size = sizeof(CK_HS_WORD) * map->capacity; maximum = 0;
bounds = hs->m->malloc(size);
if (bounds == NULL) if (map->probe_bound != NULL) {
return false; size = sizeof(CK_HS_WORD) * map->capacity;
bounds = hs->m->malloc(size);
if (bounds == NULL)
return false;
memset(bounds, 0, size); memset(bounds, 0, size);
}
} else {
maximum = map->probe_maximum;
} }
for (i = 0; i < map->capacity; i++) { for (i = 0; i < map->capacity; i++) {
@ -542,30 +548,32 @@ ck_hs_gc(struct ck_hs *hs, unsigned long cycles, unsigned long seed)
} }
if (cycles == 0) { if (cycles == 0) {
if (n_probes > maximum)
maximum = n_probes;
if (n_probes > CK_HS_WORD_MAX) if (n_probes > CK_HS_WORD_MAX)
n_probes = CK_HS_WORD_MAX; n_probes = CK_HS_WORD_MAX;
if (bounds != NULL && n_probes > bounds[offset]) if (bounds != NULL && n_probes > bounds[offset])
bounds[offset] = n_probes; bounds[offset] = n_probes;
if (n_probes > maximum)
maximum = n_probes;
} else if (--cycles == 0) } else if (--cycles == 0)
break; break;
} }
if (bounds != NULL) { /*
for (i = 0; i < map->capacity; i++) { * The following only apply to garbage collection involving
if (bounds[i] == 0 && map->probe_bound[i] != 0) * a full scan of all entries.
continue; */
if (maximum != map->probe_maximum)
ck_pr_store_uint(&map->probe_maximum, maximum);
if (bounds != NULL) {
for (i = 0; i < map->capacity; i++)
CK_HS_STORE(&map->probe_bound[i], bounds[i]); CK_HS_STORE(&map->probe_bound[i], bounds[i]);
}
hs->m->free(bounds, size, false); hs->m->free(bounds, size, false);
} }
ck_pr_store_uint(&map->probe_maximum, maximum);
return true; return true;
} }

Loading…
Cancel
Save