Skip to content

perf(system): store value instead of version number in Link for dirty check #14

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 2 commits into from
Dec 21, 2024

Conversation

johnsoncodehk
Copy link
Collaborator

@johnsoncodehk johnsoncodehk commented Dec 21, 2024

Use values ​​instead of version number in Link to simplify the algorithm.

Performance improvement is about 2~4.x%. Memory usage has been slightly improved.

master branch

benchmark avg min p75 p99 max
propagate: 1 * 1 1.48 µs/iter 1.47 µs 1.49 µs 1.50 µs 1.51 µs
propagate: 1 * 10 7.77 µs/iter 7.76 µs 7.78 µs 7.79 µs 7.79 µs
propagate: 1 * 100 68.80 µs/iter 67.88 µs 68.75 µs 72.33 µs 96.71 µs
propagate: 10 * 1 13.20 µs/iter 13.19 µs 13.20 µs 13.21 µs 13.21 µs
propagate: 10 * 10 75.89 µs/iter 75.00 µs 75.71 µs 81.42 µs 104.33 µs
propagate: 10 * 100 685.36 µs/iter 680.50 µs 686.17 µs 706.83 µs 726.17 µs
propagate: 100 * 1 130.18 µs/iter 129.00 µs 130.00 µs 135.79 µs 163.08 µs
propagate: 100 * 10 754.27 µs/iter 748.33 µs 754.04 µs 776.04 µs 785.08 µs
propagate: 100 * 100 6.86 ms/iter 6.81 ms 6.88 ms 7.01 ms 7.02 ms

This PR

benchmark avg min p75 p99 max
propagate: 1 * 1 1.45 µs/iter 1.44 µs 1.44 µs 1.50 µs 1.73 µs
propagate: 1 * 10 7.44 µs/iter 7.42 µs 7.44 µs 7.45 µs 7.45 µs
propagate: 1 * 100 65.88 µs/iter 64.92 µs 65.79 µs 71.46 µs 144.25 µs
propagate: 10 * 1 12.93 µs/iter 12.92 µs 12.94 µs 12.94 µs 12.94 µs
propagate: 10 * 10 72.63 µs/iter 71.63 µs 72.29 µs 84.38 µs 255.42 µs
propagate: 10 * 100 655.26 µs/iter 650.33 µs 655.29 µs 695.96 µs 720.38 µs
propagate: 100 * 1 127.43 µs/iter 126.00 µs 126.88 µs 147.54 µs 246.33 µs
propagate: 100 * 10 724.77 µs/iter 715.13 µs 720.13 µs 878.00 µs 1.11 ms
propagate: 100 * 100 6.56 ms/iter 6.51 ms 6.59 ms 6.77 ms 6.83 ms

@medz
Copy link
Contributor

medz commented Dec 21, 2024

@johnsoncodehk Will the performance be reduced when value encounters complex objects? Dynamic languages ​​do not use RuntimeType and memory address judgment like statically compiled languages.

@medz
Copy link
Contributor

medz commented Dec 21, 2024

Additionally, the range of boost seems to be between normal dynamic fluctuations.

@medz
Copy link
Contributor

medz commented Dec 21, 2024

@medz
Copy link
Contributor

medz commented Dec 21, 2024

👍
image
I just wrote a bench for complex objects, and it really improves things.

@johnsoncodehk johnsoncodehk changed the title perf: store value instead of version number in Link for dirty check perf(system): store value instead of version number in Link for dirty check Dec 21, 2024
@johnsoncodehk
Copy link
Collaborator Author

I just wrote a bench for complex objects, and it really improves things.

Thanks for the information, could you open a PR for add this bench?

@johnsoncodehk
Copy link
Collaborator Author

update to >> SubscriberFlags.CanPropagate

That's coincidental, but actually incorrect, consider if SubscriberFlags were as follows:

export const enum SubscriberFlags {
	None = 0,
	Tracking = 1 << 10,
	CanPropagate = 1 << 11,
	RunInnerEffects = 1 << 12,
	ToCheckDirty = 1 << 13,
	Dirty = 1 << 14,
}

The code should be >> 12 instead of >> SubscriberFlags.CanPropagate. (SubscriberFlags.CanPropagate is 4096)

@johnsoncodehk johnsoncodehk merged commit c143457 into master Dec 21, 2024
6 checks passed
@johnsoncodehk johnsoncodehk deleted the deprecated-version branch December 21, 2024 16:44
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