Sitelet https://github.com/GoogleCloudPlatform/evalbench/pull/556
Skip to content

perf(viewer): reuse click handlers instead of rebuilding them per render - #556

Open
omkargaikwad23 wants to merge 1 commit into
mainfrom
perf/handler-identity-cache
Open

omkargaikwad23 wants to merge 1 commit into
mainfrom
perf/handler-identity-cache

Conversation

@omkargaikwad23

Copy link
Copy Markdown
Collaborator

Six factories built a fresh closure for every dropdown option on every
render and registered it in globals(). Mesop memoizes handler ids on the
function object itself (compute_fn_id is an unbounded lru_cache), so a new
closure per render meant a permanent entry per render: 300 renders of a
40-option dropdown added 12,000 entries instead of 40.

Hoist the factories to module level and memoize them by value, so the same
option yields the same function object and mesop's table stays flat. The
globals() writes go with them; nothing ever read those names.

Handler name is load-bearing and stays: mesop derives identity from
name plus source, and all handlers from one factory share source, so
without it every option in a dropdown would dispatch to the same value.
Names now carry a short digest of the raw value, since the old sanitizer
mapped "a.b" and "a-b" to one name and silently merged them.


Stack created with GitHub Stacks CLI • Give Feedback 💬

@omkargaikwad23
omkargaikwad23 marked this pull request as ready for review August 10, 2026 04:53
@omkargaikwad23
omkargaikwad23 force-pushed the perf/shared-trends-caches branch from fef7b53 to c2dc17f Compare August 20, 2026 08:12
@omkargaikwad23
omkargaikwad23 force-pushed the perf/handler-identity-cache branch from 0828d08 to 56fc2fd Compare August 20, 2026 08:12
@omkargaikwad23
omkargaikwad23 force-pushed the perf/shared-trends-caches branch from c2dc17f to 6e43752 Compare August 20, 2026 08:23
@omkargaikwad23
omkargaikwad23 force-pushed the perf/handler-identity-cache branch from 56fc2fd to e1936fb Compare August 20, 2026 08:23
@omkargaikwad23
omkargaikwad23 force-pushed the perf/shared-trends-caches branch from 6e43752 to aeac5e4 Compare November 10, 2026 17:25
@omkargaikwad23
omkargaikwad23 force-pushed the perf/handler-identity-cache branch 2 times, most recently from 605bedc to b0ceea5 Compare November 11, 2026 05:46
@omkargaikwad23
omkargaikwad23 force-pushed the perf/shared-trends-caches branch from aeac5e4 to 8c9122e Compare November 11, 2026 05:46
@omkargaikwad23
omkargaikwad23 removed this pull request from stack #562 November 11, 2026 05:46
@omkargaikwad23
omkargaikwad23 changed the base branch from perf/shared-trends-caches to main November 11, 2026 05:46
Six factories built a fresh closure for every dropdown option on every
render and registered it in globals(). Mesop memoizes handler ids on the
function object itself (compute_fn_id is an unbounded lru_cache), so a new
closure per render meant a permanent entry per render: 300 renders of a
40-option dropdown added 12,000 entries instead of 40.

Hoist the factories to module level and memoize them by value, so the same
option yields the same function object and mesop's table stays flat. The
globals() writes go with them; nothing ever read those names.

Handler __name__ is load-bearing and stays: mesop derives identity from
name plus source, and all handlers from one factory share source, so
without it every option in a dropdown would dispatch to the same value.
Names now carry a short digest of the raw value, since the old sanitizer
mapped "a.b" and "a-b" to one name and silently merged them.
@omkargaikwad23
omkargaikwad23 force-pushed the perf/handler-identity-cache branch from b0ceea5 to f1087de Compare November 11, 2026 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant