Skip to content

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented May 1, 2019

No need to hold cs_main when serializing a struct to json

Fixes: #15925

@maflcko maflcko force-pushed the 1905-rpcBlockNoLock branch from fa59893 to fab00a5 Compare May 1, 2019 16:32
@jnewbery
Copy link
Contributor

jnewbery commented May 2, 2019

Does it make sense to add an AssertLockNotHeld(cs_main) to those functions?

@promag
Copy link
Contributor

promag commented May 2, 2019

For reference #12153 (comment).

Concept ACK.

Does it make sense to add an AssertLockNotHeld(cs_main) to those functions?

Maybe EXCLUDES annotation instead?

@laanwj
Copy link
Member

laanwj commented May 2, 2019

Concept ACK. The whole point of moving the lock of cs_main inside the individual RPC functions was to allow optimizations such as this.

@maflcko
Copy link
Member Author

maflcko commented May 2, 2019

Added lock annotations as requested by @promag and @jnewbery

@DrahtBot
Copy link
Contributor

DrahtBot commented May 2, 2019

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #14802 (rpc: faster getblockstats using BlockUndo data by FelixWeis)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@jnewbery
Copy link
Contributor

jnewbery commented May 2, 2019

utACK faea564

@fanatid
Copy link
Contributor

fanatid commented May 3, 2019

Why not use ENTER_CRITICAL_SECTION & LEAVE_CRITICAL_SECTION instead LOCK?

@promag
Copy link
Contributor

promag commented May 3, 2019

Because a scoped lock is more clear and "secure".

@jonasschnelli
Copy link
Contributor

utACK faea564

@maflcko maflcko merged commit faea564 into bitcoin:master May 3, 2019
maflcko pushed a commit that referenced this pull request May 3, 2019
faea564 rpc: Add lock annotations to block{,header}ToJSON (MarcoFalke)
fab00a5 rpc: Serialize in getblock without cs_main (MarcoFalke)
fa1c359 rpc: Use IsValidNumArgs in getblock (MarcoFalke)

Pull request description:

  No need to hold cs_main when serializing a struct to json

  Fixes: #15925

ACKs for commit faea56:
  jnewbery:
    utACK faea564
  jonasschnelli:
    utACK faea564

Tree-SHA512: 005d378cda1e6024e9f5142f99a8adbefe202cd7bfeaafee55eb909e8990a3790aa27fcf5dd16119cc9afe9dc8bd30f660de40233316781669be166bac3018e7
@maflcko maflcko deleted the 1905-rpcBlockNoLock branch May 3, 2019 12:15
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request May 3, 2019
faea564 rpc: Add lock annotations to block{,header}ToJSON (MarcoFalke)
fab00a5 rpc: Serialize in getblock without cs_main (MarcoFalke)
fa1c359 rpc: Use IsValidNumArgs in getblock (MarcoFalke)

Pull request description:

  No need to hold cs_main when serializing a struct to json

  Fixes: bitcoin#15925

ACKs for commit faea56:
  jnewbery:
    utACK faea564
  jonasschnelli:
    utACK faea564

Tree-SHA512: 005d378cda1e6024e9f5142f99a8adbefe202cd7bfeaafee55eb909e8990a3790aa27fcf5dd16119cc9afe9dc8bd30f660de40233316781669be166bac3018e7
#include <stdint.h>
#include <vector>

extern RecursiveMutex cs_main;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarcoFalke Do you use RecursiveMutex instead of CCriticalSection on purpose?

fanquake added a commit that referenced this pull request Jan 15, 2020
…utex

e09c701 scripted-diff: Bump copyright of files changed in 2020 (MarcoFalke)
6cbe620 scripted-diff: Replace CCriticalSection with RecursiveMutex (MarcoFalke)

Pull request description:

  `RecursiveMutex` better clarifies that the mutex is recursive, see also the standard library naming: https://en.cppreference.com/w/cpp/thread/recursive_mutex

  For that reason, and to avoid different people asking me the same question repeatedly (e.g. #15932 (review) ), remove the outdated alias `CCriticalSection` with a scripted-diff

ACKs for top commit:
  Empact:
    ACK e09c701 diff and scripts look correct
  promag:
    ACK e09c701
  practicalswift:
    ACK e09c701 -- scripted diff looks correct

Tree-SHA512: 4bd7b5de1befdcf91dc8f43c127a1fee49679e06895a43216f160344a395c8e426dc68d529fbd2d5e1c215625a5a392dc415b1bce4127316aae7ecf98030c855
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jun 1, 2020
Summary:
bitcoin/bitcoin@fa1c359

---

Partial backport of Core [[bitcoin/bitcoin#15932 | PR15932]]

Test Plan:
  ninja check check-functional

run `bitcoin-cli getblock` and check that layout is nice and lined up

Reviewers: #bitcoin_abc, nakihito, deadalnix

Reviewed By: #bitcoin_abc, nakihito, deadalnix

Subscribers: deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6296
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jun 1, 2020
Summary:
bitcoin/bitcoin@fab00a5

---

Depends on D6296

Partial backport of Core [[bitcoin/bitcoin#15932 | PR15932]]

Test Plan:
  cmake .. -GNinja -DCMAKE_BUILD_TYPE=Debug
  ninja check check-functional

Reviewers: #bitcoin_abc, nakihito

Reviewed By: nakihito

Differential Revision: https://reviews.bitcoinabc.org/D6297
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jun 1, 2020
Summary:
bitcoin/bitcoin@faea564

---

Depends on D6297

Concludes backport of Core [[bitcoin/bitcoin#15932 | PR15932]]

Test Plan:
  cmake .. -GNinja -DENABLE_SANITIZERS=thread
  ninja check

Reviewers: #bitcoin_abc, nakihito

Reviewed By: nakihito

Differential Revision: https://reviews.bitcoinabc.org/D6300
LarryRuane pushed a commit to LarryRuane/zcash that referenced this pull request May 10, 2021
LarryRuane pushed a commit to LarryRuane/zcash that referenced this pull request May 10, 2021
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Oct 12, 2021
faea564 rpc: Add lock annotations to block{,header}ToJSON (MarcoFalke)
fab00a5 rpc: Serialize in getblock without cs_main (MarcoFalke)
fa1c359 rpc: Use IsValidNumArgs in getblock (MarcoFalke)

Pull request description:

  No need to hold cs_main when serializing a struct to json

  Fixes: bitcoin#15925

ACKs for commit faea56:
  jnewbery:
    utACK faea564
  jonasschnelli:
    utACK faea564

Tree-SHA512: 005d378cda1e6024e9f5142f99a8adbefe202cd7bfeaafee55eb909e8990a3790aa27fcf5dd16119cc9afe9dc8bd30f660de40233316781669be166bac3018e7
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Oct 13, 2021
faea564 rpc: Add lock annotations to block{,header}ToJSON (MarcoFalke)
fab00a5 rpc: Serialize in getblock without cs_main (MarcoFalke)
fa1c359 rpc: Use IsValidNumArgs in getblock (MarcoFalke)

Pull request description:

  No need to hold cs_main when serializing a struct to json

  Fixes: bitcoin#15925

ACKs for commit faea56:
  jnewbery:
    utACK faea564
  jonasschnelli:
    utACK faea564

Tree-SHA512: 005d378cda1e6024e9f5142f99a8adbefe202cd7bfeaafee55eb909e8990a3790aa27fcf5dd16119cc9afe9dc8bd30f660de40233316781669be166bac3018e7
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Oct 14, 2021
faea564 rpc: Add lock annotations to block{,header}ToJSON (MarcoFalke)
fab00a5 rpc: Serialize in getblock without cs_main (MarcoFalke)
fa1c359 rpc: Use IsValidNumArgs in getblock (MarcoFalke)

Pull request description:

  No need to hold cs_main when serializing a struct to json

  Fixes: bitcoin#15925

ACKs for commit faea56:
  jnewbery:
    utACK faea564
  jonasschnelli:
    utACK faea564

Tree-SHA512: 005d378cda1e6024e9f5142f99a8adbefe202cd7bfeaafee55eb909e8990a3790aa27fcf5dd16119cc9afe9dc8bd30f660de40233316781669be166bac3018e7
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

getblock performance issue on verbosity
9 participants