Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement accurate memory accounting for mempool #6410

Merged
merged 1 commit into from Jul 11, 2015
Merged

Conversation

@sipa
Copy link
Member

@sipa sipa commented Jul 9, 2015

This implements accurate memory usage accounting for the mempool. It is only exposed through getmempoolinfo for now, but could be used for limiting the resource requirements too (#6281).

@sipa sipa mentioned this pull request Jul 9, 2015
@sipa sipa force-pushed the mempoolusage branch 2 times, most recently from 45f50ac to 38ac0b5 Jul 9, 2015
@laanwj
Copy link
Member

@laanwj laanwj commented Jul 10, 2015

Tested ACK.

Nit: I'd slightly prefer DynamicUsage for eg uint256 as helper functions outside the class instead of added members.

@sipa sipa force-pushed the mempoolusage branch from 38ac0b5 to 5098c47 Jul 10, 2015
@sipa
Copy link
Member Author

@sipa sipa commented Jul 10, 2015

Updated to retain the totaltxsize field in the RPC output.

@laanwj I avoided the need for a DynamicMemoryUsage for uint256 altogether now.

@laanwj
Copy link
Member

@laanwj laanwj commented Jul 10, 2015

Ok, even better.

@jonasschnelli
Copy link
Member

@jonasschnelli jonasschnelli commented Jul 11, 2015

Review ACK.
utACK (code is now running on bitcoin.jonasschnelli.ch)
very minor nit: some ifs have opening brackets on the same line, some not. But i don't care.

@sipa
Copy link
Member Author

@sipa sipa commented Jul 11, 2015

@jtimon
Copy link
Member

@jtimon jtimon commented Jul 11, 2015

utACK

Regarding style, I believe https://github.com/bitcoin/bitcoin/blob/master/src/.clang-format says always in the same line for if, else, for, switch and always in the next line for functions/methods (unless they are defined in one line, which is allowed). That's what I'm doing when I need to touch the lines, but I have to admit I'm not 100% sure. Anyway, style nits...

@laanwj laanwj merged commit 5098c47 into bitcoin:master Jul 11, 2015
1 check passed
laanwj added a commit that referenced this issue Jul 11, 2015
5098c47 Implement accurate memory accounting for mempool (Pieter Wuille)
@jonasschnelli
Copy link
Member

@jonasschnelli jonasschnelli commented Jul 11, 2015

Here are also some stats done with a node running this PR: http://bitcoin.jonasschnelli.ch/charts/mempool/

@petertodd
Copy link
Contributor

@petertodd petertodd commented Jul 11, 2015

utACK

@@ -58,6 +59,7 @@ class CTxMemPoolEntry
int64_t GetTime() const { return nTime; }
unsigned int GetHeight() const { return nHeight; }
bool WasClearAtEntry() const { return hadNoDependencies; }
size_t DynamicMemoryUsage() const { return nUsageSize; }
Copy link
Member

@morcos morcos Jul 13, 2015

Any reason we're not counting the other member variables? Seems like there are another 53 bytes per CTMemPoolEntry?

Copy link
Member Author

@sipa sipa Jul 13, 2015

Maybe it should have been called IndirectMemoryUsage. The size of the CTxMemPoolEntry structure itself is accounted for through memusage::DynamicUsage(mapTx), in which the entries are included. That allows for accurately taking alignment and malloc overhead into account.

zkbot added a commit to zcash/zcash that referenced this issue Mar 23, 2017
Bitcoin 0.12 mempool memory usage PRs

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#6410
- bitcoin/bitcoin#6453
- bitcoin/bitcoin#6013 (excludes changes to docs we deleted)

Part of #2074.
random-zebra added a commit to PIVX-Project/PIVX that referenced this issue Jun 3, 2020
368665e Implement accurate memory accounting for mempool (random-zebra)

Pull request description:

  Based on top of:
  - [x] #1641

  This continues the work of #1531 adding memory accounting for the mempool.
  Backports bitcoin#6410.

  Original description:
  > This implements accurate memory usage accounting for the mempool. It is only exposed through getmempoolinfo for now, but could be used for limiting the resource requirements too (bitcoin#6281).

ACKs for top commit:
  furszy:
    pretty nice, tested ACK 368665e
  Fuzzbawls:
    ACK 368665e

Tree-SHA512: f1dd0e98af58133255db02ae57f20c5d1c0b210610bf6e6c99a112c8c74c0e83e0ae05fd22a933cc4db0eaca36b5f45fa27231879809b348ba0dba034e176767
wqking added a commit to wqking/Vitae that referenced this issue Jan 9, 2021
368665e35981b28c8d2f0c982ea493996358bb05 Implement accurate memory accounting for mempool (random-zebra)

Pull request description:

  Based on top of:
  - [x] #1641

  This continues the work of #1531 adding memory accounting for the mempool.
  Backports bitcoin/bitcoin#6410.

  Original description:
  > This implements accurate memory usage accounting for the mempool. It is only exposed through getmempoolinfo for now, but could be used for limiting the resource requirements too (bitcoin/bitcoin#6281).

ACKs for top commit:
  furszy:
    pretty nice, tested ACK 368665e
  Fuzzbawls:
    ACK 368665e35981b28c8d2f0c982ea493996358bb05

Tree-SHA512: f1dd0e98af58133255db02ae57f20c5d1c0b210610bf6e6c99a112c8c74c0e83e0ae05fd22a933cc4db0eaca36b5f45fa27231879809b348ba0dba034e176767

# Conflicts:
#	src/memusage.h
#	src/script/script.cpp
#	src/script/script.h
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants