Skip to content

High memory usage while syncing #1576

Description

@seonpyoKim

During the block synchronization, codechain uses main memory over 8GB.
And the occupied memory was not cleared after the synchronization finished.

Activity

  1. seonpyoKim commented on May 29, 2019

    @seonpyoKim
    ContributorAuthor

    Now I'm suspecting this comes from "not shrinking" the Downloaded like data implemented in HeaderDownloader and BodyDownloader. I checked that length of queued (see #1567, data of which was previously included in downloaded) reaches up to about 900,000.
    That had not shrunk and will be alive continuously, I think the HashMap occupied huge amount of memory.

  2. seonpyoKim commented on May 29, 2019

    @seonpyoKim
    ContributorAuthor

    HashMap has shrink_to_fit method, But I'm worrying about the reallocation overhead.
    @foriequal0 showed me that the reallocation step occurs sparsely with doubling the previous size when inserting to HashMap but occurs densely when shrinking the HashMap.

  3. sgkim126 commented on May 30, 2019

    @sgkim126
    Contributor

    Hi @HoOngEe,
    Please call shirink_to_fit after removing items.
    I don't think it becomes a burden to reallocate because HashMap allocates memory more than it needs when there is no capacity.
    And please apply this change to HashSet and Vec in BodyDownloader.

  4. seonpyoKim commented on Aug 28, 2019

    @seonpyoKim
    ContributorAuthor

    Here is the main reason of high memory. #1585 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions