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

Optimize lookups with ets pids table #31

Merged
merged 1 commit into from
Apr 7, 2016
Merged

Optimize lookups with ets pids table #31

merged 1 commit into from
Apr 7, 2016

Conversation

chrismccord
Copy link
Member

Add pids table for reverse lookup against
values table for efficient matching of
get_by_pid.

Optimize ets select for get_by_topic
by or'ing downed node comparisons.

Add pids table for reverse lookup against
values table for efficient matching of
get_by_pid.

Optimize ets select for get_by_topic
by or'ing downed node comparisons.
@chrismccord chrismccord merged commit da4641c into master Apr 7, 2016
@chrismccord chrismccord deleted the cm-optimize branch April 7, 2016 21:04
@@ -51,7 +54,8 @@ defmodule Phoenix.Tracker.State do
reset_delta(%State{
replica: replica,
mode: :normal,
values: :ets.new(:values, [:duplicate_bag]),
values: :ets.new(:values, [:ordered_set]),
pids: :ets.new(:pids, [:duplicate_bag]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrismccord I know this is an old commit, but do you remember why did you use duplicate bag here instead of just bag which still allows duplicate keys?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate bag will not check for existing keys on insert. It gave us a 10x speedup when we profiled phoenix pubsub back in 2015 for the 2M connection benchmark

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Phoenix channels*. More info on the original PR:
phoenixframework/phoenix#1311

Insertion time is constant for dup bag, where the insertion grows linearly with the bag size for an ordered set. I just realized you are asking :bag vs :duplicate_bag, not vs :ordered_set. I'm not sure of the differences, if any, for bag vs dup bag inserts in the above context.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Thanks

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