refactor (tidy): Fixes after enable-debug configure #27353

pull TheCharlatan wants to merge 1 commits into bitcoin:master from TheCharlatan:clangTidyDebug changing 5 files +29 −29
  1. TheCharlatan commented at 10:07 am on March 28, 2023: contributor

    This diff can be reproduced by running (tested with clang-14 and clang-15):

    0./autogen.sh && CC=clang CXX=clang++ ./configure --enable-suppress-external-warnings --enable-debug
    1bear --config src/.bear-tidy-config -- make -j $(nproc)
    2cd ./src/ && run-clang-tidy -quiet -fix -j $(nproc)
    
  2. DrahtBot commented at 10:08 am on March 28, 2023: contributor

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Stale ACK hebasto

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

    Conflicts

    No conflicts as of last run.

  3. fanquake commented at 10:47 am on March 28, 2023: member
    The failure here is #27316.
  4. TheCharlatan force-pushed on Mar 30, 2023
  5. fanquake requested review from glozow on Mar 31, 2023
  6. fanquake requested review from hebasto on Mar 31, 2023
  7. hebasto commented at 12:55 pm on March 31, 2023: member

    Besides, I’m also not sold that this lint is an actual improvement.

    I think this PR diff is an improvement.

  8. TheCharlatan marked this as ready for review on Mar 31, 2023
  9. TheCharlatan commented at 1:18 pm on March 31, 2023: contributor

    I think this PR diff is an improvement.

    I’ll undraft this then, even if I still don’t understand why clang-tidy seems to catch more with debug enabled.

  10. glozow commented at 1:19 pm on March 31, 2023: member

    Besides, I’m also not sold that this lint is an actual improvement.

    I think this PR diff is an improvement.

    Could you explain why it’s an improvement? It’s unclear to me why const references to iterators would be an improvement, I was under the impression that iters by value were fine.

  11. hebasto commented at 2:43 pm on March 31, 2023: member

    I’ll undraft this then, even if I still don’t understand why clang-tidy seems to catch more with debug enabled.

    ~I suspect~ The culprit is the -DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE definition.

    UPD. The mentioned defined macro makes sizeof(CTxMemPool::txiter) == 40 on my Ubuntu 22.04 x86_64, which makes clang-tidy consider this type expensive to copy.

  12. hebasto commented at 2:48 pm on March 31, 2023: member

    Besides, I’m also not sold that this lint is an actual improvement.

    I think this PR diff is an improvement.

    Could you explain why it’s an improvement? It’s unclear to me why const references to iterators would be an improvement, I was under the impression that iters by value were fine.

    Well, my main point was enforcing of const-corectness, but I missed the fact that CTxMemPool::txiter is a const_iterator.

    Making a constness at the call site obvious for a code reader/reviewer is a very minor improvement, which could be just ignored.

  13. glozow commented at 8:46 am on April 3, 2023: member

    Making a constness at the call site obvious for a code reader/reviewer is a very minor improvement, which could be just ignored.

    Ok, so it seems we agree there is no code quality benefit. Is the motivation = CI already failing or wanting to add –enable-debug to it?

    The failure here is #27316.

    I’m having trouble understanding the relationship between this PR and that issue, am I missing something?

  14. TheCharlatan commented at 8:55 am on April 3, 2023: contributor

    I’m having trouble understanding the relationship between this PR and that issue, am I missing something?

    The CI was previously failing on the functional tests due to that issue.

  15. glozow commented at 9:12 am on April 3, 2023: member

    The CI was previously failing on the functional tests due to that issue.

    How is it possible for that functional test to fail due to using iters vs references to iters? Wasn’t the issue with #27316 not waiting for sync, i.e. addressed by #27318? Does the problem still exist? Still trying to understand the motivation for this PR.

  16. fanquake commented at 9:13 am on April 3, 2023: member
    The functional test failure was sporadic, and unrelated to the changes proposed here.
  17. hebasto commented at 12:51 pm on April 3, 2023: member

    Ok, so it seems we agree there is no code quality benefit.

    To clarify my point, this change does improve code performance when the build is configured with --enable-debug.

    I’m not saying that this fact justifies this PR sufficiently, but it should be considered, at the very least.

    Is the motivation = CI already failing or wanting to add –enable-debug to it?

    I’d avoid it as it will change code paths being parsed now (for example, the DEBUG_LOCKCONTENTION macro). Maybe just provide CPPFLAGS=-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE?

  18. TheCharlatan force-pushed on Apr 18, 2023
  19. refactor (tidy): Fixes after enable-debug configure
    This diff can be reproduced by running:
    
    ```
    ./autogen.sh && CC=clang CXX=clang++ CPPFLAGS=-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE ./configure --enable-suppress-external-warnings --enable-debug
    bear --config src/.bear-tidy-config -- make -j $(nproc)
    cd ./src/ && run-clang-tidy -quiet -fix -j $(nproc)
    ```
    27d182cef7
  20. TheCharlatan force-pushed on Apr 18, 2023
  21. TheCharlatan commented at 3:17 pm on April 18, 2023: contributor

    Updated 73afe2c3ac87049887e0633bd25c20f809e8090c -> efa1d5bb477dc2093bc06ffded382fdce6bc7703 (clangTidyDebug_0 -> clangTidyDebug_1, compare).

    Rebased efa1d5bb477dc2093bc06ffded382fdce6bc7703 -> 3e76aff9d4709f44d6439cd0cbc2fd6c90cae6ab (clangTidyDebug_1 -> clangTidyDebug_2, compare).

  22. fanquake commented at 3:23 pm on April 18, 2023: member

    Maybe just provide CPPFLAGS=-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE?

    Concept ~0 on making our clang-tidy usage dependant on some Boost define.

  23. hebasto approved
  24. hebasto commented at 3:39 pm on April 18, 2023: member

    ACK 3e76aff9d4709f44d6439cd0cbc2fd6c90cae6ab

    Concept ~0 on making our clang-tidy usage dependant on some Boost define.

    What are possible drawbacks here?

    In this case the -DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE is just a subset of flags being used for debug builds.

  25. glozow added the label Refactoring on Apr 18, 2023
  26. fanquake commented at 6:13 pm on April 18, 2023: member

    What are possible drawbacks here?

    I don’t really understand adding it given your comment above:

    I’d avoid it as it will change code paths being parsed now

    You suggested avoiding changing the code paths being parsed, and then suggested adding a define that changes the code paths being parsed?

    In its current state, this PR is adding a Boost define, because it has a side-effect that basically “tricks” clang-tidy into thinking some code is slightly less performant (but only in debug builds) than it actually is, and thus will “lint” this code, and tell us to add more code to keep it quiet.

    We could instead probably just add the consts, and leave it at that, without trying to invoke some boost-safe-mode-based side effect to trick a linter, and enforce some code change that in reality, doesn’t make any difference to anything.

  27. fanquake commented at 3:05 pm on May 8, 2023: member
    @TheCharlatan can you update this to drop 3e76aff9d4709f44d6439cd0cbc2fd6c90cae6ab, or I think we could just close this?
  28. TheCharlatan commented at 3:14 pm on May 8, 2023: contributor
    I’ll drop the commit. Could this be related to #27586 and solve some of the performance issues?
  29. TheCharlatan force-pushed on May 10, 2023
  30. TheCharlatan commented at 6:25 am on May 10, 2023: contributor

    Updated 3e76aff9d4709f44d6439cd0cbc2fd6c90cae6ab -> 27d182cef72e086afc4592cdfc565b3fdb52d0b4 (clangTidyDebug_2 -> clangTidyDebug_3, compare).

    • Dropped the commit changing the CI.
  31. hebasto commented at 12:06 pm on June 5, 2023: member

    re: #27353 (comment)

    or I think we could just close this?

    Having #27724 been merged, I agree to close this PR.

  32. glozow closed this on Jun 5, 2023

  33. bitcoin locked this on Jun 4, 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-10-30 03:12 UTC

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