perf: return TimerSequenceID by value instead of pointer - #11177
Merged
Conversation
Change timer helper functions to return (TimerSequenceID, bool) instead of *TimerSequenceID to avoid heap allocations on every call. Eliminates ~171MB of allocations per 5-minute benchmark run.
prathyushpv
reviewed
Aug 19, 2026
| TimerCreated: timerInfo.TaskStatus == TimerTaskStatusCreated, | ||
| Attempt: 1, | ||
| } | ||
| }, true |
Contributor
There was a problem hiding this comment.
This is always true, so it is fine if we don't return the boolean here.
prathyushpv
approved these changes
Aug 19, 2026
Resolves conflicts with temporalio#11565, which split the activity timer getters into free functions plus thin method wrappers. Both forms now return (TimerSequenceID, bool), and getActivityTimerDeadlines iterates over the getters instead of over their results.
Unlike the activity getters, this one has no early returns, so the bool could never be false and the conditional around the call never filtered anything.
yiminc
approved these changes
Aug 19, 2026
yiminc
enabled auto-merge (squash)
August 19, 2026 03:59
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.
Motivation
TimerSequenceID(~48 bytes) is heap-allocated and returned as a*TimerSequenceIDfrom 5 getter functions:getUserTimerTimeout,getActivityScheduleToStartTimeout,getActivityScheduleToCloseTimeout,getActivityStartToCloseTimeout, andgetActivityHeartbeatTimeout. These are called for every pending timer/activity duringLoadAndSortUserTimers()andLoadAndSortActivityTimers()— a hot path in every workflow task.Callers were already dereferencing the pointer before appending to the value-type
[]TimerSequenceIDslice, so the existing code was allocating on the heap only to immediately copy to the stack.Changes
TimerSequenceIDis now returned by value with a(TimerSequenceID, bool)tupleImpact
Eliminates one heap allocation per getter call on the timer-sorting hot path.
Tests
service/history/workflow(1075 tests): ✅ passed