[repacker] add a maximum number of roots that can be moved in one iteration.
Set to half of the roots in a space. This prevents the repacker from moving all roots in a space to a new space if their are overflows in every root.
This commit is contained in:
parent
02b12d7965
commit
3e4a25098d
|
@ -745,15 +745,6 @@ struct graph_t
|
||||||
return space_for (node.parents[0], root);
|
return space_for (node.parents[0], root);
|
||||||
}
|
}
|
||||||
|
|
||||||
void roots_with_space (unsigned space, hb_set_t* roots) const
|
|
||||||
{
|
|
||||||
for (unsigned i = 0; i < vertices_.length; i++) {
|
|
||||||
if (vertices_[i].space == space) {
|
|
||||||
roots->add (i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void err_other_error () { this->successful = false; }
|
void err_other_error () { this->successful = false; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1104,6 +1095,7 @@ static bool _try_isolating_subgraphs (const hb_vector_t<graph_t::overflow_record
|
||||||
unsigned root;
|
unsigned root;
|
||||||
unsigned overflow_space = sorted_graph.space_for (r.parent, &root);
|
unsigned overflow_space = sorted_graph.space_for (r.parent, &root);
|
||||||
if (!overflow_space) continue;
|
if (!overflow_space) continue;
|
||||||
|
if (sorted_graph.num_roots_for_space (overflow_space) <= 1) continue;
|
||||||
|
|
||||||
if (!space) {
|
if (!space) {
|
||||||
space = overflow_space;
|
space = overflow_space;
|
||||||
|
@ -1115,6 +1107,17 @@ static bool _try_isolating_subgraphs (const hb_vector_t<graph_t::overflow_record
|
||||||
|
|
||||||
if (!roots_to_isolate) return false;
|
if (!roots_to_isolate) return false;
|
||||||
|
|
||||||
|
unsigned maximum_to_move = hb_max ((sorted_graph.num_roots_for_space (space) / 2u), 1u);
|
||||||
|
if (roots_to_isolate.get_population () > maximum_to_move) {
|
||||||
|
// Only move at most half of the roots in a space at a time.
|
||||||
|
unsigned extra = roots_to_isolate.get_population () - maximum_to_move;
|
||||||
|
while (extra--) {
|
||||||
|
unsigned root = HB_SET_VALUE_INVALID;
|
||||||
|
roots_to_isolate.previous (&root);
|
||||||
|
roots_to_isolate.del (root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG_MSG (SUBSET_REPACK, nullptr,
|
DEBUG_MSG (SUBSET_REPACK, nullptr,
|
||||||
"Overflow in space %d (%d roots). Moving %d roots to space %d.",
|
"Overflow in space %d (%d roots). Moving %d roots to space %d.",
|
||||||
space,
|
space,
|
||||||
|
|
Loading…
Reference in New Issue