Iulian Barbu
    • 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
    ### Simulator TODO: create a repo with it with Jan permission, or ask him to upload it ### Results legend - **peak allocation count**: number of live allocations made by the allocator (not deallocated at the moment of counting) during the simulation period - **peak requested space**: space in bytes allocated by the allocator at maximum (while the memory is still in use and not deallocated) - **peak wasted space on padding**: extra bytes required to manage the requested space - **Final allocations**: what remains in terms of number of allocations (without a deallocation counterpart) at the end of the exercise - **Final requested space**: what space is still occupied at the end of the exercise by previous allocations - **Final wasted space on padding**: what space is used for padding/metadata at the end of the exercise by previous allocations - **Extra bytes allocated**: once the simulation is over, we do some random trials of filling up the rest of the allocator heap, given the space left after all alloc/dealloc sequence is over. We can't tell exactly how much extra bytes could be allocated at the end because that space depends on the size of the allocation, which corresponds to some extra padding. - **Physical memory used**: number of pages touched in physical memory * regular page size (4096) - which is the physical space in RAM consumed by the simulation, measured at the end of it. We compute this by looking into `/proc/self/pagemap`, which contains 64 bits for each virtual page. Bit 63 says if the virtual page is present in RAM. ### Allocation patterns on AHP 1. Used #9363 to build `polkadot-parachain` and start an AHP full node (with `-lruntime_host_allocator=debug`, which based on some later exercises in non-AHP context, might increase the allocations/deallocations sequence artificially to some extent). I used `polkadot-stable2506` branch and same commits. 2. Extracted both relaychain & parachain allocation logs. 3. I used a simulator from @koute (code should follow in a repo soon), updated to read trough a file with many host allocations for AHP runtime, from a full node which runs for an hour, synced to the tip at that time. #### asset-hub-polkadot parachain allocation patterns *Runtime: 6e20bc52aaaafd1de82ba7d2a3c0fa39193787e240b93608489cf72a4c46a584* (this is the current on chain runtime on AHP) ``` Running with allocator: legacy Peak allocation count: 5586 Peak requested space: 25214682 Peak wasted space on padding: 6788230 Final allocations (that were not yet deallocated): 4393 Final requested space (unallocated space): 25045617 Final wasted space on padding: 6693135 Physical memory used: 31035392 Bump allocator stats: AllocationStats { bytes_allocated: 31773896, bytes_allocated_peak: 32044136, bytes_allocated_sum: 571192664, address_space_used: 32248168 } Extra bytes allocated: 378385375 Running with allocator: new Peak allocation count: 5586 Peak requested space: 25214682 Peak wasted space on padding: 89283 Final allocations (that were not yet deallocated): 4393 Final requested space (unallocated space): 25045617 Final wasted space on padding: 68911 Physical memory used: 25538560 Bump allocator stats: AllocationStats { bytes_allocated: 0, bytes_allocated_peak: 0, bytes_allocated_sum: 0, address_space_used: 0 } Extra bytes allocated: 394245905 ``` *Runtime: e260d17fcfa34f10503c91148a7bc2fd820e356295d2e18f828b5fa4190d47f7* (I am not sure which runtime is this, maybe some older version which was used for some syncing?) ``` Running with allocator: legacy Peak allocation count: 7852 Peak requested space: 32659186 Peak wasted space on padding: 23185710 Final allocations (that were not yet deallocated): 7801 Final requested space (unallocated space): 32604198 Final wasted space on padding: 23154330 Physical memory used: 36519936 Bump allocator stats: AllocationStats { bytes_allocated: 55820936, bytes_allocated_peak: 55907704, bytes_allocated_sum: 283346320, address_space_used: 55953104 } Extra bytes allocated: 360474882 Running with allocator: new Peak allocation count: 7852 Peak requested space: 32659186 Peak wasted space on padding: 147502 Final allocations (that were not yet deallocated): 7801 Final requested space (unallocated space): 32604198 Final wasted space on padding: 146394 Physical memory used: 39440384 Bump allocator stats: AllocationStats { bytes_allocated: 0, bytes_allocated_peak: 0, bytes_allocated_sum: 0, address_space_used: 0 } Extra bytes allocated: 386472515 ``` #### asset-hub-polkadot relaychain allocation patterns *Runtime: e260d17fcfa34f10503c91148a7bc2fd820e356295d2e18f828b5fa4190d47f7* ``` Running with allocator: legacy Peak allocation count: 27570 Peak requested space: 159710372 Peak wasted space on padding: 112773340 Final allocations: 7549 Final requested space: 159200521 Final wasted space on padding: 112562375 Physical memory used: 208474112 Bump allocator stats: AllocationStats { bytes_allocated: 271823288, bytes_allocated_peak: 272569888, bytes_allocated_sum: 20547290680, address_space_used: 292902856 } Extra bytes allocated: 183737681 Running with allocator: new Peak allocation count: 27570 Peak requested space: 159710372 Peak wasted space on padding: 64415644 Final allocations: 7549 Final requested space: 159200521 Final wasted space on padding: 64287543 Physical memory used: 195022848 Bump allocator stats: AllocationStats { bytes_allocated: 157230856, bytes_allocated_peak: 157558560, bytes_allocated_sum: 1364898648, address_space_used: 177034712 } Extra bytes allocated: 219745053 ``` ### Heavy contract execution with host allocator debug logs: https://github.com/paritytech/memory_exhaustion 1. Used #9363 + #9267 (commit b86340a) to run `staging-node-cli`. 2. Once the node is up, with `runtime_host_allocator=debug` target enabled, I deployed the contract written here: https://github.com/paritytech/memory_exhaustion #### Extracted allocations where `staging-node-cli` is started with logging directive `runtime_host_allocator=debug` Got around 500 millions allocation/deallocation operations in sequence, and replayed them with same simulator from Jan. The extrinsic for the contract call (which recurses for 25 times) doesn't seem to end/get finalized, but allocations/deallocations are continously logged (let it run for more than 24hours and it was still logging). If the allocator log target captures the allocations logs on `debug`, contracts execution might be slow and strange things can happen (e.g. infinite allocations logged while executing an extrinsic related to a contract call - which I saw in practice). I would consider the bellow exercise not very representative for how the allocations happen, but it is still useful to be mentioned for future reference. *Runtime 01cefa9c6e629d4cf67dc635e800c19ad7aea335333802af4945ada00dca1f0b* ``` Running with allocator: legacy Peak allocation count: 16376 Peak requested space: 321974359 Peak wasted space on padding: 6350956 Final allocations: 2855 Final requested space: 317628029 Final wasted space on padding: 6350955 Physical memory used: 348807168 Bump allocator stats: AllocationStats { bytes_allocated: 324001824, bytes_allocated_peak: 328308656, bytes_allocated_sum: 13785237856, address_space_used: 351468928 } Extra bytes allocated: 139785942 Running with allocator: new Peak allocation count: 16376 Peak requested space: 321974359 Peak wasted space on padding: 5285723 Final allocations: 2855 Final requested space: 317628029 Final wasted space on padding: 5285443 Physical memory used: 350203904 Bump allocator stats: AllocationStats { bytes_allocated: 257951880, bytes_allocated_peak: 262277192, bytes_allocated_sum: 3068803176, address_space_used: 284035320 } Extra bytes allocated: 140989127 ``` ### Heavy contract execution w/o custom logging directives: https://github.com/paritytech/memory_exhaustion Setup is same as for the execution with debug logging directives, only that I used for polkadot-sdk branch of #9267 at 032e005. #### Extracted allocations where `staging-node-cli` is started w/o logging directives and host allocator logs for allocations/deallocations are logged as `warn` - so they show up by default in node logs Looks like when logging allocator logs on `warn` the exercise finishes successfully, and the allocations are much lower (e.g. ~55MB peak requested space and ~60/56MB phyisical memory used). *Runtime: ead5ededbf9840660462ca27ae6d8008e827f902c6974d940b2cfee5d4be84f8* ``` Running with allocator: legacy Peak allocation count: 16777 Peak requested space: 55185677 Peak wasted space on padding: 2580291 Final allocations: 968 Final requested space: 5131075 Final wasted space on padding: 506613 Physical memory used: 60407808 Bump allocator stats: AllocationStats { bytes_allocated: 5645432, bytes_allocated_peak: 57772736, bytes_allocated_sum: 6860640944, address_space_used: 61215344 } Extra bytes allocated: 357079214 Running with allocator: new Peak allocation count: 16777 Peak requested space: 55185677 Peak wasted space on padding: 207033 Final allocations: 968 Final requested space: 5131075 Final wasted space on padding: 19581 Physical memory used: 56799232 Bump allocator stats: AllocationStats { bytes_allocated: 0, bytes_allocated_peak: 0, bytes_allocated_sum: 0, address_space_used: 0 } Extra bytes allocated: 414225157 ```

    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