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

feat: overlay type definitions and operations #648

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rphmeier
Copy link
Contributor

This defines the Overlay types. I tried to make it passably fast at an algorithmic level and will follow up with integrations!

Copy link
Contributor

@gabriele-0201 gabriele-0201 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modulo some doubts on comments this seems to be a great starting point to manage Overlays. I like the imbl and Map + Vector approach to handle a quick creation and indexing of the overlays!

}

impl Index {
// Prune all items with a sequence number less than the minimum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing "." at the end?

#[derive(Debug, Clone, Copy, PartialEq)]
pub struct InvalidAncestors;

/// A live overlay which is being used as a parent.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used as child maybe?

self.pages_by_seqn.push_front((seqn, key));
break;
}
Some((seqn, key)) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to change key to page_id, less confusing

.filter(|&got_seqn| got_seqn != seqn && got_seqn >= min)
{
// key has been updated since this point. reinsert.
self.pages.insert(key, got_seqn);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, probably related to a copy-paste being the same code as values_by_seqn pruning

//!
//! However, creating a new [`LiveOverlay`] requires the user to provide strong references to each
//! of the ancestors which are still alive. It is still the user's responsibility to ensure
//! that all live ancestors are provided, or else data will go silently missing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I struggle to see how a user can create a chain of Overlay with some missing Overlay, leading to silently miss out on some data. I have a some ideas based on how you envisioned the usage in the follow-up pr.

The user will be able to start a session and update NOMT with an Overlay as an output (first session created, so no overlays are available to be submitted). From now on, new overlays can be created again from the same previous state or on top of fresh new overlays. Each new overlay will contain a vector of weak references to all ancestors, making two things possible:

  1. Upon the creation of LiveOverlay, the provided Overlay iterator is checked against the vector of weak references contained in the parent of the new overlay.
  2. During the commit of an overlay, some logic could be added to ensure that an overlay is not committed twice or that all ancestors have already been committed. Something like storing a vector of all weak references to childs of an overlay could make this possible (modulo some efficiency, I didn't think about yet to this aspect)

That is to say, the comment seems not strictly correct to me, the user will probably be able to not commit an overlay and thus may silently lose some data (but probably this could be solved in some way). However, they will not be able to silently create an overlay on top of a broken chain of overlays, because an error will be thrown as a result.

@pepyakin pepyakin changed the base branch from rh-bitbox-nocopy to graphite-base/648 January 2, 2025 12:33
@pepyakin pepyakin force-pushed the rh-overlay-definition-and-ops branch from 735bb7f to 57178b0 Compare January 2, 2025 12:35
@pepyakin pepyakin changed the base branch from graphite-base/648 to master January 2, 2025 12:36
@pepyakin pepyakin force-pushed the rh-overlay-definition-and-ops branch from 57178b0 to 56e5220 Compare January 2, 2025 12:36
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