-
Notifications
You must be signed in to change notification settings - Fork 838
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
Agency Node Refactor #19312
Agency Node Refactor #19312
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments for Node.h
as a starter. To be continued...
// | ||
/// @brief Get node specified by path string | ||
Node& getOrCreate(std::string_view path); | ||
Array const* hasAsArray(std::string const&) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a code comment here explaining that all hasAs...
methods walk down the tree and then insist that a certain type is at the end. If not (or if the path does not exist), they return nullptr
or a None
option.
…into feature/agency-node-refactor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I seem to have found an old bug. Commenting before the review is done, to allow quick fixing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LVGTM. This PR gives us a substantial improvement in Agency code and also the AgencyCache. The (internal) Node
/Store
API has been cleaned up considerably (without breaking things!). But even more substantial are the internal changes in the data structures of the Agency data. The move to immutable data structures and the corresponding improvements will not only save a huge amount of RAM but also speed up operations considerably. This is a cleanup which was long overdue!
I have not found any serious problems and nearly all minor things have already been addressed.
I did find one bug in the agency triggers which had been there before, and which will be fixed in this PR as well.
Co-authored-by: Max Neunhöffer <max@arangodb.com>
…into feature/agency-node-refactor
…into feature/agency-node-refactor
Scope & Purpose
Refactor agency nodes and prepare them for memory accounting. Instead of mutating nodes in place, we use an immutable representation of the agency. This reduced the memory usage: previously we stored the data three times:
After this change, all three places point to the same node (in the stable case).
Futhermore, the supervision no longer copies the state every run, but just copies a shared pointer.
Finally, read db no longer applies the transactions a second time but instead copies a shared pointer.
And one other thing: for reading you first copy a shared pointer and then immediately release the lock. Previously the lock was held during read.
The part with shared spearhead and readDB will happen in another PR. This PR is already big enough and adding that feature requires more work.