Skip to content

Modify proposervm window #1638

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

Merged
merged 8 commits into from
Jun 28, 2023
Merged

Conversation

najeal
Copy link
Contributor

@najeal najeal commented Jun 20, 2023

Why this should be merged

It resolves the issue #1292

How this works

It replaces the current tip of the window (wall clock time) by a new one: the timestamp of the newest block added in the window.
It reduces the time range of the window from 5 minutes to 2 minutes. (Need to be validated because the issue was not proposing new value).

How this was tested

It was required to change unit tests of the window.

Copy link
Contributor

@StephenButtolph StephenButtolph left a comment

Choose a reason for hiding this comment

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

2 small comments

Copy link
Contributor

Choose a reason for hiding this comment

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

Now that the window is only modified in Add I think we can get away with using a read lock in Oldest and Length.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed lock for the two functions

Comment on lines 116 to 118
// Now we're one second past the ttl of 10 seconds of when [4] was added,
// so all existing elements should be evicted.
clock.Set(epochStart.Add(22 * time.Second))
Copy link
Contributor

@StephenButtolph StephenButtolph Jun 21, 2023

Choose a reason for hiding this comment

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

This statement doesn't seem to do anything anymore - should we remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

@StephenButtolph StephenButtolph added enhancement New feature or request vm This involves virtual machines warp labels Jun 21, 2023
@StephenButtolph StephenButtolph added this to the v1.10.4 milestone Jun 21, 2023
@patrick-ogrady
Copy link
Contributor

patrick-ogrady commented Jun 21, 2023

If we are reopening this code, would it make sense to even keep the time window around if we are capping it at 64/256 back (why not just do 64/256 back always)? I guess in the "average case" we may do less lookbacks with the time bound?

I don't have a "problem" with this, just thinking about how the shortened window could impact stability (how many surges of 64 blocks are there on the P-Chain?).

(this is not necessarily a reflection on this PR but more of a discussion of the original issue)

hexfusion pushed a commit to hexfusion/avalanchego that referenced this pull request Jun 22, 2023
najeal and others added 2 commits June 23, 2023 08:39
Co-authored-by: Stephen Buttolph <stephen@avalabs.org>
Signed-off-by: nathan haim <nathan.haim@free.fr>
@joshua-kim joshua-kim linked an issue Jun 27, 2023 that may be closed by this pull request
Comment on lines -89 to -90
w.lock.Lock()
defer w.lock.Unlock()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we grab the read lock here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The function does not modify the content. The lock was previously used because Oldest and Length were potentially removing content. It was to prevent concurrent update.

Copy link
Contributor

Choose a reason for hiding this comment

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

Though Length and Oldest don't update any values it's possible that another thread will call Add which will result in Length and Oldest having race-y reads

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A change has been pushed 👍 Sorry I thought that this kind of concurrent write/read in our use-case was meaningless.

@StephenButtolph
Copy link
Contributor

I don't have a "problem" with this, just thinking about how the shortened window could impact stability (how many surges of 64 blocks are there on the P-Chain?).

(this is not necessarily a reflection on this PR but more of a discussion of the original issue)

I think the question here is actually more: "how frequently does one node end up accepting a block more than 64 blocks ahead of another node" which is essentially never based on our metrics.

Also remember we don't end up setting the P-chain height to the Oldest value here - we set it to Oldest's parent (aka the most recently evicted value).

@joshua-kim
Copy link
Contributor

Thanks a lot for the change @najeal 🙏

@StephenButtolph StephenButtolph merged commit 1ee4a73 into ava-labs:dev Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request vm This involves virtual machines warp
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Improve ProposerVM Window-er
4 participants