mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-24 00:11:14 +01:00
This reverts commit 708d59a50.
The one-entry per-face cache doesn't help the common case: with a
single plan per face, the plan is already the first node of the list.
When shaping alternates between keys on one face (LTR and RTL, two
scripts, different features), every call misses the slot. That costs
an extra key.equal() before the list walk, then a write to the slot.
From several threads, that write bounces the face's cache line
between them on almost every call. This is the same problem as the
hb_language_from_string() cache from #6549, which is also being
reverted.
A long-lived face with many plans walks the uncapped plan list by
design. If that becomes a real problem, it should be fixed in the
list itself, not with a slot in front of it.
hb_atomic_t<T *>::set_release(), added in #6549 for these caches,
stays.
Testing: meson test -C build: 278 OK.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0c910506de
commit
73e9d5f054
2 files changed
-13
No files matched your search
@@ -71,10 +71,6 @@ struct hb_face_t
|
||||
};
|
||||
#ifndef HB_NO_SHAPER
|
||||
hb_atomic_t<plan_node_t *> shape_plans;
|
||||
/* One-entry cache of the last plan looked up, so repeated shaping with the
|
||||
* same key hits without walking the list. Nodes are never freed before the
|
||||
* face, so a cached pointer stays valid. */
|
||||
hb_atomic_t<plan_node_t *> last_shape_plan;
|
||||
#endif
|
||||
|
||||
hb_blob_t *reference_table (hb_tag_t tag) const
|
||||
|
||||
@@ -567,18 +567,10 @@ retry:
|
||||
shaper_list))
|
||||
return hb_shape_plan_get_empty ();
|
||||
|
||||
hb_face_t::plan_node_t *cached = face->last_shape_plan.get_acquire ();
|
||||
if (cached && cached->shape_plan->key.equal (&key))
|
||||
{
|
||||
DEBUG_MSG_FUNC (SHAPE_PLAN, cached->shape_plan, "fulfilled from last-plan cache");
|
||||
return hb_shape_plan_reference (cached->shape_plan);
|
||||
}
|
||||
|
||||
for (hb_face_t::plan_node_t *node = cached_plan_nodes; node; node = node->next)
|
||||
if (node->shape_plan->key.equal (&key))
|
||||
{
|
||||
DEBUG_MSG_FUNC (SHAPE_PLAN, node->shape_plan, "fulfilled from cache");
|
||||
face->last_shape_plan.set_release (node);
|
||||
return hb_shape_plan_reference (node->shape_plan);
|
||||
}
|
||||
}
|
||||
@@ -605,7 +597,6 @@ retry:
|
||||
goto retry;
|
||||
}
|
||||
DEBUG_MSG_FUNC (SHAPE_PLAN, shape_plan, "inserted into cache");
|
||||
face->last_shape_plan.set_release (node);
|
||||
|
||||
return hb_shape_plan_reference (shape_plan);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user