Skip to content

perf(propagate): don't increase the stack when there is only one subscriber #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

johnsoncodehk
Copy link
Collaborator

@johnsoncodehk johnsoncodehk commented Nov 25, 2024

Benchmark Results

main branch

benchmark avg min p75 p99 max
propagate: 1 * 1 1.59 µs/iter 1.56 µs 1.61 µs 1.65 µs 1.67 µs
propagate: 10 * 1 14.32 µs/iter 14.23 µs 14.34 µs 14.40 µs 14.47 µs
propagate: 100 * 1 139.54 µs/iter 136.83 µs 138.00 µs 182.58 µs 307.58 µs
propagate: 1 * 10 8.61 µs/iter 8.59 µs 8.62 µs 8.63 µs 8.63 µs
propagate: 10 * 10 84.50 µs/iter 82.92 µs 83.58 µs 109.29 µs 249.54 µs
propagate: 100 * 10 843.57 µs/iter 831.71 µs 837.38 µs 983.25 µs 995.58 µs
propagate: 1 * 100 77.82 µs/iter 76.08 µs 76.96 µs 102.38 µs 241.33 µs
propagate: 10 * 100 767.59 µs/iter 754.83 µs 761.71 µs 913.63 µs 938.08 µs
propagate: 100 * 100 7.67 ms/iter 7.57 ms 7.73 ms 7.80 ms 7.80 ms

This PR

benchmark avg min p75 p99 max
propagate: 1 * 1 1.52 µs/iter 1.50 µs 1.54 µs 1.55 µs 1.56 µs
propagate: 10 * 1 13.89 µs/iter 13.86 µs 13.91 µs 13.92 µs 13.92 µs
propagate: 100 * 1 137.14 µs/iter 134.75 µs 135.92 µs 174.79 µs 296.29 µs
propagate: 1 * 10 8.07 µs/iter 8.06 µs 8.07 µs 8.08 µs 8.09 µs
propagate: 10 * 10 79.17 µs/iter 77.79 µs 78.42 µs 90.38 µs 231.33 µs
propagate: 100 * 10 786.38 µs/iter 775.50 µs 781.67 µs 926.71 µs 951.96 µs
propagate: 1 * 100 72.09 µs/iter 70.67 µs 71.46 µs 82.42 µs 244.08 µs
propagate: 10 * 100 717.08 µs/iter 706.29 µs 712.83 µs 861.29 µs 888.17 µs
propagate: 100 * 100 7.15 ms/iter 7.07 ms 7.21 ms 7.25 ms 7.26 ms

@johnsoncodehk johnsoncodehk merged commit cd05402 into master Nov 25, 2024
6 checks passed
@johnsoncodehk johnsoncodehk deleted the propagate branch November 25, 2024 10:13
@johnsoncodehk
Copy link
Collaborator Author

johnsoncodehk commented Nov 27, 2024

This is a fast path that can only be achieved without using recursion propagate call.

Before this PR, propagate always used stack to fall back to the previous node.

image

In this PR, propagate will only roll back to the previous branch.

image

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