Holochain
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # rrDHT Optimize Gossip with Chunks+Fingerprints ###### tags: `Holochain` `dht` `documentation` `specs` ## Assumptions - **Problem 1:** We currently create a bloom filter with size proportional to number of historical DhtOps and exchange it while gossiping. Ideally we would take up less space for older data that is unlikely to change. - **Problem 2:** We create one of these bloom filters for each peer we gossip with, because each peer's DHT Arc has a unique overlap with ours. Ideally we would have less unique overlaps, so that we could re-use computation. - If we align our DHT Arcs along predictable boundaries and split the Arcs into chunks, we can re-use gossip data for a given chunk across each connection that has that as overlap. - If we compute hashes of historical DhtOps for various time ranges, we can gossip those hashes instead of a bloom filter, and in the frequent case where those hashes do not differ between peers, we can save resources. - We want to optimize gossip to accomplish a few main goals: - be easy to maintain (follow a single pattern in a single gossip loop) - minimize overhead in terms of computation and bandwidth - require the most reliable nodes to do be doing the least work (meaning, a node that has been offline knows it is going to have to get updates when it comes on, but nodes that stay on, should only be computing and gossiping new data, never old data with each other) ## Overview ### Chunking - Each node represents their Arc for a given DNA as a Chunk Size and Chunk Count - We require Chunk Size to be rounded to a power of two number of DHT Addresses, rather than a continuous range, so that it changes infrequently. Since there are 2^32 total DHT addresses, nodes can represent their Chunk Size as simply an exponent between 0 and 32. For example, 32 = a chunk is the whole DHT, 31 = a chunk is half the DHT. - We start each Chunk at an absolute multiple of the Chunk Size, rather than at an offset from the agent address, so that they will match those of other agents. ``` Alice's Chunk Size = 1/8 DHT = 2^29 = 536,870,912 Alice's Chunk Count = 3 Alice's Agent Address = 600,000,000 --------------------------------------------------------------------------------- | Chunk 0 | Chunk 1 | Chunk 2 | Chunk 3 | Chunk 4 | Chunk 5 | Chunk 6 | Chunk 7 | --------------------------------------------------------------------------------- ^ Alice's Address <---------|---------|---------> Alice's Arc ``` ### Fingerprinting - When gossiping about a given Chunk, we use a hash-based representation of DhtOps that has higher granularity for recent data and gradually lower time granularity for older more stable data. - This Gossip Fingerprint is a vector of historical hashes, each associated with a time-range, as well as a bloom/vacuum filter associated with the current time-range that is under construction. ```rust struct GossipFingerprint { history: Vec<(GossipHash, TimeWindowSize)>, current_range: BloomFilter, } type GossipHash = Option<[u8; 32]>; // None if there were no DhtOps in the time range type TimeWindowSize = u8; ``` - The `current_range` contains the hashes of DhtOps with timestamps from the last 5 minutes. - At the end of each 5 minute period, we reset `current_range` to be empty, and we append an item to `history`, with a hash determined by - querying the database for all the DhtOps in that time range - sorting them by timestamp - concatenating their DhtOpHashes into a `Vec<u8>` - applying blake2b to the bytes - Once there are three history items with the same TimeWindowSize, we collapse the older two of them into one history item with twice the TimeWindowSize and with a GossipHash that XORs the two child GossipHashes as input. - Since TimeWindowSize is always a power of two times 5 minutes, we represent it as an exponent. - For example ``` time window lengths = [] at t=1 minute after the epoch time window lengths = [5] at t=5 time window lengths = [5, 5] at t=10 time window lengths = [10, 5] at t=15 (from collapsing [5, 5, 5]) time window lengths = [10, 5, 5] at t=20 time window lengths = [10, 10, 5] at t=25 (from collapsing [10, 5, 5, 5]) time window lengths = [10, 10, 5, 5] at t=30 time window lengths = [20, 10, 5] at t=35 (from collapsing [10, 10, 10, 5]) (from collapsing [10, 10, 5, 5, 5]) ``` ``` t=5 1 t=10 1 2 t=15 a /\ 1 2 3 t=20 a /\ 1 2 3 4 t=25 a a /\ / \ 1 2 3 4 5 ... t=40 b / \ a a a /\ / \ / \ 1 2 3 4 5 6 7 ``` - This way, a time window N minutes long ends at least N - 5 minutes ago. - We use a sparse tree representation for historical data so that time periods with no data have NULL values and don't need to be traversed more deeply to know they're empty. ``` Vec<Option<GossipHash>> ``` We can optimize the structure of the fingerprint - - - The amount of time represented by a time window is $5 \cdot 2^d$ minutes where $d$ is the number of times chunks have been combined - - - ### Meeting, 2021-11-30 Can we compute the hashes of spacetime chunks lazily, so that any mismatch in the "currently used" chunks between agents can be reconciled through lazy computation? - We should still have a way to target the same ideal chunk sizes if nodes see similar dht state. - It would be good if the chunks didn't change too frequently to avoid recomputing hashes. #### Metadata hardening Kinda out of scope for gossip at the moment but good to think about a bit. There can be a threshold of time beyond which we just don't gossip chunks that fall in that region of time. - - - Followup, thinking about spacetime trees instead of time trees: https://hackmd.io/R6pV-Af2TFWmKQht8K5XYA Followup to the followup, focusing on a tree in space of trees in time: https://hackmd.io/lsu-Q353S_mPz13E_sfwng

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully