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

Small tweaks to the LoE #1125

Merged
merged 1 commit into from
Jun 4, 2024
Merged

Small tweaks to the LoE #1125

merged 1 commit into from
Jun 4, 2024

Conversation

Niols
Copy link
Contributor

@Niols Niols commented May 29, 2024

This PR is a cherry pick of the commits of #1119 that make changes to the LoE:

  1. We relax the bound in computeLoEMaxExtra in d32239b. Previously, this function could never return Just 0. This made the LoE stricter than necessary. This is not a big problem but it does not match the modelled behaviour.

  2. Instead of rejecting candidates that fork off the LoE fragment, we now trim them in 3957238. This is again just relaxing the LoE a tiny bit.

  3. We change the helper followsLoEFrag in c6b1d22. It previously had a pre-condition that the anchor of the candidate had to be somewhere on the LoE fragment, but this precondition was regularly violated. The new version does not have this shortcoming.

@Niols Niols added the Genesis PRs related to Genesis testing and implementation label May 29, 2024
@Niols Niols requested a review from facundominguez May 29, 2024 13:08
@Niols
Copy link
Contributor Author

Niols commented May 29, 2024

This force push addresses your two comments (getting rid of the changes that introduce a bug and then fix it, and merging two commits). Additionally, it adds a681653 (from #1119) to what is now bfd27d0.

@Niols Niols changed the title Three fixes to the LoE Fix the LoE May 29, 2024
@Niols Niols changed the title Fix the LoE Small tweaks to the LoE May 29, 2024
followsLoEFrag (LoEEnabled loe) frag =
AF.withinFragmentBounds (AF.headPoint loe) frag
|| AF.withinFragmentBounds (AF.headPoint frag) loe
-> ChainAndLedger blk
Copy link
Member

Choose a reason for hiding this comment

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

We don't actually need the ledger, so maybe just pass in the fragment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is true, but that would actually be more verbose to use in addToCurrentChain and switchToAFork so I'd prefer keeping it like this. Alternatively, to make the use of arguments clear, we could have followsLoEFrag (now trimToLoE) getting only a fragment and then a variation followsLoEFrag' that gets a ChainAndLedger and a diff, turns it into a fragment, and passes it to followsLoEFrag. Only the latter would actually be used in code.

@facundominguez
Copy link
Contributor

facundominguez commented May 29, 2024

I went into the trouble of pruning the generation of candidates instead of trimming.
niols/fix-loe...fd/no-trimming

I find the code easier to understand since there are no subtle interactions between generation and trimming. But Uniform tests are failing still.

For May I propose that we deliver this PR more or less as is, or perhaps without the trimming. Then we can try to polish the code for July by tuning the generation of candidates.

I'll see if the trimming is noticeable in benchmarks. I'm guessing that the intersections could be noticeable in the 1 peer case of syncing, when chain selection dominates execution time.

@Niols
Copy link
Contributor Author

Niols commented May 30, 2024

I went into the trouble of pruning the generation of candidates instead of trimming. niols/fix-loe...fd/no-trimming

I find the code easier to understand since there are no subtle interactions between generation and trimming. But Uniform tests are failing still.

I had the exact same experience when I tried this, although my changes to maximalCandidates were different.

For May I propose that we deliver this PR more or less as is, or perhaps without the trimming. Then we can try to polish the code for July by tuning the generation of candidates.

I think that is wise.

@facundominguez
Copy link
Contributor

There is a small overhead to trimming. But it doesn't seem to delay syncing or not by much in any case.

10 peers, trimming:
trimToLoE:   0.475s  count:  2_443
real 4m5s

10 peers, no trimming:
followsLoEFrag:   0.293s  count:  2_442
real 4m16s

1 peer, trimming:
trimToLoE:  24.728s  count: 5_393
real 8m10s

1 peer, no trimming:
followsLoEFrag:   0.267s  count: 2_436
real  8m10s

@facundominguez facundominguez force-pushed the genesis/milestone-13 branch 5 times, most recently from db11bc1 to 2acc4b3 Compare May 30, 2024 19:23
@Niols
Copy link
Contributor Author

Niols commented May 31, 2024

Bundled everything into one commit and rebased on top of genesis/milestone13.

@Niols Niols force-pushed the niols/fix-loe branch 2 times, most recently from 78c05a2 to 80cf37d Compare June 3, 2024 11:53
This commit brings several LoE-related improvements, namely:

- The precondition of `followsLoEFrag` stipulating that the given
  candidate fragment had to intersect with the LoE fragment was
  often violated in the code, because the candidate fragments were
  anchored at the tip of the selection.

- `followsLoEFrag` used to accept or reject fragments depending on
  whether they were LoE-compliant or not. The new verson trims them
  to their longest LoE-compliant prefix. Following this change,
  `followsLoEFrag` has been renamed to `timToLoE`. It does not filter
  candidates out anymore.

- This last change makes `computeLoEMaxExtra` redundant. We get rid of
  it entirely and clean up the functions `maximalCandidates` and
  `extendWithSuccessors` accordingly.
@Niols Niols merged commit cd032b1 into genesis/milestone-13 Jun 4, 2024
1 of 2 checks passed
@Niols Niols deleted the niols/fix-loe branch June 4, 2024 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Genesis PRs related to Genesis testing and implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants