Skip to content

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Apr 27, 2020

On master (eef90c1):

  • thread list from OS:
    Screenshot from 2020-04-28 00-25-41
  • log excerpt:
2020-04-27T21:25:26Z [] GUI: initialize : Running initialization in thread
...
2020-04-27T21:26:04Z [] Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
2020-04-27T21:26:04Z [] Using wallet /home/hebasto/.bitcoin/testnet3/wallets/test2
2020-04-27T21:26:04Z [] BerkeleyEnvironment::Open: LogDir=/home/hebasto/.bitcoin/testnet3/wallets/test2/database ErrorFile=/home/hebasto/.bitcoin/testnet3/wallets/test2/db.log
2020-04-27T21:26:04Z [] init message: Loading wallet...
2020-04-27T21:26:04Z [] BerkeleyEnvironment::Open: LogDir=/home/hebasto/.bitcoin/testnet3/wallets/test2/database ErrorFile=/home/hebasto/.bitcoin/testnet3/wallets/test2/db.log
2020-04-27T21:26:04Z [] [test2] Wallet File Version = 169900
2020-04-27T21:26:04Z [] [test2] Keys: 2001 plaintext, 0 encrypted, 2001 w/ metadata, 2001 total. Unknown wallet records: 0
2020-04-27T21:26:04Z [] [test2] Wallet completed loading in              26ms
2020-04-27T21:26:04Z [] GUI: TransactionTablePriv::refreshWallet
2020-04-27T21:26:04Z [] [test2] setKeyPool.size() = 2000
2020-04-27T21:26:04Z [] [test2] mapWallet.size() = 0
2020-04-27T21:26:04Z [] [test2] m_address_book.size() = 0

With this PR:

  • thread list from OS:
    Screenshot from 2020-04-28 00-21-40
  • log excerpt:
2020-04-27T21:21:25Z [qt-init] GUI: initialize : Running initialization in thread
...
2020-04-27T21:23:08Z [qt-walletctrl] Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
2020-04-27T21:23:08Z [qt-walletctrl] Using wallet /home/hebasto/.bitcoin/testnet3/wallets/test2
2020-04-27T21:23:08Z [qt-walletctrl] BerkeleyEnvironment::Open: LogDir=/home/hebasto/.bitcoin/testnet3/wallets/test2/database ErrorFile=/home/hebasto/.bitcoin/testnet3/wallets/test2/db.log
2020-04-27T21:23:08Z [qt-walletctrl] init message: Loading wallet...
2020-04-27T21:23:08Z [qt-walletctrl] BerkeleyEnvironment::Open: LogDir=/home/hebasto/.bitcoin/testnet3/wallets/test2/database ErrorFile=/home/hebasto/.bitcoin/testnet3/wallets/test2/db.log
2020-04-27T21:23:08Z [qt-walletctrl] [test2] Wallet File Version = 169900
2020-04-27T21:23:08Z [qt-walletctrl] [test2] Keys: 2001 plaintext, 0 encrypted, 2001 w/ metadata, 2001 total. Unknown wallet records: 0
2020-04-27T21:23:08Z [qt-walletctrl] [test2] Wallet completed loading in              37ms
2020-04-27T21:23:08Z [qt-walletctrl] init message: Rescanning...
2020-04-27T21:23:08Z [qt-walletctrl] [test2] Rescanning last 112924 blocks (from block 1609206)...
2020-04-27T21:23:08Z [qt-walletctrl] [test2] Rescan started from block 000000000000003761c81f7efbd8cebf217f39d353ec1ac59c624ac2dddfc2a8...
2020-04-27T21:23:22Z [qt-walletctrl] [test2] Rescan completed in           14157ms
2020-04-27T21:23:22Z [qt-walletctrl] GUI: TransactionTablePriv::refreshWallet
2020-04-27T21:23:22Z [qt-walletctrl] [test2] setKeyPool.size() = 2000
2020-04-27T21:23:22Z [qt-walletctrl] [test2] mapWallet.size() = 0
2020-04-27T21:23:22Z [qt-walletctrl] [test2] m_address_book.size() = 0

@DrahtBot
Copy link
Contributor

DrahtBot commented Apr 27, 2020

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

Conflicts

No conflicts as of last run.

@laanwj
Copy link
Member

laanwj commented Apr 30, 2020

Please keep to the convention of starting thread names with b-.

@hebasto
Copy link
Member Author

hebasto commented Apr 30, 2020

Please keep to the convention of starting thread names with b-.

It is responsibility of the ThreadRename() function:

void util::ThreadRename(std::string&& name)
{
SetThreadName(("b-" + name).c_str());
SetInternalName(std::move(name));
}

:)

UPDATE: On the screenshot in OP you can see all of the touched threads with b- prefix in the htop output.

@laanwj
Copy link
Member

laanwj commented Apr 30, 2020

It is responsibility of the ThreadRename() function:

Thanks for clearing that up.

@hebasto hebasto force-pushed the 200427-name-qthread branch from da42cd4 to 64815f1 Compare April 30, 2020 20:37
@hebasto
Copy link
Member Author

hebasto commented Apr 30, 2020

Updated da42cd4 -> 64815f1 (pr18790.01 -> pr18790.02, diff):

  • dropped "Name leveldb thread with its own name" commit

@jb55
Copy link
Contributor

jb55 commented Apr 30, 2020

ACK 64815f1

@maflcko maflcko changed the title Improve thread naming gui: Improve thread naming Apr 30, 2020
@brakmic
Copy link
Contributor

brakmic commented May 1, 2020

ACK 64815f1

Built, run and tested on macOS Catalina 10.15.4

about_window

./src/qt/bitcoin-qt -logthreadnames -debug -printtoconsole -regtest                      (7s 63ms)  
2020-05-01T09:48:48Z Ignoring unknown configuration value regtest.natmap
2020-05-01T09:48:48Z [main] Bitcoin Core version pr18790.02 (release build)
2020-05-01T09:48:48Z [main] Qt 5.14.1 (dynamic), plugin=cocoa (dynamic)
2020-05-01T09:48:48Z [main] System: macOS 10.15, x86_64-little_endian-lp64
2020-05-01T09:48:48Z [main] Screen: Color LCD 1440x900, pixel ratio=1.0
2020-05-01T09:48:48Z [main] GUI: Populating font family aliases took 197 ms. Replace uses of missing font family ".AppleSystemUIFont,13,-1,5,50,0,0,0,0,0" with one that exists to avoid this cost. 
2020-05-01T09:48:48Z [main] Validating signatures for all blocks.
2020-05-01T09:48:48Z [main] Setting nMinimumChainWork=0000000000000000000000000000000000000000000000000000000000000000
2020-05-01T09:48:48Z [main] Using the 'sse4(1way),sse41(4way),avx2(8way)' SHA256 implementation
2020-05-01T09:48:48Z [main] Using RdSeed as additional entropy source
2020-05-01T09:48:48Z [main] Using RdRand as an additional entropy source
2020-05-01T09:48:48Z [main] GUI: requestInitialize : Requesting initialize
2020-05-01T09:48:48Z [qt-init] GUI: initialize : Running initialization in thread
2020-05-01T09:48:48Z [qt-init] Default data directory /Users/brakmic/Library/Application Support/Bitcoin
2020-05-01T09:48:48Z [qt-init] Using data directory /Users/brakmic/Library/Application Support/Bitcoin/regtest
2020-05-01T09:48:48Z [qt-init] Config file: /Users/brakmic/Library/Application Support/Bitcoin/bitcoin.conf
2020-05-01T09:48:48Z [qt-init] Config file arg: regtest="0"
2020-05-01T09:48:48Z [qt-init] Config file arg: testnet="0"
2020-05-01T09:48:48Z [qt-init] Config file arg: [main] daemon="1"
2020-05-01T09:48:48Z [qt-init] Config file arg: [main] deprecatedrpc="signrawtransaction"
2020-05-01T09:48:48Z [qt-init] Config file arg: [main] listen="1"
2020-05-01T09:48:48Z [qt-init] Config file arg: [main] port="8444"
2020-05-01T09:48:48Z [qt-init] Config file arg: [main] prune="550"
2020-05-01T09:48:48Z [qt-init] Config file arg: [main] rest="1"
2020-05-01T09:48:48Z [qt-init] Config file arg: [main] rpcallowip="127.0.0.1"
2020-05-01T09:48:48Z [qt-init] Config file arg: [main] rpcbind=****
2020-05-01T09:48:48Z [qt-init] Config file arg: [main] rpcpassword=****
2020-05-01T09:48:48Z [qt-init] Config file arg: [main] rpcport="8445"
2020-05-01T09:48:48Z [qt-init] Config file arg: [main] rpcuser=****
2020-05-01T09:48:48Z [qt-init] Config file arg: [main] server="1"
2020-05-01T09:48:48Z [qt-init] Config file arg: [main] shrinkdebugfile="1"
2020-05-01T09:48:48Z [qt-init] Config file arg: [main] zmqpubhashblock="tcp://127.0.0.1:58335"
2020-05-01T09:48:48Z [qt-init] Config file arg: [main] zmqpubhashtx="tcp://127.0.0.1:58334"
2020-05-01T09:48:48Z [qt-init] Config file arg: [main] zmqpubrawblock="tcp://127.0.0.1:58332"
2020-05-01T09:48:48Z [qt-init] Config file arg: [main] zmqpubrawtx="tcp://127.0.0.1:58333"

@hebasto
Copy link
Member Author

hebasto commented May 1, 2020

@brakmic
Thank you for reviewing. Mind particularly testing the changed threads: qt-clientmodl, qt-rpcconsole, and qt-walletctrl?

@brakmic
Copy link
Contributor

brakmic commented May 1, 2020

@brakmic
Thank you for reviewing. Mind particularly testing the changed threads: qt-clientmodl, qt-rpcconsole, and qt-walletctrl?

Yes, sure.

I was able to get qt-rpcconsole and qt-walletctrl but no matter what I do and whichever window I open, there is no qt-clientmodl in sight.

qt-rpcconsole

qt-walletctrl

@hebasto
Copy link
Member Author

hebasto commented May 1, 2020

@brakmic

... but no matter what I do and whichever window I open, there is no qt-clientmodl in sight.

It's because there is no logging in the qt-clientmodl thread. But b-qt-clientmodl should be showed by the OS via tools similar to ps, top etc.

@brakmic
Copy link
Contributor

brakmic commented May 1, 2020

@brakmic

... but no matter what I do and whichever window I open, there is no qt-clientmodl in sight.

It's because there is no logging in the qt-clientmodl thread. But b-qt-clientmodl should be showed by the OS via tools similar to ps, top etc.

Ok.

I took a sample from the running process and here's the b-qt-clientmodlthread.

qt-clientmodel

@hebasto
Copy link
Member Author

hebasto commented May 5, 2020

Rebased 64815f1 -> 6d8747d (pr18790.02 -> pr18790.03) due to the conflict with #18699.

@hebasto
Copy link
Member Author

hebasto commented May 19, 2020

Rebased 6d8747d -> f979110 (pr18790.03 -> pr18790.04) due to the conflict with #18152.

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Concept ACK, build and dumped all thread list with lld, looks good.

From https://doc.qt.io/qt-5/qthread.html

To choose the name that your thread will be given (as identified by the command ps -L on Linux, for example), you can call setObjectName() before starting the thread. If you don't call setObjectName(), the name given to your thread will be the class name of the runtime type of your thread object (for example, "RenderThread" in the case of the Mandelbrot Example, as that is the name of the QThread subclass). Note that this is currently not available with release builds on Windows.

Is it because of the above windows issue that you don't use setObjectName? Not sure if that even maters to us.

@hebasto
Copy link
Member Author

hebasto commented Jun 2, 2020

@promag

Is it because of the above windows issue that you don't use setObjectName? Not sure if that even maters to us.

Using setObjectName() does not work for our logging with thread names.

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

ACK f979110

@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 9, 2020

Gitian builds

File commit 9573d2b
(master)
commit d7ac184
(master and this pull)
*-aarch64-linux-gnu-debug.tar.gz e092833e8bc7a590... ae361942d0011529...
*-aarch64-linux-gnu.tar.gz 9d4f23ed812ccc3c... 0173970597aa9fcd...
*-arm-linux-gnueabihf-debug.tar.gz 59794fcb8b141049... 6cb424f9746e755c...
*-arm-linux-gnueabihf.tar.gz 7dda786a40d23245... 729c3e9c93f50264...
*-osx-unsigned.dmg f43b723fc0491aa5... 660ac8a6902be589...
*-osx64.tar.gz 4635b4bc5ecde0e2... 93f4f6c1c39414a0...
*-riscv64-linux-gnu-debug.tar.gz bdd3128818116892... 9f0cd1313be1b8ee...
*-riscv64-linux-gnu.tar.gz 70e73b9bd66cc363... df3c3d93fde6774f...
*-win64-debug.zip 6c3048443290eadc... ccd7bff4d348726b...
*-win64-setup-unsigned.exe 2ceef94656b66c4b... b404dcfa1029bbf3...
*-win64.zip 37c9e5183b6a6491... 4e4c2883500cce23...
*-x86_64-linux-gnu-debug.tar.gz 98c18ae66b7ff173... 3eca72e70ac170ed...
*-x86_64-linux-gnu.tar.gz 4d95d8abfe7665e1... 2c2dc98cbcd2c1bc...
*.tar.gz b5211f42c22c6a7e... 07fcef7337a379de...
bitcoin-core-linux-0.21-res.yml 0d18708214e0fd79... 2f6bcb26066dc604...
bitcoin-core-osx-0.21-res.yml 4d41949eba545356... 2ae4cc85a53c6d9f...
bitcoin-core-win-0.21-res.yml fa8a7240e220cc6e... c69381443077fbbb...
linux-build.log e9f33fa744efbeea... 35e3adfd71132f32...
osx-build.log 6589b020fa210d97... a05934dbca3740ff...
win-build.log 58b4da2f4b194b38... 0ec5051ed72505fa...
bitcoin-core-linux-0.21-res.yml.diff 2194cbd0d06cc034...
bitcoin-core-osx-0.21-res.yml.diff 104571e0f443b20f...
bitcoin-core-win-0.21-res.yml.diff 8e6fafb15a072c79...
linux-build.log.diff a2f14aa723150c51...
osx-build.log.diff 1566cb8e53954cae...
win-build.log.diff 60da6f8ac6b4bc5b...

@Sjors
Copy link
Member

Sjors commented Jun 19, 2020

Concept ACK

@hebasto hebasto force-pushed the 200427-name-qthread branch from f979110 to ead771b Compare August 13, 2020 13:40
@hebasto
Copy link
Member Author

hebasto commented Aug 13, 2020

Rebased f979110 -> ead771b (pr18790.04 -> pr18790.05) due to the conflict with #19011.

@fanquake
Copy link
Member

Planning on reviewing (shortly) and merging this PR in this repo. @promag @jb55 @jonatack @Sjors want to take another look here?

@Sjors
Copy link
Member

Sjors commented Sep 17, 2020

tACK ead771b

@fanquake fanquake merged commit 83b2384 into bitcoin:master Sep 19, 2020
@hebasto hebasto deleted the 200427-name-qthread branch September 19, 2020 09:34
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 20, 2020
ead771b qt: Rename qt-init thread before logging start (Hennadii Stepanov)
ad5f614 qt: Name ClientModel timer QThread (Hennadii Stepanov)
2c7f5d8 qt: Name WalletController worker QThread (Hennadii Stepanov)
27dcc37 qt: Name RPCConsole executor QThread (Hennadii Stepanov)

Pull request description:

  On **master** (eef90c1):
  - thread list from OS:
  ![Screenshot from 2020-04-28 00-25-41](https://user-images.githubusercontent.com/32963518/80425413-3de07100-88ec-11ea-8d7a-79bd9e152395.png)
  - log excerpt:
  ```
  2020-04-27T21:25:26Z [] GUI: initialize : Running initialization in thread
  ...
  2020-04-27T21:26:04Z [] Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
  2020-04-27T21:26:04Z [] Using wallet /home/hebasto/.bitcoin/testnet3/wallets/test2
  2020-04-27T21:26:04Z [] BerkeleyEnvironment::Open: LogDir=/home/hebasto/.bitcoin/testnet3/wallets/test2/database ErrorFile=/home/hebasto/.bitcoin/testnet3/wallets/test2/db.log
  2020-04-27T21:26:04Z [] init message: Loading wallet...
  2020-04-27T21:26:04Z [] BerkeleyEnvironment::Open: LogDir=/home/hebasto/.bitcoin/testnet3/wallets/test2/database ErrorFile=/home/hebasto/.bitcoin/testnet3/wallets/test2/db.log
  2020-04-27T21:26:04Z [] [test2] Wallet File Version = 169900
  2020-04-27T21:26:04Z [] [test2] Keys: 2001 plaintext, 0 encrypted, 2001 w/ metadata, 2001 total. Unknown wallet records: 0
  2020-04-27T21:26:04Z [] [test2] Wallet completed loading in              26ms
  2020-04-27T21:26:04Z [] GUI: TransactionTablePriv::refreshWallet
  2020-04-27T21:26:04Z [] [test2] setKeyPool.size() = 2000
  2020-04-27T21:26:04Z [] [test2] mapWallet.size() = 0
  2020-04-27T21:26:04Z [] [test2] m_address_book.size() = 0
  ```

  With **this PR**:
  - thread list from OS:
  ![Screenshot from 2020-04-28 00-21-40](https://user-images.githubusercontent.com/32963518/80425527-7a13d180-88ec-11ea-8a34-dfc774bb1c75.png)
  - log excerpt:
  ```
  2020-04-27T21:21:25Z [qt-init] GUI: initialize : Running initialization in thread
  ...
  2020-04-27T21:23:08Z [qt-walletctrl] Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
  2020-04-27T21:23:08Z [qt-walletctrl] Using wallet /home/hebasto/.bitcoin/testnet3/wallets/test2
  2020-04-27T21:23:08Z [qt-walletctrl] BerkeleyEnvironment::Open: LogDir=/home/hebasto/.bitcoin/testnet3/wallets/test2/database ErrorFile=/home/hebasto/.bitcoin/testnet3/wallets/test2/db.log
  2020-04-27T21:23:08Z [qt-walletctrl] init message: Loading wallet...
  2020-04-27T21:23:08Z [qt-walletctrl] BerkeleyEnvironment::Open: LogDir=/home/hebasto/.bitcoin/testnet3/wallets/test2/database ErrorFile=/home/hebasto/.bitcoin/testnet3/wallets/test2/db.log
  2020-04-27T21:23:08Z [qt-walletctrl] [test2] Wallet File Version = 169900
  2020-04-27T21:23:08Z [qt-walletctrl] [test2] Keys: 2001 plaintext, 0 encrypted, 2001 w/ metadata, 2001 total. Unknown wallet records: 0
  2020-04-27T21:23:08Z [qt-walletctrl] [test2] Wallet completed loading in              37ms
  2020-04-27T21:23:08Z [qt-walletctrl] init message: Rescanning...
  2020-04-27T21:23:08Z [qt-walletctrl] [test2] Rescanning last 112924 blocks (from block 1609206)...
  2020-04-27T21:23:08Z [qt-walletctrl] [test2] Rescan started from block 000000000000003761c81f7efbd8cebf217f39d353ec1ac59c624ac2dddfc2a8...
  2020-04-27T21:23:22Z [qt-walletctrl] [test2] Rescan completed in           14157ms
  2020-04-27T21:23:22Z [qt-walletctrl] GUI: TransactionTablePriv::refreshWallet
  2020-04-27T21:23:22Z [qt-walletctrl] [test2] setKeyPool.size() = 2000
  2020-04-27T21:23:22Z [qt-walletctrl] [test2] mapWallet.size() = 0
  2020-04-27T21:23:22Z [qt-walletctrl] [test2] m_address_book.size() = 0
  ```

ACKs for top commit:
  Sjors:
    tACK ead771b

Tree-SHA512: a3b2789990414ab23b69236ca36b656a3f026e11e88fb5940ef4fecfc2053df5ed886615afb37f98584f6e19b953209d3884baab057740b2e9eed68661880dd3
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 11, 2021
Summary:
> qt: Name RPCConsole executor QThread

> qt: Name WalletController worker QThread

> qt: Name ClientModel timer QThread

> qt: Rename qt-init thread before logging start

This is a backport of [[bitcoin/bitcoin#18790 | core#18790]]

Test Plan:
```
$ ninja && src/qt/bitcoin-qt
$ ps -T -p $( ps -ef | grep bitcoin-qt | grep -v "grep" | awk '{print $2}')
    PID    SPID TTY          TIME CMD
  31348   31348 pts/1    00:00:00 bitcoin-qt
  31348   31349 pts/1    00:00:00 QXcbEventQueue
  31348   31350 pts/1    00:00:00 gmain
  31348   31351 pts/1    00:00:00 gdbus
  31348   31352 pts/1    00:00:00 QDBusConnection
  31348   31378 pts/1    00:00:01 b-qt-init
  31348   31379 pts/1    00:00:00 b-scriptch.0
  31348   31380 pts/1    00:00:00 b-scriptch.1
  31348   31381 pts/1    00:00:00 b-scriptch.2
  31348   31382 pts/1    00:00:00 b-scriptch.3
  31348   31383 pts/1    00:00:00 b-scriptch.4
  31348   31384 pts/1    00:00:00 b-scriptch.5
  31348   31385 pts/1    00:00:00 b-scriptch.6
  31348   31386 pts/1    00:00:00 b-scriptch.7
  31348   31387 pts/1    00:00:00 b-scriptch.8
  31348   31388 pts/1    00:00:00 b-scriptch.9
  31348   31389 pts/1    00:00:00 b-scriptch.10
  31348   31390 pts/1    00:00:00 b-scriptch.11
  31348   31391 pts/1    00:00:00 b-scriptch.12
  31348   31392 pts/1    00:00:00 b-scriptch.13
  31348   31393 pts/1    00:00:00 b-scriptch.14
  31348   31394 pts/1    00:00:00 b-scheduler
  31348   31395 pts/1    00:00:00 b-qt-init
  31348   31399 pts/1    00:00:00 b-torcontrol
  31348   31400 pts/1    00:00:00 b-net
  31348   31402 pts/1    00:00:00 b-addcon
  31348   31403 pts/1    00:00:00 b-opencon
  31348   31404 pts/1    00:00:00 b-msghand
  31348   31405 pts/1    00:00:00 b-qt-clientmodl
  31348   31406 pts/1    00:00:00 b-qt-rpcconsole
  31348   31407 pts/1    00:00:00 b-qt-walletctrl
  31348   31409 pts/1    00:00:00 Qt bearer threa
```

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D10280
@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.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants