Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Make presence.get_new_events a bit faster #1876
Conversation
erikjohnston
added some commits
Feb 2, 2017
erikjohnston
assigned
NegativeMjark
Feb 2, 2017
| @@ -280,6 +280,23 @@ def get_rooms_for_user(self, user_id): | ||
| user_id, membership_list=[Membership.JOIN], | ||
| ) | ||
| + @cachedInlineCallbacks(max_entries=50000, cache_context=True, iterable=True) | ||
| + def get_users_who_share_room_with_user(self, user_id, cache_context): |
NegativeMjark
Feb 2, 2017
Contributor
I guess we are leaking the cache_context.invalidate callbacks if this cache is smaller than the get_users_in_room or get_rooms_for_user caches. I wonder if we need a max_entries at all for dependant caches like this one since it can't be bigger than the get_rooms_for_user or get_users_in_room caches.
| @@ -478,6 +478,8 @@ def update_results_dict(res): | ||
| class _CacheContext(namedtuple("_CacheContext", ("cache", "key"))): | ||
| + # We rely on _CacheContext implementing __eq__ and __hash__ sensibly, | ||
| + # which namedtuple does for us. |
NegativeMjark
Feb 2, 2017
•
Contributor
(I'm worried that future me will find this comment and will have forgotten what bit of code relies on these having __eq__ and __hash__ defined "sensibly" or what sensible means in this case)
|
Other than the sightly cryptic comment LGTM. |
erikjohnston commentedFeb 2, 2017
We do this by caching the set of users a user shares rooms with.