Skip to content

perf(time): cache parsed relative time strings - #1052

Merged
bhearsum merged 1 commit into
taskcluster:mainfrom
marco-c:cache_time_strings
Oct 4, 2026
Merged

bhearsum merged 1 commit into
taskcluster:mainfrom
marco-c:cache_time_strings

Conversation

@marco-c

@marco-c marco-c commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

value_of parsed the same few relative time strings ("1 day", "28 days", ...) with a regex every time, although task definitions contain several of them and are resolved multiple times. Its results are timedeltas, which are immutable, so they are now cached.

On a typical task definition, resolve_timestamps takes 16.4us instead of 20.5us.

`value_of` parsed the same few relative time strings ("1 day",
"28 days", ...) with a regex every time, although task definitions
contain several of them and are resolved multiple times. Its results
are timedeltas, which are immutable, so they are now cached.

On a typical task definition, resolve_timestamps takes 16.4us instead of
20.5us.
@marco-c
marco-c requested a review from a team as a code owner September 29, 2026 13:40
@marco-c
marco-c requested a review from hneiva September 29, 2026 13:40

@bhearsum bhearsum left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me wonder if we should have some static built-ins (and a way to add to them maybe?). It seems a little silly to be calculating some of these even once.

In any case, this is a useful improvement.

@bhearsum
bhearsum merged commit 7586e03 into taskcluster:main Oct 4, 2026
22 checks passed
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.

2 participants