[Perf] Cache last-call result in perf_dispatch for single-compatible case#438
Merged
hughperkins merged 3 commits intomainfrom Mar 31, 2026
Merged
[Perf] Cache last-call result in perf_dispatch for single-compatible case#438hughperkins merged 3 commits intomainfrom
hughperkins merged 3 commits intomainfrom
Conversation
hughperkins
commented
Mar 31, 2026
| if self._forced_impl is not None: | ||
| return self._forced_impl(*args, **kwargs) | ||
|
|
||
| cached = self._cached_impl |
Collaborator
Author
There was a problem hiding this comment.
just use in the if directly
hughperkins
commented
Mar 31, 2026
c9fef35 to
227c73d
Compare
…case When only one registered implementation is compatible for a given geometry, cache the args/kwargs/impl from the last call. On subsequent calls with the same objects (identity check via `is`), return the cached impl directly, bypassing geometry hash computation, dict lookups, and time.time() checks. Only activates for the single-compatible path; multi-compatible benchmarking with repeat_after_seconds is unaffected. Reduces perf_dispatch overhead from ~9.5 us to ~1.8 us per call, closing the ~13% FPS gap on CPU benchmarks (e.g. franka_random) to ~1.8%.
227c73d to
37e394a
Compare
Collaborator
Author
|
I have read every line added in this PR, and reviewed the lines. I take responsibilty for the lines added and removed in this PR, and won't blame any issues on Opus. |
duburcqa
approved these changes
Mar 31, 2026
hughperkins
commented
Mar 31, 2026
| return self._forced_impl(*args, **kwargs) | ||
|
|
||
| if self._cached_impl is not None: | ||
| ca = self._cached_args |
Collaborator
Author
There was a problem hiding this comment.
can we put ca, ck assign on same line?
86b1fbb to
e01db70
Compare
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.
When only one registered implementation is compatible for a given geometry, cache the args/kwargs/impl from the last call. On subsequent calls with the same objects (identity check via
is), return the cached impl directly, bypassing geometry hash computation, dict lookups, and time.time() checks.Only activates for the single-compatible path; multi-compatible benchmarking with repeat_after_seconds is unaffected.
Reduces perf_dispatch overhead from ~9.5 us to ~1.8 us per call, closing the ~13% FPS gap on CPU benchmarks (e.g. franka_random) to ~1.8%.
Issue: #
Brief Summary
copilot:summary
Walkthrough
copilot:walkthrough