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

[Cable] Use sets instead of arrays to store subscription parameters #129

Merged
merged 1 commit into from
Feb 11, 2025

Conversation

rsamoilov
Copy link
Member

@rsamoilov rsamoilov commented Feb 10, 2025

Arrays were used initially here because they are much more memory efficient than sets. Another reason was that I couldn't reproduce a case where linear complexity searches with include? would become problematic.

However, with the process of synchronizing subscription parameters between worker processes, using include? on arrays has become a problem. With as little as several thousands of unique subscription identifiers, the time to connect can spike to several seconds.

Using sets fixes the issue, and with the number of connections a standard server can handle, the memory difference is negligible.

Arrays were used initially here because they are much more memory efficient than sets. Another reason was that I couldn't reproduce a case where linear complexity searches with `include?` would become problematic.

However, with the process of synchronizing subscription parameters between worker processes, using `include?` on Arrays has become a problem. With as little as several thousands of unique subscription identifiers, the time to connect can spike to several seconds.

Using sets fixes the issue, and with the number of connections a standard server can handle, the memory difference is negligible.
@rsamoilov rsamoilov force-pushed the sets-for-identifiers branch from ae1b3f4 to 6eab03d Compare February 10, 2025 19:29
@rsamoilov rsamoilov changed the title Use sets instead of arrays to store subscription parameters [Cable] Use sets instead of arrays to store subscription parameters Feb 11, 2025
@rsamoilov rsamoilov merged commit 80b10f6 into master Feb 11, 2025
8 checks passed
@rsamoilov rsamoilov deleted the sets-for-identifiers branch February 11, 2025 18:35
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