Skip to content

repo.stat reads entire of blockstore into memory #180

Closed
@alanshaw

Description

@alanshaw

In IPFS repo.stat takes about 5s per call for me. I found that that the entire blockstore is read into memory every time this function is called to get the count and size:

js-ipfs-repo/src/index.js

Lines 301 to 317 in 3611043

blocks: (cb) => this.blocks.query({}, (err, list) => {
list = list || []
const count = new Big(list.length)
let size = new Big(0)
list.forEach(block => {
size = size
.plus(block.value.byteLength)
.plus(block.key._buf.byteLength)
})
cb(err, {
count: count,
size: size
})
}),

This needs to be streamed and/or calculated once, cached, and kept up to date.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium: Good to have, but can wait until someone steps upexp/wizardExtensive knowledge (implications, ramifications) requiredhelp wantedSeeking public contribution on this issuestatus/readyReady to be worked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions