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

Split function for anti-diff finger tree that is based on heuristics #4269

Merged
merged 3 commits into from
Jan 11, 2023

Conversation

jorisdral
Copy link
Contributor

@jorisdral jorisdral commented Jan 11, 2023

Description

Closes #4268.

We add a splitSized function that computes a split and the corresponding split root measures using a heuristic, which the Sized class provides. One example of a sensible Sized instance would be one that computes the length of a finger tree. We can view the splitSized function as an equivalent function that delegates to splitl and splitr based on the heuristic.

We also perform comparative benchmarks, where we compare the performance of splitl, splitr and splitSized for three scenarios:

  1. splitl's worst-case running time: a split at the end of the finger tree.
  2. splitr's worst-case running time: a split at the start of the finger tree.
  3. A split in the middle of the finger tree.

In scenario 1, splitl performs much better than splitr, which is expected, and splitc performs only slightly worse than splitl. In scenario 2, splitl performs much worse than splitr, which is expected, and splitSized performs only slightly worse than splitr. In Scenario 3, we see nearly identical performance for all three split functions.

Checklist

  • Branch
    • Commit sequence broadly makes sense
    • Commits have useful messages
    • New tests are added if needed and existing tests are updated
    • If this branch changes Consensus and has any consequences for downstream repositories or end users, said changes must be documented in interface-CHANGELOG.md
    • If this branch changes Network and has any consequences for downstream repositories or end users, said changes must be documented in interface-CHANGELOG.md
    • If serialization changes, user-facing consequences (e.g. replay from genesis) are confirmed to be intentional.
  • Pull Request
    • Self-reviewed the diff
    • Useful pull request description at least containing the following information:
      • What does this PR change?
      • Why these changes were needed?
      • How does this affect downstream repositories and/or end-users?
      • Which ticket does this PR close (if any)? If it does, is it linked?
    • Reviewer requested

@jorisdral jorisdral added consensus issues related to ouroboros-consensus technical debt UTxO-HD 📒💽 labels Jan 11, 2023
@jorisdral jorisdral self-assigned this Jan 11, 2023
@jorisdral jorisdral linked an issue Jan 11, 2023 that may be closed by this pull request
Copy link
Contributor

@jasagredo jasagredo left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks!

anti-diff/src/Data/FingerTree/RootMeasured/Strict.hs Outdated Show resolved Hide resolved
Remove an obsolete space

Co-authored-by: Javier Sagredo <javier.sagredo@iohk.io>
@jorisdral jorisdral merged commit 29ea145 into feature/utxo-hd Jan 11, 2023
@jorisdral jorisdral deleted the jdral/4268-improved-anti-diff-splits branch January 11, 2023 14:54
jasagredo pushed a commit that referenced this pull request Jan 18, 2023
…i-diff-splits

Split function for anti-diff finger tree that is based on heuristics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus issues related to ouroboros-consensus technical debt UTxO-HD 📒💽
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improved splits for anti-diff finger trees
2 participants