Skip to content

Commit

Permalink
flambda-backend: permanent/default-to-best-fit (cherry-pick 64240fd)
Browse files Browse the repository at this point in the history
Change the default policy to best-fit and space overhead to 100
  • Loading branch information
stedolan authored and poechsel committed Jun 25, 2021
1 parent 2561dd9 commit 00027c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion runtime/caml/config.h
Expand Up @@ -240,7 +240,7 @@ typedef uint64_t uintnat;
/* Default speed setting for the major GC. The heap will grow until
the dead objects and the free list represent this percentage of the
total size of live objects. */
#define Percent_free_def 80
#define Percent_free_def 100

/* Default setting for the compacter: 500%
(i.e. trigger the compacter when 5/6 of the heap is free or garbage)
Expand Down
18 changes: 9 additions & 9 deletions runtime/freelist.c
Expand Up @@ -1754,7 +1754,7 @@ enum {
policy_best_fit = 2,
};

uintnat caml_allocation_policy = policy_next_fit;
uintnat caml_allocation_policy = policy_best_fit;

/********************* exported functions *****************************/

Expand All @@ -1763,25 +1763,25 @@ uintnat caml_allocation_policy = policy_next_fit;
[caml_fl_allocate] returns a head pointer, or NULL if no suitable block
is found in the free set.
*/
header_t *(*caml_fl_p_allocate) (mlsize_t wo_sz) = &nf_allocate;
header_t *(*caml_fl_p_allocate) (mlsize_t wo_sz) = &bf_allocate;

/* Initialize the merge_block machinery (at start of sweeping). */
void (*caml_fl_p_init_merge) (void) = &nf_init_merge;
void (*caml_fl_p_init_merge) (void) = &bf_init_merge;

/* These are called internally. */
static void (*caml_fl_p_init) (void) = &nf_init;
static void (*caml_fl_p_reset) (void) = &nf_reset;
static void (*caml_fl_p_init) (void) = &bf_init;
static void (*caml_fl_p_reset) (void) = &bf_reset;

/* [caml_fl_merge_block] returns the head pointer of the next block after [bp],
because merging blocks may change the size of [bp]. */
header_t *(*caml_fl_p_merge_block) (value bp, char *limit) = &nf_merge_block;
header_t *(*caml_fl_p_merge_block) (value bp, char *limit) = &bf_merge_block;

/* [bp] must point to a list of blocks of wosize >= 1 chained by their field 0,
terminated by Val_NULL, and field 1 of the first block must point to
the last block.
The blocks must be blue.
*/
void (*caml_fl_p_add_blocks) (value bp) = &nf_add_blocks;
void (*caml_fl_p_add_blocks) (value bp) = &bf_add_blocks;

/* Cut a block of memory into pieces of size [Max_wosize], give them headers,
and optionally merge them into the free list.
Expand All @@ -1795,9 +1795,9 @@ void (*caml_fl_p_add_blocks) (value bp) = &nf_add_blocks;
*/
void (*caml_fl_p_make_free_blocks)
(value *p, mlsize_t size, int do_merge, int color)
= &nf_make_free_blocks;
= &bf_make_free_blocks;
#ifdef DEBUG
void (*caml_fl_p_check) (void) = &nf_check;
void (*caml_fl_p_check) (void) = &bf_check;
#endif

void caml_set_allocation_policy (intnat p)
Expand Down

0 comments on commit 00027c4

Please sign in to comment.