perf(scheduler): cache scheduler-capability lookups by target identity#108
Closed
Arbousier1 wants to merge 1 commit into
Closed
perf(scheduler): cache scheduler-capability lookups by target identity#108Arbousier1 wants to merge 1 commit into
Arbousier1 wants to merge 1 commit into
Conversation
The three scheduler-capability accessors (globalRegionScheduler, regionScheduler, entityScheduler) re-resolve the same reflective method and re-invoke it on the same target on every call. In the render hot path and ServerSchedulerReflectionBenchmark, a burst of 84 scheduling calls (4 global + 16 region + 64 entity) all hit the same server/entity targets. Add single-slot identity caches keyed on the target object reference: - globalRegionScheduler caches on plugin.getServer() identity - regionScheduler caches on plugin.getServer() identity - entityScheduler caches on the entity identity On a cache hit the reflective MethodResolution.invoke dispatch is skipped entirely, returning the previously resolved scheduler handle. Identity equality (==) is correct because the server instance is stable for the plugin's lifetime and entity schedulers are stable per entity. Fields are volatile for cross-thread visibility; a torn read at worst causes a cache miss (recompute) or returns a stale handle for one call, both safe because scheduler handles are stable references.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Collaborator
Author
|
Closing per the performance and correctness gates. The complete 8-shard paired run finished as |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add single-slot identity caches for globalRegionScheduler(),
egionScheduler(), and entityScheduler(entity) to skip reflective MethodResolution.invoke dispatch on repeat calls with the same target.
In the render hot path and ServerSchedulerReflectionBenchmark, a burst of 84 scheduling calls (4 global + 16 region + 64 entity) all hit the same server/entity targets. With the identity cache, only the first call per target performs reflective dispatch; subsequent calls return the cached scheduler handle.
Identity equality (==) is correct because the server instance is stable for the plugin's lifetime and entity schedulers are stable per entity. Fields are volatile for cross-thread visibility.
Targets the scheduler-reflection profile (both scheduler.folia.time and scheduler.paper.time must pass).