Stash the RPC user and password in a global string so we don't have to fetch them from the map on every RPC request.
Cache RPC user and password in globals #560
pull luke-jr wants to merge 1 commits into bitcoin:master from luke-jr:optimize_cache_rpcauth changing 4 files +9 −6-
luke-jr commented at 8:52 PM on October 4, 2011: member
-
Stash the RPC user and password in a global string so we don't have to fetch them from the map on every RPC request. 86a1e25ae3
-
gavinandresen commented at 2:25 PM on October 5, 2011: contributor
I hate to sound like a broken record...
... but how much faster on what machine for what operation(s)?
The first rule of optimization is benchmark every change before and after, because changes that will "obviously" make things faster often don't.
-
laanwj commented at 7:17 PM on October 11, 2011: member
Fetching from a std::map is really fast (order log N the number of entries in the map, which is very small as it only contains the command line arguments). Also it is only done once for every HTTP request, so I doubt that this gives a speed advantage.
On the other hand, I do think the code is somewhat cleaner storing the user and password in explicit variables. After all, it shouldn't matter conceptually where the settings come from. One could discard the command line arguments map after parsing them and storing the values in the appropriate component that needs them (most programs do that afaik).
Eventually these should be part of an object / namespace instead of globals though... :-)
Anyway: ACK
-
JoelKatz commented at 12:41 AM on November 5, 2011: contributor
This change speeds up
getworkby about 3% if made to vanilly 0.3.24 (the version I benchmarked against). With my other patches, this patches speeds up a getwork by about 11%. (The improvement due to this patch is about the same, but getwork is about four times faster with all of my patches -- same numerator, smaller denominator, bigger fraction.) Some of those patches are already in CVS, so it should be somewhere between 3% and 11% now. -
gavinandresen commented at 2:13 PM on December 1, 2011: contributor
Reworked to be self-contained in bitcoinrpc.cpp: #670
- gavinandresen closed this on Dec 1, 2011
- nomnombtc referenced this in commit 9fcdbf5058 on May 14, 2017
- lateminer referenced this in commit c96694d5af on May 5, 2021
- rajarshimaitra referenced this in commit f913d8dc81 on Aug 5, 2021
- DrahtBot locked this on Sep 8, 2021