Repository navigation
feat(functions): report execution duration as wall clock in every path - #13754
Merged
Merged
Conversation
ChiragAgg5k
force-pushed
the
feat/execution-duration-wall-clock
branch
from
September 18, 2026 08:59
c1e6ae2 to
ed2e99e
Compare
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
ChiragAgg5k
force-pushed
the
feat/execution-duration-wall-clock
branch
2 times, most recently
from
September 18, 2026 09:01
c148a7c to
378346c
Compare
Contributor
|
ChiragAgg5k
force-pushed
the
feat/execution-duration-wall-clock
branch
from
September 18, 2026 09:06
378346c to
574808b
Compare
`duration` meant two different things depending on how the execution was triggered. A domain-routed request was timed around the whole request, so it included cold start, while the executions API and the async worker stored the executor's own figure, whose timer starts once the runtime is warm. A console execution measured at 6.01s in the browser showed as 311ms in the table. All three paths now store the wall-clock window they already measure. Each one computed it for its failure branch and then threw it away on success; now both branches use it. `testSyncCreateExecution` capped duration at 1.5s, which only held while cold start was excluded. It now bounds the reported duration against the time the caller actually waited, which is the comparison that surfaced the bug in the first place. `testScopes` covers the async worker by comparing its warm execution against the cold one that precedes it. Drops two UTF-8 assertions commented out since 2021, one of them against a response field that has since been renamed. `duration` feeds executions.compute and executions.mbSeconds, so reported compute rises by roughly the cold-start share of traffic.
ChiragAgg5k
force-pushed
the
feat/execution-duration-wall-clock
branch
from
September 18, 2026 09:07
574808b to
b97c779
Compare
…cutions The async assertion compared the queued execution against the cold synchronous one before it, which assumed the worker reuses that same warm runtime. Nothing pins it to one, and the old executor-reported durations could satisfy the same ordering by chance, so it never tested the contract it claimed to. It now bounds the stored duration against the observable window between queueing the execution and seeing it complete.
levivannoort
approved these changes
Sep 18, 2026
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.
What
durationon an execution now means the same thing however the execution was triggered: the total time the caller waited, cold start included.Why
The field meant two different things depending on the path. A domain-routed request was timed around the whole request, so it included cold start. The executions API and the async worker stored the number the executor reports, whose timer starts only once the runtime is warm.
The gap is not small. A Console "Create execution" measured at 6.01s in the browser showed as 311ms in the Executions table — the missing 5.7s was almost entirely cold start, with nothing in the UI to say so. The same function invoked two ways produced non-comparable numbers in the same column, which also affects anything aggregating on
duration.What changed, visually
Same function, same work; the only difference used to be which path you came in
through. A cold-started Console execution reported
311msfor a request thebrowser measured at
6.01s, because everything left ofexecutewas invisible.How
Each of the three paths already measured the wall-clock window — and already used it, but only on the failure branch. On success they discarded it in favour of the executor's figure. Now both branches use the same window:
app/controllers/general.php:709src/Appwrite/Platform/Modules/Functions/Http/Executions/Create.php:496src/Appwrite/Platform/Workers/Functions.php:743In all three, the timer starts immediately before the executor call and after the execution document is written, so no database work is folded in.
This also makes successes and failures consistent with each other. Because the failure branches were already using the wide window, a failed execution was already reported — and billed — on wall clock while a successful one was not.
No new field, no store migration, no response filter:
durationkeeps its name, type and shape, and only its meaning changes.Billing
durationfeedsexecutions.computeandexecutions.mbSeconds, so reported compute rises by the cold-start share of traffic — roughly +11.5% measured across a week of production telemetry. That share is concentrated in a small fraction of executions (about 1% carry a cold start), so it lands hardest, in relative terms, on low-traffic functions whose absolute usage sits inside the free allowance. Projects already paying overage are high-traffic and therefore rarely cold, and should see well under 1%.Worth a changelog note regardless, since it is a silent semantic change to a billed field.
Not in scope
durationdescription changed.Tests
Folded into the tests that already cover these paths rather than adding a new one.
testSyncCreateExecutioncappeddurationat 1.5s — a bound that only held because cold start was excluded, so this change breaks it. It now measures the time the caller actually waited, client-side around the call, and asserts the reported duration tracks it. That is deliberately the same comparison that surfaced the bug: before this change a cold-started request reports a few hundred ms against several seconds of real wait and the assertion fails; after, the two track each other.testFunctionsDomaingets the same check on the domain path, reading the execution back by thex-appwrite-execution-idheader it already asserts on.One existing ceiling is left alone:
testCreateExecutionassertsduration < 10. Cold start now counts toward it, but CI cold starts run well inside that.Pint, PHPStan and the unit tier pass locally. The e2e tests need a running stack.