optimization: Preallocate addresses in GetAddr based on nNodes #29608

pull paplorinc wants to merge 1 commits into bitcoin:master from paplorinc:paplorinc/addrman-get-address-preallocate changing 1 files +1 −0
  1. paplorinc commented at 7:58 pm on March 9, 2024: contributor

    The reserve method optimizes memory allocation by preallocating space for the expected number of elements (nNodes), reducing reallocations and improving performance. The upper bound ensures efficient memory usage based on the input constraints.

    before:

    0|               ns/op |                op/s |    err% |     total | benchmark
    1|--------------------:|--------------------:|--------:|----------:|:----------
    2|           76,852.79 |           13,011.89 |    0.4% |      1.07 | `AddrManGetAddr`
    3|           76,598.21 |           13,055.14 |    0.2% |      1.07 | `AddrManGetAddr`
    4|           76,296.32 |           13,106.79 |    0.1% |      1.07 | `AddrManGetAddr`
    

    after:

    0|               ns/op |                op/s |    err% |     total | benchmark
    1|--------------------:|--------------------:|--------:|----------:|:----------
    2|           65,966.97 |           15,159.10 |    0.3% |      1.07 | `AddrManGetAddr`
    3|           66,075.40 |           15,134.23 |    0.2% |      1.06 | `AddrManGetAddr`
    4|           66,306.34 |           15,081.51 |    0.3% |      1.06 | `AddrManGetAddr`
    
  2. DrahtBot commented at 7:58 pm on March 9, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Stale ACK vasild

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. paplorinc renamed this:
    refactorÉ Preallocate addresses in GetAddr_ based on nNodes
    refactor: Preallocate addresses in GetAddr_ based on nNodes
    on Mar 9, 2024
  4. DrahtBot added the label Refactoring on Mar 9, 2024
  5. paplorinc force-pushed on Mar 9, 2024
  6. paplorinc renamed this:
    refactor: Preallocate addresses in GetAddr_ based on nNodes
    refactor: Preallocate addresses in GetAddr based on nNodes
    on Mar 9, 2024
  7. paplorinc force-pushed on Mar 9, 2024
  8. paplorinc marked this as ready for review on Mar 9, 2024
  9. brunoerg commented at 10:11 pm on March 9, 2024: contributor
    Perhaps It would be better to cherry-pick this change into #29578 since that touches it?
  10. paplorinc commented at 10:16 pm on March 9, 2024: contributor
    @brunoerg, feel free to do that, I’ll close this if you cherry-pick it to the other PR (please provide before/after measurements)
  11. vasild approved
  12. vasild commented at 2:13 pm on March 11, 2024: contributor

    ACK 278a1ee27bc760d3eb00069327d4b8f49950f6b6

    Note that this may overshoot and allocate more space than is going to be needed. Less so with #29578.

  13. brunoerg commented at 2:42 pm on March 11, 2024: contributor

    @brunoerg, feel free to do that, I’ll close this if you cherry-pick it to the other PR (please provide before/after measurements)

    Done.

  14. paplorinc commented at 2:46 pm on March 11, 2024: contributor
    Thanks for the review @vasild, we’ve moved it over to the other PR
  15. paplorinc closed this on Mar 11, 2024

  16. paplorinc deleted the branch on Mar 11, 2024
  17. paplorinc restored the branch on Jun 23, 2024
  18. paplorinc reopened this on Jun 23, 2024

  19. Preallocate addresses in GetAddr based on nNodes
    > make && ./src/bench/bench_bitcoin --filter=AddrManGetAddr --min-time=1000
    
    Before:
    ```
    |               ns/op |                op/s |    err% |     total | benchmark
    |--------------------:|--------------------:|--------:|----------:|:----------
    |           76,852.79 |           13,011.89 |    0.4% |      1.07 | `AddrManGetAddr`
    |           76,598.21 |           13,055.14 |    0.2% |      1.07 | `AddrManGetAddr`
    |           76,296.32 |           13,106.79 |    0.1% |      1.07 | `AddrManGetAddr`
    ```
    After:
    ```
    |               ns/op |                op/s |    err% |     total | benchmark
    |--------------------:|--------------------:|--------:|----------:|:----------
    |           65,966.97 |           15,159.10 |    0.3% |      1.07 | `AddrManGetAddr`
    |           66,075.40 |           15,134.23 |    0.2% |      1.06 | `AddrManGetAddr`
    |           66,306.34 |           15,081.51 |    0.3% |      1.06 | `AddrManGetAddr`
    ```
    0dd1e09871
  20. paplorinc commented at 4:25 pm on June 23, 2024: contributor
    Reopening since #29578 was closed without merge
  21. paplorinc force-pushed on Jun 23, 2024
  22. paplorinc renamed this:
    refactor: Preallocate addresses in GetAddr based on nNodes
    optimization: Preallocate addresses in GetAddr based on nNodes
    on Jun 23, 2024

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: 2024-06-29 07:13 UTC

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