Paul Chiusano
    • Create new note
    • Create a note from template
      • 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
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me 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
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • 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 Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy 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
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me 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
    # Push / Pull / Merge operations __Problem:__ Pushing to base and pulling from base often takes forever, like 8 minutes rather than expected: < 10s. We want to fix this. * Phases of a pull: * __Git fetch:__ Git operation to fetch the latest commit of the remote * __Sync:__ Copy definitions that are present in the source namespace but not present in the destination namespace. * __Merge:__ Merge of the source namespace and the destination namespace (this calls `Causal.before`) * Anything else?? * Phases of a push: * __Git fetch:__ Git operation to fetch the latest commit of the remote (note: this is the same as a `pull`) * __Merge:__ Merge the source namespace and destination namespace. (this calls `Causal.before`) * __Git fetch:__ Apart from a round-trip over the network to the remote git server, this should be a no-op if there are no new commits on the remote since the previous __Git fetch__. * __Verify fast-forward:__ Reject unless it's a fast forward (calls `Causal.before` to check). * __Sync:__ Copy definitions that are present in the source namespace but not present in the destination namespace. * __Git push:__ Git operation to add a local commit and push it to the remote repo. __Scenarios:__ 1. `.> pull git@github.com:unisonweb/base:.trunk base` on an empty repo 2. `.> pull git@github.com:unisonweb/base:.trunk base2` on the same repo as 1 3. Some stuff __Results:__ ### `.> pull <base> .base` in empty repo __base git commit 245f053, 3/11/2020__ |base git commit |245f053|CFI|3c928b7|CFI| |-------- | ----- |---|------ |---| |**date** |**11-Mar** ||**06-May** || |branchFromFiles | 0.03s / 0.03s |0.03s|1.3s / 1.45s || |syncFromDirectory | 4.2s / 4.34s |0.15s|343s / 421s || | --- LoadDependentsDir | |0.02s|343s / 421s || | --- CopyTransitiveDeps| |0.00s|343s / 421s || | --- Copy Dependents Index| |0.00s|343s / 421s || | --- Copy Type Index | |0.03s|343s / 421s || | --- Copy Type Mentions| |0.09s|343s / 421s || |merge branch | 0.42s / 1.61s |0.00s|4.5s / 38.66s|| |propagate default patch | 0.0075s / 0.0075 || .78s / 1.06s|| ### `.> pull <base> .base2` in same (now non-empty) repo |base git commit | 245f053 |3c928b7 | |-------- | ------------- |------------ | |**date** | **11-Mar** |**06-May** | |branchFromFiles | 0.03s / 0.03s |1.53s / 1.82s | |syncFromDirectory | 0.00s / 0.00s |0.00s / 0.00s | |merge branch | 0.39s / 1.03s |3.0s / 4.35s | |propagate default patch | 0.002s / 0.002s | 0.45s / 0.45s| It's interesting that just `branchFromFiles` is so slow. Why is that? * Do some sharing of the sub-branches * Is the slowness just linear slowdown because we're loading 50x more branch files? We think yes, just because lots of tests and docs were added, and new definitions with docs and tests nested underneath. * Idea: try the other syncing method (would improve the syncFromDirectory phase) * Idea: load the sub-branch directly, rather than loading the root (would improve branchFromFiles a bit) * Idea: keep a namespace cache, keyed by hash, use it to preserve sharing (may help with branchFromFiles) * `Util.cache :: (MonadIO m, Ord k) => k -> m v -> m (k -> m v)`, just use this in a few places in `FileCodebase`. For implementation, either a `TVar (Map k v)` or the [concurrent map from `stm-containers`](https://hackage.haskell.org/package/stm-containers-1.1.0.4/docs/StmContainers-Map.html). * Next step may be to prepopulate this cache in the background. * Idea: in the code that syncs a namespace, are we avoiding visiting the same namespace twice? When crawling through history, the same namespace may occur many times. * Idea: in `Causal`, put elements in `m e` rather than `e`. It's kind of a big refactor (or maybe not?) * Along same lines, load a `Causal m ()`, store that in the `Branch` as well, various operations on `Branch` could use the `Causal m ()` spine instead. ### Raw results ``` .> pull https://github.com/aryairani/base-fork .base Finished Git fetch in 0.00608s (cpu), 0.481169s (system) Finished FileCodebase.Common.branchFromFiles in 0.033558s (cpu), 0.034246s (system) Finished FileCodebase.Common.getRootBranch in 0.033868s (cpu), 0.034554s (system) Finished Git fetch (sbh) in 0.0339s (cpu), 0.034587s (system) Finished SyncFromDirectory in 4.210363s (cpu), 4.340794s (system) Finished Merge Branch in 0.424144s (cpu), 1.616646s (system) Finished Propagate Default Patch in 0.0075s (cpu), 0.00751s (system) .> pull https://github.com/aryairani/base-fork .base2 Finished Git fetch in 0.005311s (cpu), 0.496279s (system) Finished FileCodebase.Common.branchFromFiles in 0.033443s (cpu), 0.033981s (system) Finished FileCodebase.Common.getRootBranch in 0.03375s (cpu), 0.034285s (system) Finished Git fetch (sbh) in 0.033784s (cpu), 0.03432s (system) Finished SyncFromDirectory in 0.000128s (cpu), 0.000144s (system) Finished Merge Branch in 0.39215s (cpu), 1.026571s (system) Finished Propagate Default Patch in 0.001895s (cpu), 0.001891s (system) ``` pulling master ``` .> pull https://github.com/unisonweb/base .base Timing Git fetch... Finished Git fetch in 0.007145s (cpu), 1.50681s (system) Timing Git fetch (sbh)... Timing FileCodebase.Common.getRootBranch... Timing FileCodebase.Common.branchFromFiles... Finished FileCodebase.Common.branchFromFiles in 1.291687s (cpu), 1.45078s (system) Finished FileCodebase.Common.getRootBranch in 1.29208s (cpu), 1.451172s (system) Finished Git fetch (sbh) in 1.292109s (cpu), 1.4512s (system) Timing SyncFromDirectory...s into local codebase... Finished SyncFromDirectory in 343.271177s (cpu), 421.425816s (system) Timing Merge Branch... Finished Merge Branch in 4.577604s (cpu), 38.657448s (system) Timing Propagate Default Patch... Finished Propagate Default Patch in 0.780459s (cpu), 1.062506s (system) .> pull https://github.com/unisonweb/base .base2 Timing Git fetch... Finished Git fetch in 0.007562s (cpu), 1.806194s (system) Timing Git fetch (sbh)... Timing FileCodebase.Common.getRootBranch... Timing FileCodebase.Common.branchFromFiles... Finished FileCodebase.Common.branchFromFiles in 1.530779s (cpu), 1.823564s (system) Finished FileCodebase.Common.getRootBranch in 1.531172s (cpu), 1.823964s (system) Finished Git fetch (sbh) in 1.531204s (cpu), 1.823994s (system) Timing SyncFromDirectory...s into local codebase... Finished SyncFromDirectory in 0.000127s (cpu), 0.000133s (system) Timing Merge Branch... Finished Merge Branch in 3.000088s (cpu), 4.35114s (system) Timing Propagate Default Patch... Finished Propagate Default Patch in 0.448015s (cpu), 0.452972s (system) ``` ### Raw Results, with CopyFilterIndex sync base as of march ``` Timing FileCodebase.Common.getRootBranch... Timing FileCodebase.Common.branchFromFiles... Finished FileCodebase.Common.branchFromFiles in 0.000332s (cpu), 0.000337s (system) Finished FileCodebase.Common.getRootBranch in 0.000878s (cpu), 0.000894s (system) ⚙️ Processing stanza 1 of 1.Timing Git fetch... Finished Git fetch in 0.007285s (cpu), 2.045757s (system) Timing Git fetch (sbh)... Timing FileCodebase.Common.getRootBranch... Timing FileCodebase.Common.branchFromFiles... Finished FileCodebase.Common.branchFromFiles in 0.033141s (cpu), 0.078254s (system) Finished FileCodebase.Common.getRootBranch in 0.033336s (cpu), 0.078448s (system) Finished Git fetch (sbh) in 0.033357s (cpu), 0.078472s (system) Timing SyncFromDirectory...s into local codebase... Timing Load Dependents Dir... Finished Load Dependents Dir in 0.023473s (cpu), 0.023509s (system) Timing Copy Transitive Dependencies... Finished Copy Transitive Dependencies in 0.000043s (cpu), 0.000044s (system) Timing Copy Dependents Index... Finished Copy Dependents Index in 0.000077s (cpu), 0.000078s (system) Timing Copy Type Index... Finished Copy Type Index in 0.032337s (cpu), 0.032429s (system) Timing Copy Type Mentions Index... Finished Copy Type Mentions Index in 0.090889s (cpu), 0.091452s (system) Finished SyncFromDirectory in 0.147237s (cpu), 0.147935s (system) Timing Merge Branch... Finished Merge Branch in 0.000224s (cpu), 0.000222s (system) Timing Git fetch... Finished Git fetch in 0.004898s (cpu), 0.593304s (system) Timing Git fetch (sbh)... Timing FileCodebase.Common.getRootBranch... Timing FileCodebase.Common.branchFromFiles... Finished FileCodebase.Common.branchFromFiles in 0.030922s (cpu), 0.031982s (system) Finished FileCodebase.Common.getRootBranch in 0.031356s (cpu), 0.03241s (system) Finished Git fetch (sbh) in 0.031392s (cpu), 0.032447s (system) Timing SyncFromDirectory...s into local codebase... Timing Load Dependents Dir... Finished Load Dependents Dir in 0.046921s (cpu), 0.049333s (system) Timing Copy Transitive Dependencies... Finished Copy Transitive Dependencies in 0.000028s (cpu), 0.000031s (system) Timing Copy Dependents Index... Finished Copy Dependents Index in 0.000181s (cpu), 0.000203s (system) Timing Copy Type Index... Finished Copy Type Index in 0.049949s (cpu), 0.050617s (system) Timing Copy Type Mentions Index... Finished Copy Type Mentions Index in 0.133033s (cpu), 0.138627s (system) Finished SyncFromDirectory in 0.230755s (cpu), 0.239438s (system) Timing Merge Branch... Finished Merge Branch in 0.000165s (cpu), 0.000163s (system) ``` Notes: * Git clone of base takes about 2-3 seconds Speculation of possible issues: * Traversing codebase structure and reserializing * `Causal.before` was super inefficient — have a patch in \<branch TBD\>. * `Causal.merge`'s use of `before a b` followed by `before b a`, is inefficient; it would be good to pursue both tests fairly, in parallel — maybe LCA provides exactly that? * Say you are computing `merge a b`. If: * `lca a b == a` then merge result is `b` * `lca a b == b` then merge result is `a` * `lca a@(merge [a1,a2]) b@(merge [a1,a2,a3])` will be `a1` or `a2`, so it's not equal to `a`, even though `before a b` is true here. * What if LCA returns a set of LCAs, all at the same path length? Then before just checks that... * Seems like need n-way merge * Laws for merge: * `before a (merge a b)` * `before b (merge a b)` * Given `merge a@(merge [a1,a2]) b@(merge [a1,a2,a3])`, could produce: * `merge [a1,a2,a3]` (basically, `b`) * `merge [a1,a2,a3,a]` (make `a` an ancestor of the new merge node) * `merge [a1,a2,b]` (make `b` an ancestor of the new merge node) * `merge [a,b]` (make `a` and `b` ancestors of a new merge node) * Deserializing

    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