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

Agency Node Refactor #19312

Merged
merged 76 commits into from
Jul 17, 2023
Merged

Agency Node Refactor #19312

merged 76 commits into from
Jul 17, 2023

Conversation

maierlars
Copy link
Contributor

@maierlars maierlars commented Jun 26, 2023

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:

  1. Spearhead
  2. ReadDB
  3. Supervision Snapshot

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.

Copy link
Member

@neunhoef neunhoef left a 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...

arangod/Agency/Node.h Outdated Show resolved Hide resolved
arangod/Agency/Node.h Outdated Show resolved Hide resolved
arangod/Agency/Node.h Show resolved Hide resolved
//
/// @brief Get node specified by path string
Node& getOrCreate(std::string_view path);
Array const* hasAsArray(std::string const&) const;
Copy link
Member

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.

arangod/Agency/Node.h Outdated Show resolved Hide resolved
Copy link
Member

@neunhoef neunhoef left a 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.

arangod/Agency/NodeLoadInspector.h Outdated Show resolved Hide resolved
arangod/Agency/Store.cpp Show resolved Hide resolved
Copy link
Member

@neunhoef neunhoef left a 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.

Base automatically changed from feature/remove-ttl-and-observe to devel July 17, 2023 19:11
@maierlars maierlars merged commit ad1d269 into devel Jul 17, 2023
@maierlars maierlars deleted the feature/agency-node-refactor branch July 17, 2023 21:10
@KVS85 KVS85 added this to the devel milestone Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants