Skip to content

test(bench): measure the workflow lifecycle with eviction - #855

Draft
xepozz wants to merge 1 commit into
fix/issue-507-attempt-6from
chore/issue-507-eviction-bench
Draft

xepozz wants to merge 1 commit into
fix/issue-507-attempt-6from
chore/issue-507-eviction-bench

Conversation

@xepozz

@xepozz xepozz commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

Benchmark: eviction cost, master vs fix

See #852

Setup. tests/Benchmark/EvictionBench.php on branch chore/issue-507-eviction-bench. Each rev starts one workflow, sends a signal, and evicts the workflow with DestroyWorkflow. The run uses the unit worker mock (no RoadRunner, no server), PHP 8.5 with opcache and without xdebug, and 3000 revs × 10 iterations. GC runs only when the router or PHP starts it, as in production. The values are the mode in µs per workflow lifecycle.

Pending at eviction master fix Δ
timer 92.4 65.1 −30%
Promise::all of 3 timers 125.7 98.5 −22%
React\Promise\all of 3 timers 122.8 94.6 −23%
nested Workflow::async scopes 172.8 114.1 −34%
then() chain 95.5 65.3 −32%
user Deferred 94.7 53.7 −43%
Workflow::await + signal handler 88.5 59.4 −33%

GC, per 3000 evictions (separate script, only the destroy batch is timed):

master fix
GC runs 36–72 3 (the router's periodic call)
Collector time 28–57 ms 0.1 ms
Garbage that waits for GC 1.1–2.7 MB, 3.6k–8.3k cyclic objects 2 KB, 0
Memory after a forced GC 2 KB 2 KB

Result. On master, each evicted workflow leaves a cycle graph that only the cycle collector can free. The fix frees the workflow at eviction, so a full lifecycle is 22–43% faster. Neither branch has a real leak: a forced GC frees everything on both.

Run: vendor/bin/phpbench run tests/Benchmark/EvictionBench.php --report=aggregate

What was changed

Why?

Checklist

  1. Closes

  2. How was this tested:

  1. Any docs updates needed?

Each rev starts, signals and evicts one workflow. The bench emits ON_FINALLY itself, so it runs on master too.

This branch has not been deployed

No deployments
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.

1 participant