ARROW-2558: [Plasma] avoid walk through all the objects when a client disconnects#2015
Closed
zhijunfu wants to merge 3 commits intoapache:masterfrom
Closed
ARROW-2558: [Plasma] avoid walk through all the objects when a client disconnects#2015zhijunfu wants to merge 3 commits intoapache:masterfrom
zhijunfu wants to merge 3 commits intoapache:masterfrom
Conversation
pcmoritz
reviewed
May 9, 2018
cpp/src/plasma/plasma.h
Outdated
| #endif | ||
| /// Set of clients currently using this object. | ||
| std::unordered_set<Client*> clients; | ||
| /// Reference count. |
Contributor
There was a problem hiding this comment.
Better documentation is: Number of clients currently using this object.
Contributor
Author
There was a problem hiding this comment.
Yes this is indeed better:)
pcmoritz
reviewed
May 9, 2018
cpp/src/plasma/plasma.h
Outdated
| /// Set of clients currently using this object. | ||
| std::unordered_set<Client*> clients; | ||
| /// Reference count. | ||
| int refcnt; |
Contributor
There was a problem hiding this comment.
Let's rename this to ref_count, it's good to be not too cryptic ;)
pcmoritz
reviewed
May 9, 2018
cpp/src/plasma/store.cc
Outdated
| } | ||
| // Add the client pointer to the list of clients using this object. | ||
| entry->clients.insert(client); | ||
| // Increase refcnt. |
Contributor
There was a problem hiding this comment.
// Increase reference count.
pcmoritz
reviewed
May 9, 2018
cpp/src/plasma/store.cc
Outdated
| auto it = client->object_ids.find(entry->object_id); | ||
| if (it != client->object_ids.end()) { | ||
| client->object_ids.erase(it); | ||
| // Decrease refcnt. |
Contributor
There was a problem hiding this comment.
// Decrease reference count.
pcmoritz
reviewed
May 9, 2018
cpp/src/plasma/store.cc
Outdated
| @@ -533,19 +538,25 @@ void PlasmaStore::disconnect_client(int client_fd) { | |||
| // lists. | |||
| // TODO(swang): Avoid iteration through the object table. | |||
Contributor
There was a problem hiding this comment.
can remove the TODO(swang) now
Contributor
Author
|
Comments addressed. Thanks |
Contributor
|
Performance impact: Without this PR: With this PR: So looks like the performance is approximately the same. |
pcmoritz
approved these changes
May 15, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently plasma stores list-of-clients in ObjectTableEntry, which is used to track which clients are using a given object, this serves for two purposes:
A problem with list-of-clients approach is that when a client disconnects, we need to walk through all the objects and remove the client pointer from the list for each object.
Instead, we could add a reference count in ObjectTableEntry, and store list-of-object-ids in client structure. This could both goals that the original approach is targeting, while when a client disconnects, it just walk through its object-ids and dereference each ObjectTableEntry, there's no need to walk through all objects.