Mempool memory usage underutilized #8609

issue rebroad opened this issue on August 27, 2016
  1. rebroad commented at 2:58 AM on August 27, 2016: contributor

    screenshot at 2016-08-27 10 07 27

    In this example the mempool memory usage went to pretty much zero before eventually becoming useful again.

    NOTE: This symptom becomes less pronounced when maxmempool and dbcache are increased.

    UPDATE: The problem seems to occur just as much on another node with maxmempool and dbcache doubled - just at different times, so it may not be related to these values.

  2. rebroad renamed this:
    MinRelayFee falls too slowly
    Mempool memory usage underutilized
    on Aug 27, 2016
  3. gmaxwell commented at 8:13 AM on September 9, 2016: contributor

    What reason do you have to believe that this isn't perfectly correct?

  4. laanwj commented at 8:37 AM on September 9, 2016: member

    I don't get it. What is the problem here? The mempool size is a maximum cap, it willuse less than that after e.g. a block comes in and transactions are removed from it.

  5. sipa commented at 8:41 AM on September 9, 2016: member

    Also see #8610, which effectively reassigns the unused portion of the mempool for use by the chainstate cache.

  6. laanwj closed this on Sep 9, 2016

  7. rebroad commented at 3:40 AM on September 25, 2016: contributor

    @laanwj you ask a question, and then close the issue the same day without giving me a chance to answer. Are issues only issues as long as you personally understand them?

    Look at the graph half-way through - there is still a minimum relay fee even though the memory utilization is almost zero. This is the issue - why limit the txs at all when the utilization is almost 0%? Would it not make more sense to continue storing txs and only increase the restrictive criteria once utilization gets close to being 100%?

  8. sipa commented at 4:48 AM on September 25, 2016: member

    @rebroad One design goal of the limited mempool was to prevent relay of transactions that don't pay for relay.

    Consider the following scenario: a peer figures out what the lowest feerate of any transaction in your mempool is (call it tx A), and creates a valid transaction with a feerate 1sat/kB than this (call it tx B). If our mempool is at its maximum size, and there was no minimum feerate at all, we would kick out tx A and accept tx B, effectively replacing it. If this were to happen across the network (for example because there are several nodes with the same mempool size and software), the network as a whole would have relayed tx A without it actually ending up in a block - it effectively relayed across the network for free.

    This could be exploited by anyone who observes the network wide behaviour, and produces a series of transactions with very very slowly increasing fee only, which at every node in the network cause the previous transaction to be replaced by the newer one, for effectively ~zero cost. At a large scale, this means someone could use the P2P network to mass relay data everywhere, wasting bandwidth and processing time, without paying fees as a deterrent.

    To combat this:

    • There always is a minimum feerate that we demand transactions pay (1000/kB currently, far lower than the going network rate, and the same as many versions ago).
    • When a transaction is being kicked out in favor of another transaction (whether through RBF or mempool limiting), we always require the feerate of the new one to pay at least the minimum feerate more than the kicked-out one paid. This guarantees that the latest transaction in a chain of replacements always paid for the relay (at minimum feerate level) of all previous evicted transactions before it.
    • After kicking out a transaction, we raise the effective minimum feerate temporarily to avoid using the newly available space (after a new block was mined) from being filled with relatively low-feerate transactions that necessitate being evicted again soon after anyway.

    As you can see, for all of these countermeasures, we need an effective minimum feerate even when the mempool is not full.

  9. laanwj commented at 6:29 AM on September 25, 2016: member

    @laanwj you ask a question, and then close the issue the same day without giving me a chance to answer. Are issues only issues as long as you personally understand them?

    Closing issues (in contrast to locking them) doesn't prevent anyone from answering.

    To keep a lid on the sheer number of issues open, I have to do the thankless job of closing issues that are not clear user problems, but fall into other categories like "I've noticed this curious behavior and have questions about it". As I've said to you many times this is an issue tracker not a Q&A site.

    This is also not the place to make other people do your research/investigation for you.

  10. rebroad commented at 7:15 AM on October 4, 2016: contributor

    @laanwj I do not see github being used to do other people research/investigation, but I understand that you perceive this. I do not understand why though.

    I think the root cause of this is ultimately lack of documentation. @sipa 's very detailed response, IMHO, ought to be incorporated into such documentation. There is the question of where this documentation ought to best be stored. My answer to that question would be github - with the documentation for the functionality of each pull request being stored against the pull request. Ideally the documentation ought to be submitted with the pull request itself, or in the code as comments, but when this isn't done, then at least, retrospectively might be a suitable alternative.

    Perhaps I am unaware of such documentation that already exists - if so, then the issue, IMHO, would be making it easier for people to find it.

  11. MarcoFalke commented at 8:55 AM on October 4, 2016: member

    I think the root cause of this is ultimately lack of documentation.

    I agree that there is a lack of documentation. Usually the code is considered the documentation and it becomes clear how something works, but the design principles usually are hidden somewhere else. (Maybe not even publicly accessible)

    For the protocol and general bitcoin related concepts, we have the Bitcoin Improvement Proposals... For documenting internal logic, you suggested to use github issues and pull requests. I disagree, the design rationale for the internal logic should be placed in properly formatted doxygen comments above each class/method. (We have the problem, that those comments usually outdate very quickly because contributors "forget" to update the comments. Unfortunately I don't know of a way to enforce during review that comments need to be updated when the code is changed. Maybe only a maintainer for the specific module could keep it in mind? While not perfect, I still think that documentation should be part of the source code.)

  12. laanwj commented at 9:06 AM on October 4, 2016: member

    While not perfect, I still think that documentation should be part of the source code.

    100% agreed.

    Also note that while it's easy to forget to update developer documentation that is part of the source code, it is even easier to forget to update "design documents" that live elsewhere. We actually have a few of those in doc/, for example https://github.com/bitcoin/bitcoin/blob/master/doc/multiwallet-qt.md . Or the list of threads here: https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#threads . Sufficient to say, both are outdated, though to different degrees.

    Application user documentation should probably exist outside the source code, although it can exist as something that can be queried from the program itself. Like the RPC help, or --help flags. And e.g. a context-sensitive help for the GUI would be nice.

    Protocol documentation should exist outside this repository as it is not specific to Bitcoin Core. Examples of this are the BIPs, as well as the excellent Developer Reference on bitcoin.org.

  13. rebroad referenced this in commit 6c89b147e4 on Dec 11, 2016
  14. rebroad commented at 1:57 AM on December 11, 2016: contributor

    @sipa why would anyone want to relay txs around the network with no intention of them getting into blocks?

  15. rebroad referenced this in commit ebaae24d2a on Dec 11, 2016
  16. rebroad referenced this in commit cf528b1cb5 on Dec 11, 2016
  17. rebroad referenced this in commit b884da626d on Dec 11, 2016
  18. rebroad referenced this in commit c6731f7094 on Dec 12, 2016
  19. rebroad referenced this in commit eb257f81bd on Dec 12, 2016
  20. rebroad referenced this in commit 66f2612e1f on Dec 13, 2016
  21. rebroad referenced this in commit 306205bd5c on Dec 13, 2016
  22. rebroad referenced this in commit f7bac48964 on Dec 13, 2016
  23. rebroad referenced this in commit 5483927936 on Dec 13, 2016
  24. rebroad referenced this in commit 226d09363d on Dec 14, 2016
  25. rebroad referenced this in commit e854ee229f on Dec 16, 2016
  26. rebroad referenced this in commit 3bab050124 on Dec 18, 2016
  27. rebroad referenced this in commit 2d03cdd010 on Dec 20, 2016
  28. rebroad referenced this in commit c53e4e56ad on Dec 23, 2016
  29. rebroad referenced this in commit 4dac157791 on Dec 23, 2016
  30. rebroad referenced this in commit c4c20177c3 on Dec 23, 2016
  31. rebroad referenced this in commit 302ceac879 on Dec 24, 2016
  32. rebroad referenced this in commit 25d7847d69 on Dec 26, 2016
  33. rebroad referenced this in commit 54289ae405 on Dec 26, 2016
  34. rebroad referenced this in commit a23df6146b on Dec 26, 2016
  35. rebroad referenced this in commit b78edb97ec on Dec 26, 2016
  36. rebroad referenced this in commit 237097a40b on Dec 27, 2016
  37. rebroad referenced this in commit 5159ec3113 on Dec 27, 2016
  38. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-22 18:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me