Geom_grow: Move in advancing logic.
This commit is contained in:
parent
131b1b5338
commit
ffe552223c
@ -21,6 +21,33 @@ struct geom_grow_s {
|
|||||||
malloc_mutex_t mtx;
|
malloc_mutex_t mtx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
geom_grow_size_prepare(geom_grow_t *geom_grow, size_t alloc_size_min,
|
||||||
|
size_t *r_alloc_size, pszind_t *r_skip) {
|
||||||
|
*r_skip = 0;
|
||||||
|
*r_alloc_size = sz_pind2sz(geom_grow->next + *r_skip);
|
||||||
|
while (*r_alloc_size < alloc_size_min) {
|
||||||
|
(*r_skip)++;
|
||||||
|
if (geom_grow->next + *r_skip >=
|
||||||
|
sz_psz2ind(SC_LARGE_MAXCLASS)) {
|
||||||
|
/* Outside legal range. */
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
*r_alloc_size = sz_pind2sz(geom_grow->next + *r_skip);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
geom_grow_size_commit(geom_grow_t *geom_grow, pszind_t skip) {
|
||||||
|
if (geom_grow->next + skip + 1 <= geom_grow->limit) {
|
||||||
|
geom_grow->next += skip + 1;
|
||||||
|
} else {
|
||||||
|
geom_grow->next = geom_grow->limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool geom_grow_init(tsdn_t *tsdn, geom_grow_t *geom_grow);
|
bool geom_grow_init(tsdn_t *tsdn, geom_grow_t *geom_grow);
|
||||||
void geom_grow_prefork(tsdn_t *tsdn, geom_grow_t *geom_grow);
|
void geom_grow_prefork(tsdn_t *tsdn, geom_grow_t *geom_grow);
|
||||||
void geom_grow_postfork_parent(tsdn_t *tsdn, geom_grow_t *geom_grow);
|
void geom_grow_postfork_parent(tsdn_t *tsdn, geom_grow_t *geom_grow);
|
||||||
|
20
src/extent.c
20
src/extent.c
@ -625,17 +625,13 @@ extent_grow_retained(tsdn_t *tsdn, pac_t *pac, ehooks_t *ehooks,
|
|||||||
* Find the next extent size in the series that would be large enough to
|
* Find the next extent size in the series that would be large enough to
|
||||||
* satisfy this request.
|
* satisfy this request.
|
||||||
*/
|
*/
|
||||||
pszind_t egn_skip = 0;
|
size_t alloc_size;
|
||||||
size_t alloc_size = sz_pind2sz(pac->geom_grow.next + egn_skip);
|
pszind_t geom_grow_skip;
|
||||||
while (alloc_size < alloc_size_min) {
|
bool err = geom_grow_size_prepare(&pac->geom_grow, alloc_size_min,
|
||||||
egn_skip++;
|
&alloc_size, &geom_grow_skip);
|
||||||
if (pac->geom_grow.next + egn_skip >=
|
if (err) {
|
||||||
sz_psz2ind(SC_LARGE_MAXCLASS)) {
|
|
||||||
/* Outside legal range. */
|
|
||||||
goto label_err;
|
goto label_err;
|
||||||
}
|
}
|
||||||
alloc_size = sz_pind2sz(pac->geom_grow.next + egn_skip);
|
|
||||||
}
|
|
||||||
|
|
||||||
edata_t *edata = edata_cache_get(tsdn, pac->edata_cache);
|
edata_t *edata = edata_cache_get(tsdn, pac->edata_cache);
|
||||||
if (edata == NULL) {
|
if (edata == NULL) {
|
||||||
@ -727,12 +723,8 @@ extent_grow_retained(tsdn_t *tsdn, pac_t *pac, ehooks_t *ehooks,
|
|||||||
* Increment extent_grow_next if doing so wouldn't exceed the allowed
|
* Increment extent_grow_next if doing so wouldn't exceed the allowed
|
||||||
* range.
|
* range.
|
||||||
*/
|
*/
|
||||||
if (pac->geom_grow.next + egn_skip + 1 <= pac->geom_grow.limit) {
|
|
||||||
pac->geom_grow.next += egn_skip + 1;
|
|
||||||
} else {
|
|
||||||
pac->geom_grow.next = pac->geom_grow.limit;
|
|
||||||
}
|
|
||||||
/* All opportunities for failure are past. */
|
/* All opportunities for failure are past. */
|
||||||
|
geom_grow_size_commit(&pac->geom_grow, geom_grow_skip);
|
||||||
malloc_mutex_unlock(tsdn, &pac->geom_grow.mtx);
|
malloc_mutex_unlock(tsdn, &pac->geom_grow.mtx);
|
||||||
|
|
||||||
if (config_prof) {
|
if (config_prof) {
|
||||||
|
Loading…
Reference in New Issue
Block a user