aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
AgeCommit message (Collapse)Author
2018-03-09Format timestamps using ISO 8601 formatting (e.g. "2018-02-28T12:34:56Z")practicalswift
* Z is the zone designator for the zero UTC offset. * T is the delimiter used to separate date and time. This makes it clear for the end-user that the date/time logged is specified in UTC and not in the local time zone.
2018-03-06Merge #10271: Use std::thread::hardware_concurrency, instead of Boost, to ↵Wladimir J. van der Laan
determine available cores 937bf4335 Use std::thread::hardware_concurrency, instead of Boost, to determine available cores (fanquake) Pull request description: Following discussion on IRC about replacing Boost usage for detecting available system cores, I've opened this to collect some benchmarks + further discussion. The current method for detecting available cores was introduced in #6361. Recap of the IRC chat: ``` 21:14:08 fanquake: Since we seem to be giving Boost removal a good shot for 0.15, does anyone have suggestions for replacing GetNumCores? 21:14:26 fanquake: There is std::thread::hardware_concurrency(), but that seems to count virtual cores, which I don't think we want. 21:14:51 BlueMatt: fanquake: I doubt we'll do boost removal for 0.15 21:14:58 BlueMatt: shit like BOOST_FOREACH, sure 21:15:07 BlueMatt: but all of boost? doubtful, there are still things we need 21:16:36 fanquake: Yea sorry, not the whole lot, but we can remove a decent chunk. Just looking into what else needs to be done to replace some of the less involved Boost usage. 21:16:43 BlueMatt: fair 21:17:14 wumpus: yes, it makes sense to plan ahead a bit, without immediately doing it 21:18:12 wumpus: right, don't count virtual cores, that used to be the case but it makes no sense for our usage 21:19:15 wumpus: it'd create a swarm of threads overwhelming any machine with hyperthreading (+accompanying thread stack overhead), for script validation, and there was no gain at all for that 21:20:03 sipa: BlueMatt: don't worry, there is no hurry 21:59:10 morcos: wumpus: i don't think that is correct 21:59:24 morcos: suppose you have 4 cores (8 virtual cores) 21:59:24 wumpus: fanquake: indeed seems that std has no equivalent to physical_concurrency, on any standard. That's annoying as it is non-trivial to implement 21:59:35 morcos: i think running par=8 (if it let you) would be notably faster 21:59:59 morcos: jeremyrubin and i discussed this at length a while back... i think i commented about it on irc at the time 22:00:21 wumpus: morcos: I think the conclusion at the time was that it made no difference, but sure would make sense to benchmark 22:00:39 morcos: perhaps historical testing on the virtual vs actual cores was polluted by concurrency issues that have now improved 22:00:47 wumpus: I think there are not more ALUs, so there is not really a point in having more threads 22:01:40 wumpus: hyperthreads are basically just a stored register state right? 22:02:23 sipa: wumpus: yes but it helps the scheduler 22:02:27 wumpus: in which case the only speedup using "number of cores" threads would give you is, possibly, excluding other software from running on the cores on the same time 22:02:37 morcos: well this is where i get out of my depth 22:02:50 sipa: if one of the threads is waiting on a read from ram, the other can use the arithmetic unit for example 22:02:54 morcos: wumpus: i'm pretty sure though that the speed up is considerably more than what you might expect from that 22:02:59 wumpus: sipa: ok, I back down, I didn't want to argue this at all 22:03:35 morcos: the reason i haven't tested it myself, is the machine i usually use has 16 cores... so not easy due to remaining concurrency issues to get much more speedup 22:03:36 wumpus: I'm fine with restoring it to number of virtual threads if that's faster 22:03:54 morcos: we should have somene with 4 cores (and  actually test it though, i agree 22:03:58 sipa: i would expect (but we should benchmark...) that if 8 scriot validation threads instead of 4 on a quadcore hyperthreading is not faster, it's due to lock contention 22:04:20 morcos: sipa: yeah thats my point, i think lock contention isn't that bad with 8 now 22:04:22 wumpus: on 64-bit systems the additional thread overhead wouldn't be important at least 22:04:23 gmaxwell: I previously benchmarked, a long time ago, it was faster. 22:04:33 gmaxwell: (to use the HT core count) 22:04:44 wumpus: why was this changed at all then? 22:04:47 wumpus: I'm confused 22:05:04 sipa: good question! 22:05:06 gmaxwell: I had no idea we changed it. 22:05:25 wumpus: sigh  22:05:54 gmaxwell: What PR changed it? 22:06:51 gmaxwell: In any case, on 32-bit it's probably a good tradeoff... the extra ram overhead is worth avoiding. 22:07:22 wumpus: https://github.com/bitcoin/bitcoin/pull/6361 22:07:28 gmaxwell: PR 6461 btw. 22:07:37 gmaxwell: er lol at least you got it right. 22:07:45 wumpus: the complaint was that systems became unsuably slow when using that many thread 22:07:51 wumpus: so at least I got one thing right, woohoo 22:07:55 sipa: seems i even acked it! 22:07:57 BlueMatt: wumpus: there are more alus 22:08:38 BlueMatt: but we need to improve lock contention first 22:08:40 morcos: anywya, i think in the past the lock contention made 8 threads regardless of cores a bit dicey.. now that is much better (although more still to be done) 22:09:01 BlueMatt: or we can just merge #10192, thats fee 22:09:04 gribble: https://github.com/bitcoin/bitcoin/issues/10192 | Cache full script execution results in addition to signatures by TheBlueMatt · Pull Request #10192 · bitcoin/bitcoin · GitHub 22:09:11 BlueMatt: s/fee/free/ 22:09:21 morcos: no, we do not need to improve lock contention first. but we should probably do that before we increase the max beyond 16 22:09:26 BlueMatt: then we can toss concurrency issues out the window and get more speedup anyway 22:09:35 gmaxwell: wumpus: yea, well in QT I thought we also diminished the count by 1 or something? but yes, if the motivation was to reduce how heavily the machine was used, thats fair. 22:09:56 sipa: the benefit of using HT cores is certainly not a factor 2 22:09:58 wumpus: gmaxwell: for the default I think this makes a lot of sense, yes 22:10:10 gmaxwell: morcos: right now on my 24/28 physical core hosts going beyond 16 still reduces performance. 22:10:11 wumpus: gmaxwell: do we also restrict the maximum par using this? that'd make less sense 22:10:51 wumpus: if someone *wants* to use the virtual cores they should be able to by setting -par= 22:10:51 sipa: *flies to US* 22:10:52 BlueMatt: sipa: sure, but the shared cache helps us get more out of it than some others, as morcos points out 22:11:30 BlueMatt: (because it means our thread contention issues are less) 22:12:05 morcos: gmaxwell: yeah i've been bogged down in fee estimation as well (and the rest of life) for a while now.. otherwise i would have put more effort into jeremy's checkqueue 22:12:36 BlueMatt: morcos: heh, well now you can do other stuff while the rest of us get bogged down in understanding fee estimation enough to review it  22:12:37 wumpus: [to answer my own question: no, the limit for par is MAX_SCRIPTCHECK_THREADS, or 16] 22:12:54 morcos: but to me optimizing for more than 16 cores is pretty valuable as miners could use beefy machines and be less concerned by block validation time 22:14:38 BlueMatt: morcos: i think you may be surprised by the number of mining pools that are on VPSes that do not have 16 cores  22:15:34 gmaxwell: I assume right now most of the time block validation is bogged in the parts that are not as concurrent. simple because caching makes the concurrent parts so fast. (and soon to hopefully increase with bluematt's patch) 22:17:55 gmaxwell: improving sha2 speed, or transaction malloc overhead are probably bigger wins now for connection at the tip than parallelism beyond 16 (though I'd like that too). 22:18:21 BlueMatt: sha2 speed is big 22:18:27 morcos: yeah lots of things to do actually... 22:18:57 gmaxwell: BlueMatt: might be a tiny bit less big if we didn't hash the block header 8 times for every block.  22:21:27 BlueMatt: ehh, probably, but I'm less rushed there 22:21:43 BlueMatt: my new cache thing is about to add a bunch of hashing 22:21:50 BlueMatt: 1 sha round per tx 22:22:25 BlueMatt: and sigcache is obviously a ton ``` Tree-SHA512: a594430e2a77d8cc741ea8c664a2867b1e1693e5050a4bbc8511e8d66a2bffe241a9965f6dff1e7fbb99f21dd1fdeb95b826365da8bd8f9fab2d0ffd80d5059c
2018-02-15test: Add unit test for LockDirectoryWladimir J. van der Laan
Add a unit test for LockDirectory, introduced in #11281.
2018-02-15util: Fix multiple use of LockDirectoryWladimir J. van der Laan
This commit fixes problems with calling LockDirectory multiple times on the same directory, or from multiple threads. It also fixes the build on OpenBSD. - Wrap the boost::interprocess::file_lock in a std::unique_ptr inside the map that keeps track of per-directory locks. This fixes a build issue with the clang 4.0.0+boost-1.58.0p8 version combo on OpenBSD 6.2, and should have no observable effect otherwise. - Protect the locks map using a mutex. - Make sure that only locks that are successfully acquired are inserted in the map. - Open the lock file for appending only if we know we don't have the lock yet - The `FILE* file = fsbridge::fopen(pathLockFile, "a");` wipes the 'we own this lock' administration, likely because it opens a new fd for the locked file then closes it.
2018-02-05Add AbsPathForConfigVal to consolidate datadir prefixing for path argsJames O'Beirne
Most commandline/config args are interpreted as relative to datadir if not passed absolute. Consolidate the logic for this normalization.
2018-01-16Abstract directory locking into util.cppMeshCollider
2018-01-03Increment MIT Licence copyright header year on files modified in 2017Akira Takizawa
2017-12-15Use std::thread::hardware_concurrency, instead of Boost, to determine ↵fanquake
available cores
2017-12-12Merge #10574: Remove includes in .cpp files for things the corresponding .h ↵Wladimir J. van der Laan
file already included a720b92 Remove includes in .cpp files for things the corresponding .h file already included (practicalswift) Pull request description: Remove includes in .cpp files for things the corresponding .h file already included. Example case: * `addrdb.cpp` includes `addrdb.h` and `fs.h` * `addrdb.h` includes `fs.h` Then remove the direct inclusion of `fs.h` in `addrman.cpp` and rely on the indirect inclusion of `fs.h` via the included `addrdb.h`. In line with the header include guideline (see #10575). Tree-SHA512: 8704b9de3011a4c234db336a39f7d2c139e741cf0f7aef08a5d3e05197e1e18286b863fdab25ae9638af4ff86b3d52e5cab9eed66bfa2476063aa5c79f9b0346
2017-12-06Test datadir in conf file existsMeshCollider
2017-11-30Add `-debuglogfile` optionWladimir J. van der Laan
This patch adds an option to configure the name and/or directory of the debug log. The user can specify either a relative path, in which case the path is relative to the data directory. They can also specify an absolute path to put the log anywhere else in the file system.
2017-11-30Merge #11191: RPC: Improve help text and behavior of RPC-logging.Wladimir J. van der Laan
c60c49b Improve help text and behavior of RPC-logging (Akio Nakamura) Pull request description: 1. It is allowed `libevent` logging to be updated during runtime, but still described that restriction in the help text. So we delete these text. 2. Add a descrption about the evaluation order of `<include>` and `<exclude>` to clarify how debug loggig categories to be set. 3. Add a description about the available logging category `"all"` which is not explained. 4. Add `"optional"` to the help text of `<include>` and `<exclude>`. 5. Add missing new lines before `"Argument:"`. 6. `"0"`,`"1"` are allowed in both array of `<include>` and `<exclude>`. `"0"` is **ignored** and `"1"` is treated **same as** `"all"`. It is confusing, so forbid them. 7. It always returns all logging categories with status. Fix the help text to match this behavior. Tree-SHA512: c2142da1a9bf714af8ebc38ac0d82394e2073fc0bd56f136372e3db7b2af3b6746f8d6b0241fe66c1698c208c124deb076be83f07dec0d0a180ad150593af415
2017-11-20Improve help text and behavior of RPC-loggingAkio Nakamura
A) The changes in behavior are as follows: 1. Introduce logging category "none" as alias of "0" for both RPC-logging and bitcoind "-debug" parameter. 2. Same as "0" is given to argument of "-debug", if "none" or "0" is given to <include>, all other given logging categories are ignored. The same is true for <exclude>. (Before this PR, "0" was accepted but just be ignored itself.) B) The changes in the help text are as follows: 1. Add a descrption about the evaluation order of <include> and <exclude> to clarify how debug loggig categories to be set. 2. Delete text that describe restriction about libevent because it's already allowed libevent logging to be updated during runtime. 3. Add a description for category "all", "1", "none" and "0". 4. Add "optional" to the help text of <include> and <exclude>. 5. Add missing new lines before "Argument:". 6. This RPC always returns all logging categories with status. Fix the help text to match this behavior.
2017-11-18Create walletdir if datadir doesn't exist and fix testsMeshCollider
2017-11-16Remove includes in .cpp files for things the corresponding .h file already ↵practicalswift
included
2017-11-16scripted-diff: Replace #include "" with #include <> (ryanofsky)MeshCollider
-BEGIN VERIFY SCRIPT- for f in \ src/*.cpp \ src/*.h \ src/bench/*.cpp \ src/bench/*.h \ src/compat/*.cpp \ src/compat/*.h \ src/consensus/*.cpp \ src/consensus/*.h \ src/crypto/*.cpp \ src/crypto/*.h \ src/crypto/ctaes/*.h \ src/policy/*.cpp \ src/policy/*.h \ src/primitives/*.cpp \ src/primitives/*.h \ src/qt/*.cpp \ src/qt/*.h \ src/qt/test/*.cpp \ src/qt/test/*.h \ src/rpc/*.cpp \ src/rpc/*.h \ src/script/*.cpp \ src/script/*.h \ src/support/*.cpp \ src/support/*.h \ src/support/allocators/*.h \ src/test/*.cpp \ src/test/*.h \ src/wallet/*.cpp \ src/wallet/*.h \ src/wallet/test/*.cpp \ src/wallet/test/*.h \ src/zmq/*.cpp \ src/zmq/*.h do base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f done -END VERIFY SCRIPT-
2017-10-04Merge #10939: [init] Check non-emptiness of -blocknotify command prior to ↵Wladimir J. van der Laan
executing cffe85f Skip sys::system(...) call in case of empty command (practicalswift) 6fb8f5f Check that -blocknotify command is non-empty before executing (practicalswift) Pull request description: Check that `-blocknotify` command is non-empty before executing. To make the `BlockNotifyCallback(...)` (`-blocknotify`) behaviour consistent with that of: * `AlertNotify(...)` (`-alertnotify`) * `AddToWallet(...)` (`-walletnotify`) Tree-SHA512: 18272166793a5a8b9cc2a727bfbcea53d38c329a55bc975c02db601329d608a61c20e026ce4b616193ecd3810dca4d3e2cb3bf773898a51872008a8dba96763e
2017-08-16Merge #10901: Fix constness of ArgsManager methodsMarcoFalke
a622a1768 Fix constness of ArgsManager methods (João Barbosa) Pull request description: Make `cs_args` mutex mutable so that const methods can acquire it. There's also tiny performance improvement by avoiding two map lookups when retrieving an argument value. Tree-SHA512: ece58469745f2743b4b643242b51889a3d9c5b76492ed70bb74d4e5b378fff59da79fc129e499da779bf9f488c9435dda17ad1f3a804c1c30f56af422389e8bd
2017-08-14Skip sys::system(...) call in case of empty commandpracticalswift
2017-08-14remove unused gArgs wrappersMarko Bencun
2017-08-07scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal ↵practicalswift
instead of the macro NULL -BEGIN VERIFY SCRIPT- sed -i 's/\<NULL\>/nullptr/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h src/qt/*/*.cpp src/qt/*/*.h src/wallet/*/*.cpp src/wallet/*/*.h src/support/allocators/*.h sed -i 's/Prefer nullptr, otherwise SAFECOOKIE./Prefer NULL, otherwise SAFECOOKIE./g' src/torcontrol.cpp sed -i 's/tor: Using nullptr authentication/tor: Using NULL authentication/g' src/torcontrol.cpp sed -i 's/METHODS=nullptr/METHODS=NULL/g' src/test/torcontrol_tests.cpp src/torcontrol.cpp sed -i 's/nullptr certificates/NULL certificates/g' src/qt/paymentserver.cpp sed -i 's/"nullptr"/"NULL"/g' src/torcontrol.cpp src/test/torcontrol_tests.cpp -END VERIFY SCRIPT-
2017-07-24Fix constness of ArgsManager methodsJoão Barbosa
2017-06-27Merge #10118: Util: Remove redundant calls to argsGlobal.IsArgSet()Wladimir J. van der Laan
ed866ab Indentation after 'Remove redundant calls to gArgs.IsArgSet()' (Jorge Timón) 506b700 Util: Remove redundant calls to gArgs.IsArgSet() (Jorge Timón) Tree-SHA512: 4f97a0bf2a76c0f351a6343db62898cf057d745c848de00fa09465e870a120f28e0d836cafd6a047f4ec0da7ab671aebee43fa7410c9f0e66382edd1bb2009ba
2017-06-27Util: Remove redundant calls to gArgs.IsArgSet()Jorge Timón
Return empty std::vector<std::string> with ArgsManager::GetArgs if nothing is set for that string
2017-06-25[RPC] Add an uptime command that displays the amount of time that bitcoind ↵Ricardo Velhote
has been running
2017-06-14Merge #9895: Turn TryCreateDirectory() into TryCreateDirectories()Wladimir J. van der Laan
1d1ea9f Turn TryCreateDirectory() into TryCreateDirectories() (Marko Bencun) Tree-SHA512: 49a524167bcf66e351a964c88d09cb3bcee12769a32da83410e3ba649fa4bcdbf0478d41e4d09bb55adb9b3f122e742271db6feb30bbafe2a7973542b5f10f79
2017-06-14Turn TryCreateDirectory() into TryCreateDirectories()Marko Bencun
Use case: TryCreateDirectory(GetDataDir() / "blocks" / "index") would fail if the blocks directory was not explicitly created before. The line that did so was in a weird location and could be removed as a result.
2017-06-12Merge #8694: Basic multiwallet supportWladimir J. van der Laan
c237bd7 wallet: Update formatting (Luke Dashjr) 9cbe8c8 wallet: Forbid -salvagewallet, -zapwallettxes, and -upgradewallet with multiple wallets (Luke Dashjr) a2a5f3f wallet: Base backup filenames on original wallet filename (Luke Dashjr) b823a4c wallet: Include actual backup filename in recovery warning message (Luke Dashjr) 84dcb45 Bugfix: wallet: Fix warningStr, errorStr argument order (Luke Dashjr) 008c360 Wallet: Move multiwallet sanity checks to CWallet::Verify, and do other checks on all wallets (Luke Dashjr) 0f08575 Wallet: Support loading multiple wallets if -wallet used more than once (Luke Dashjr) b124cf0 Wallet: Replace pwalletMain with a vector of wallet pointers (Luke Dashjr) 19b3648 CWalletDB: Store the update counter per wallet (Luke Dashjr) 74e8738 Bugfix: ForceSetArg should replace entr(ies) in mapMultiArgs, not append (Luke Dashjr) 23fb9ad wallet: Move nAccountingEntryNumber from static/global to CWallet (Luke Dashjr) 9d15d55 Bugfix: wallet: Increment "update counter" when modifying account stuff (Luke Dashjr) f28eb80 Bugfix: wallet: Increment "update counter" only after actually making the applicable db changes to avoid potential races (Luke Dashjr) Tree-SHA512: 23f5dda58477307bc07997010740f1dc729164cdddefd2f9a2c9c7a877111eb1516d3e2ad4f9b104621f0b7f17369c69fcef13d28b85cb6c01d35f09a8845f23
2017-06-09Remove unused Boost includespracticalswift
2017-06-05Bugfix: ForceSetArg should replace entr(ies) in mapMultiArgs, not appendLuke Dashjr
2017-05-16Merge #10383: [logging] log system time and mock timeWladimir J. van der Laan
761392d [logging] log system time and mock time (John Newbery) Tree-SHA512: 0a4b3ad74bcac201be490fe12e4b45adeabc39030ac46f40e1aeb2a20b2f3963e4468e65798d8aaeca1818759cab55ff2b2aa214500aa11571492c3301dd31c1
2017-05-10[logging] log system time and mock timeJohn Newbery
2017-05-09Util: Put mapMultiArgs inside ArgsManagerJorge Timón
- Set ArgsManager::mapMultiArgs in ArgsManager::SoftSetArg, ForceSetArg, SoftSetBoolArg
2017-05-09Util: Create ArgsManager class...Jorge Timón
- Introduce ArgsManager::GetArgs() - Adapt util_tests.cpp to ArgsManager
2017-04-25Remove Clang workaround for Boost 1.46fanquake
2017-04-10allow libevent logging to be updated during runtimeJohn Newbery
2017-04-10[rpc] Add logging RPCJohn Newbery
Adds an RPC to get and set currently active logging categories.
2017-04-03Remove `namespace fs=fs`Wladimir J. van der Laan
Having these inside functions is silly and redundant now.
2017-04-03Use fsbridge for fopen and freopenWladimir J. van der Laan
Abstracts away how a path is opened to a `FILE*`. Reduces the number of places where path is converted to a string for anything else but printing.
2017-04-03Replace uses of boost::filesystem with fsWladimir J. van der Laan
Step two in abstracting away boost::filesystem. To repeat this, simply run: ``` git ls-files \*.cpp \*.h | xargs sed -i 's/boost::filesystem/fs/g' ```
2017-04-03Replace includes of boost/filesystem.h with fs.hWladimir J. van der Laan
This is step one in abstracting the use of boost::filesystem.
2017-04-03Merge #10058: No need to use OpenSSL malloc/freeWladimir J. van der Laan
6d5dd60 No need to use OpenSSL malloc/free (Thomas Snider) Tree-SHA512: 29f790067ffd5a10a8e1a621318a0ba445691f57c804aa3b7c8ca372c8408d8c7fe703c42b48018e400fc32e3feff5ab401d97433910ce2c50e69da0b8a6662e
2017-04-01Change LogAcceptCategory to use uint32_t rather than sets of strings.Gregory Maxwell
This changes the logging categories to boolean flags instead of strings. This simplifies the acceptance testing by avoiding accessing a scoped static thread local pointer to a thread local set of strings. It eliminates the only use of boost::thread_specific_ptr outside of lockorder debugging. This change allows log entries to be directed to multiple categories and makes it easy to change the logging flags at runtime (e.g. via an RPC, though that isn't done by this commit.) It also eliminates the fDebug global. Configuration of unknown logging categories now produces a warning.
2017-03-30util: Work around (virtual) memory exhaustion on 32-bit w/ glibcWladimir J. van der Laan
glibc-specific: On 32-bit systems set the number of arenas to 1. By default, since glibc 2.10, the C library will create up to two heap arenas per core. This is known to cause excessive virtual address space usage in our usage. Work around it by setting the maximum number of arenas to 1.
2017-03-28No need to use OpenSSL malloc/freeThomas Snider
2017-03-09[util] Remove redundant call to get() on smart pointer (thread_specific_ptr)practicalswift
2017-03-08Refactor: Remove using namespace <xxx> from util*Karl-Johan Alm
2017-02-20Fix for issue #9775. Added check for open() returning a NULL pointer.kirit93
2017-01-24Increase minimum debug.log size to 10MB after shrink.Alex Morcos
2016-12-31Increment MIT Licence copyright header year on files modified in 2016isle2983
Edited via: $ contrib/devtools/copyright_header.py update .