Skip to content

Switch hashmap to treemap in mempool.Update #2887

@ValarDragon

Description

@ValarDragon

Mempool.Update(txs) job is to ensure that every tx in txs is removed from the mempool. This is currently done by creating a hashmap of strings, and putting all of these txs in there. Then one iterates through the mempool, casts each tx to string, and checks if its in the mempool. This has two constant overheads per tx, converting every tx in the mempool to a string, and AES-hashing every tx in the mempool.

I think instead, we should use a tree map over the []byte representation directly. We can make the ordering condition for the tree map length and then direct big endian byte comparison. I suspect this will make for a significantly faster update function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C:mempoolComponent: MempoolT:perfType: Performance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions