Skip to content
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

refactor: optimise object creation & remove spread #265

Merged
merged 2 commits into from
May 28, 2024
Merged

Conversation

tkurki
Copy link
Collaborator

@tkurki tkurki commented Apr 18, 2024

This came up during a recent profiling session: there's a hotspot here, using the spread operator to create a new object.

With server processing an n2k file with the server with "noThrottle": true for the simple stream configuration, multiplexed file playback the baseline throughput was 35k deltas/s and with small change it jumped to 45k deltas/s, so not an insignificant change.

I have not looked into any deeper: does this really need to construct a new object? Or can it just modify the incoming object? All tests pass, but I am really no expert with this codebase, so please have a deeper look.

@tkurki tkurki requested a review from sbender9 April 18, 2024 15:19
@tkurki
Copy link
Collaborator Author

tkurki commented Apr 18, 2024

I pushed another version/commit, this one is clocking around 48k deltas/s. Now the object is copied.

The comment is a little confusing to me: all incoming properties are copied as is, but overridden by the other parameters and added, so not remove or add is not quite accurate for the original functionality.

@sbender9 sbender9 merged commit aa5ff47 into master May 28, 2024
3 checks passed
@sbender9 sbender9 deleted the optimize-spread branch May 28, 2024 15:06
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