0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-21 12:22:50 -05:00
bitcoin-bitcoin-core/src/wallet
Ryan Ofsky 6300438a2e
Merge bitcoin/bitcoin#30115: rpc: avoid copying into UniValue
d7707d9843 rpc: avoid copying into UniValue (Cory Fields)

Pull request description:

  These are the simple (and hopefully obviously correct) copies that can be moves instead.

  This is a follow-up from https://github.com/bitcoin/bitcoin/pull/30094#issuecomment-2108751842

  As it turns out, there are hundreds of places where we copy UniValues needlessly. It should be the case that moves are always preferred over copies, so there should be no downside to these changes.

  willcl-ark, however, noticed that memory usage may increase in some cases. Logically this makes no sense to me. The only plausible explanation imo is that because the moves are faster, more ops/second occur in some cases.

  This list of moves was obtained by changing the function signatures of the UniValue functions to accept only rvalues, then compiling and fixing them up one by one. There still exist many places where copies are being made. These can/should be fixed up, but weren't done here for the sake of doing the easy ones first.

  I ran these changes through clang-tidy with `performance-move-const-arg` and `bugprone-use-after-move` and no bugs were detected (though that's obviously not to say it can be trusted 100%).

  As stated above, there are still lots of other less trivial fixups to do after these including:
  - Using non-const UniValues where possible so that moves can happen
  - Refactoring code in order to be able to move a UniValue without introducing a use-after-move
  - Refactoring functions to accept UniValues by value rather than by const reference

ACKs for top commit:
  achow101:
    ACK d7707d9843
  ryanofsky:
    Code review ACK d7707d9843. No changes since last review other than rebase. I agree benchmarks showing increased peak memory usage and RSS are surprising, but number of allocations is down as expected, and runtime is also decreased.
  willcl-ark:
    ACK d7707d9843

Tree-SHA512: 7f511be73984553c278186286a7d161a34b2574c7f5f1a0edc87c2913b4c025a0af5241ef9af2df17547f2e4ef79710aa5bbb762fc9472435781c0488dba3435
2024-05-23 10:53:37 -04:00
..
rpc rpc: avoid copying into UniValue 2024-05-20 16:48:19 +00:00
test Merge bitcoin/bitcoin#30115: rpc: avoid copying into UniValue 2024-05-23 10:53:37 -04:00
bdb.cpp bdb: Be able to make byteswapped databases 2024-05-16 15:03:13 -04:00
bdb.h bdb: Be able to make byteswapped databases 2024-05-16 15:03:13 -04:00
coincontrol.cpp wallet: Explicitly preserve scriptSig and scriptWitness in CreateTransaction 2023-12-08 17:12:19 -05:00
coincontrol.h wallet: Explicitly preserve scriptSig and scriptWitness in CreateTransaction 2023-12-08 17:12:19 -05:00
coinselection.cpp opt: Skip over barren combinations of tiny UTXOs 2024-02-09 11:03:18 +01:00
coinselection.h coinselection: Track whether CG completed 2024-02-09 10:50:10 +01:00
context.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
context.h interfaces: Add schedulerMockForward method so mockscheduler RPC can work across processes 2023-10-20 10:30:16 -04:00
crypter.cpp refactor: Remove unused C-style casts 2023-07-24 15:32:00 +02:00
crypter.h scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
db.cpp wallet: implement BerkeleyROBatch 2024-05-13 23:01:37 -04:00
db.h bdb: Be able to make byteswapped databases 2024-05-16 15:03:13 -04:00
dump.cpp bdb: Be able to make byteswapped databases 2024-05-16 15:03:13 -04:00
dump.h wallettool: Don't create CWallet when dumping DB 2023-12-19 16:54:06 -05:00
external_signer_scriptpubkeyman.cpp wallet: return and display signer error 2024-04-16 17:47:43 +02:00
external_signer_scriptpubkeyman.h wallet: return and display signer error 2024-04-16 17:47:43 +02:00
feebumper.cpp test: wallet, fix change position out of range error 2023-12-12 15:20:38 -03:00
feebumper.h rpc: bumpfee, improve doc for 'reduce_output' arg 2023-09-26 20:17:02 -03:00
fees.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
fees.h
init.cpp Merge bitcoin/bitcoin#26606: wallet: Implement independent BDB parser 2024-05-21 10:05:09 +01:00
interfaces.cpp Merge bitcoin/bitcoin#24313: Improve display address handling for external signer 2024-04-23 17:20:54 -04:00
load.cpp interfaces: Add schedulerMockForward method so mockscheduler RPC can work across processes 2023-10-20 10:30:16 -04:00
load.h interfaces: Add schedulerMockForward method so mockscheduler RPC can work across processes 2023-10-20 10:30:16 -04:00
migrate.cpp Error if LSNs are not reset 2024-05-16 15:03:13 -04:00
migrate.h Add MakeBerkeleyRODatabase 2024-05-16 15:03:13 -04:00
receive.cpp [clang-tidy] Enable the misc-no-recursion check 2024-04-07 14:04:45 +01:00
receive.h wallet: Add wallet/types.h for simple public enum and struct types 2023-04-11 15:52:25 -04:00
salvage.cpp tidy: modernize-use-emplace 2023-10-12 11:27:19 +02:00
salvage.h refactor: Move fs.* to util/fs.* 2023-03-23 12:55:18 +01:00
scriptpubkeyman.cpp [clang-tidy] Enable the misc-no-recursion check 2024-04-07 14:04:45 +01:00
scriptpubkeyman.h wallet: return and display signer error 2024-04-16 17:47:43 +02:00
spend.cpp refactor: Avoid copying util::Result values 2024-04-25 16:08:24 -04:00
spend.h refactor: pass CRecipient to FundTransaction 2024-01-19 15:04:56 +01:00
sqlite.cpp scripted-diff: Add IWYU pragma keep to bitcoin-config.h includes 2024-05-01 08:33:04 +02:00
sqlite.h sqlite: Ensure that only one SQLiteBatch is writing to db at a time 2024-02-06 12:24:36 -05:00
transaction.cpp scripted-diff: wallet: s/TxStateConflicted/TxStateBlockConflicted 2024-03-14 17:38:39 -04:00
transaction.h wallet: track mempool conflicts 2024-03-20 15:05:34 -04:00
types.h wallet: add AddressPurpose enum to replace string values 2023-04-11 15:52:25 -04:00
wallet.cpp Merge bitcoin/bitcoin#26606: wallet: Implement independent BDB parser 2024-05-21 10:05:09 +01:00
wallet.h wallet: return and display signer error 2024-04-16 17:47:43 +02:00
walletdb.cpp Merge bitcoin/bitcoin#26606: wallet: Implement independent BDB parser 2024-05-21 10:05:09 +01:00
walletdb.h wallet: db, introduce 'RunWithinTxn()' helper function 2024-02-12 16:05:14 -03:00
wallettool.cpp Merge bitcoin/bitcoin#26606: wallet: Implement independent BDB parser 2024-05-21 10:05:09 +01:00
wallettool.h
walletutil.cpp wallet, descspkm: Refactor wallet descriptor generation to standalone func 2024-03-20 16:15:43 -04:00
walletutil.h wallet, descspkm: Refactor wallet descriptor generation to standalone func 2024-03-20 16:15:43 -04:00