Jun Furuse
    • 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
    --- type: slide slideOptions: theme: white --- <style type="text/css"> .reveal p { text-align: left; } .reveal ul { display: block; } .reveal ol { display: block; } .reveal h1 { text-align: left; font-size: 150%; text-transform: none; } .reveal h2 { text-align: left; font-size: 125%; text-transform: none; } .reveal h3 { text-align: left; font-size: 112%; text-transform: none; } .reveal h4 { text-align: left; font-size: 100%; text-transform: none; } .reveal h5 { text-align: left; font-size: 100%; text-transform: none; } .reveal h6 { text-align: left; font-size: 100%; text-transform: none; } </style> # Snoop benchmark dependency analysis --- ## Benchmark has models These models are called *Aggregated* and have *submodels*. (Micheline pasing/unparsing benchmarks have multiple models.) --- ## The submodel to determine a cost function "Model for codegen": ``` (* ex. Lsl_bytes *) N_ILsl_bytes_const + N_ILsl_bytes_bytes * size1 + N_ILsl_bytes_shift * size2 ``` (This code for `Lsl_bytes` turned to be incorrect.) The most benchmark has another submodel for `Timer_latency`. --- ## Benchmark performs auxiliary computations Their times must be subtracted to infer the parameters for the codegen: * `Timer_latency`: cost of execute a function * `amplification_loop_iteration`: cost of a loop execution * `N_IHalt_const`: cost of `HALT` opcode --- ## Benchmark free variables * Variables in the model for codegen * `N_ILsl_bytes_*`, etc * Variables for the auxiliary computations * `Timer_latency`, `amplification_loop_iteration`, `N_IHalt_const`, etc --- ## Benchmark dependency analysis ### Provided vs dependent A variables of a benchmark must be either * *Provided*: the benchmark fixes its value * otherwise, *Dependent*: provided by another benchmark Provided vs dependent is determined with with some heuristics. See `Dep_graph.Solver.solve`. (We have clear idea about which variables are to be provided or dependent, but Snoop does not.) --- ## Benchmark dependency analysis Topological sort of benchmarks Benchmark $b$ is dependent on benchmark $b'$, when some dependent variables of $b$ are provided by $b'$. --- ## Inference For each benchmark, the values of the provided variables are inferred from: * The workload data of the benchmark * The values of the dependent variables inferred by the inference of the benchmarks providing them. --- ## Ambiguities Variable is *ambiguous* when provided by more than 1 benchmarks. Ambiguities are resolved by heuristics. But the resolution is sometimes different from our intention. ### Proposal Ambiguities should be rejected. Benchmarks and models should be fixed. --- ## Intercept cases Michelson opcode often has 2 benchmarks: * Intercept case: determines the interecept * Non-intercept case: determines the coefficients (Why we need this?) The 2 benchmarks have the same base models: ``` (* ex Add_int *) N_IAdd_int_const + N_IAdd_int_coeff * max size1 size2 ``` --- ## Typical ambiguities #1 Provided/dependent analysis *after the application of workload*. For intercept case, the sizes are fixed to `0` and the above formula is simplified to: ``` (* ex Add_int, intercept case *) N_IAdd_int_const ``` This makes the dependency unambigous: * Intercept case provides `N_IAdd_int_const` * Non-intercept case depends on `N_IAdd_int_const` and provides `N_IAdd_int_coeff` --- ## Typical ambiguities #2 Model formula is complex and variables are not optimized out for intercept cases: ``` (* ex Mul_int *) let a = size1 + size2 in N_IMul_int_coeff * a * log2 (1 + a) + N_IMul_int_const ``` At the intercept, `size1=0` and `size2=0` but the formula is not optimized enough to optimize the coeff variable out: ``` let a = 0 in N_IMul_int_coeff * a * log2 (1 + a) + N_IMul_int_const ``` 3 problems: * Both variables are provided by the intercept case. * The coeff variable can be arbitrarily inferred. * Non-intercept and intercept cases become ambiguous. One is chosen arbitrarily. Possible fix: * Implement `let` expansion at the constant folding when the bound value is a constant. --- ## Typical ambiguities #3 Intercept origin is **not at 0**, which does not coeff variables optimized away: ``` (* ex. Lsl_bytes *) N_ILsl_bytes_const + N_ILsl_bytes_bytes * size1 + N_ILsl_bytes_shift * size2 ``` The intercept point is fixed at `size1=0` and `size2=1`. After the workload application, the intercept model becomes: ``` N_ILsl_bytes_const + N_ILsl_bytes_shift ``` 3 problems: * Both variables are provided by the intercept case. * They are arbitrary inferred. * Non-intercept and intercept cases become ambiguous. One is chosen arbitrarily. See ![](https://gitlab.com/tezos/tezos/uploads/af349c70d35593183e3cff9c48afa9ac/lsl_bytes.dot.png) Possible fix: * Move the intercept point to 0: ``` (* ex. Lsl_bytes *) N_ILsl_bytes_const + N_ILsl_bytes_bytes * size1 + N_ILsl_bytes_shift * (sat_sub size2 - int 1) ``` The graph becomes: ![](https://gitlab.com/tezos/tezos/uploads/5d945e58c29ac8ce5afc9fdf0ff91ff3/lsl_bytes.dot.png) --- ## Other ambiguities Some others out of the above examples. Not checked why they are ambiguous yet. * ISapling_verify_update * N_KMap_enter_body * N_IMap_map * N_KMap_enter_body_singleton * N_KMap_exit_body But all are with `interpreter` local model names. --- ## Conclusion * Benchmark dependency analysis currently accepts ambiguities. * Ambiguities are heuristically resolved (but with a bug at inference). * Ambiguousity may lead to arbitrary inference of parameters including 0 values, which must be avoided. Tentative fix * Ambiguousity should be rejected. * Many ambiguousity can be resolved by fixing the models and benchmakrs. * Few still remain unchecked.

    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