Skip to content

Optimize lookups with ets pids table#31

Merged
chrismccord merged 1 commit intomasterfrom
cm-optimize
Apr 7, 2016
Merged

Optimize lookups with ets pids table#31
chrismccord merged 1 commit intomasterfrom
cm-optimize

Conversation

@chrismccord
Copy link
Copy Markdown
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
mode: :normal,
values: :ets.new(:values, [:duplicate_bag]),
values: :ets.new(:values, [:ordered_set]),
pids: :ets.new(:pids, [:duplicate_bag]),
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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