Published on: 2011-07-04T11:40:28+00:00
Jan Vornberger provided an update on the issue with the "sendfrom" function. He discovered that the function triggers a rebuild of the cache, which caused delays. To address this, he made changes so that a complete rebuild of the cache only happens on new blocks. For new wallet transactions, the cache will be adjusted incrementally. Jan tested the cache by running a full calculation every 4000 calls and found no issues so far. The changes have been pushed to the Github branch Jan shared. However, Jan mentioned that the cache does not work correctly with the RPC command "move" as he hasn't implemented the necessary adjustments yet.Earlier, Jan, the creator of Instawallet, received a suggestion from John Smith to improve server speed. The suggestion involved scanning the wallet whenever there was a new block or any changes in the blockchain. This allowed for balance accumulation for all accounts in amortized linear time using a hash_map. Jan created a branch on GitHub with the code for the cache and attached a patch file. He implemented a list of all account balances each time a new block or transaction affecting his wallet appeared. The list is stored in a "map" due to Jan's limited experience with C++. However, because of low memory on his VPS, a tree-based implementation of map was used instead. There are plans to switch to a newer version of the codebase in the future.In an email sent on June 23, 2011, Jan reached out to a mailing list seeking help to improve the speed of the "getbalance" function, which had a processing time bottleneck. One suggested solution was to scan the wallet whenever a block or something else changed in the blockchain, and then accumulate balances for all accounts using a hash_map. This method significantly reduced the time it took for the API to return the balance for an account. It was also considered less prone to bugs than incremental caching and did not require determining which accounts were influenced by a new block. Additionally, this solution handled blockchain reorganizations without any issues.Jan, the founder of Instawallet, faced a bottleneck issue with the "getbalance" function, leading to long processing times due to bitcoind recalculating the balance for each relevant transaction. Seeking advice from the community, Jan wanted to improve this issue without invasive changes. He planned to implement a simple cache in bitcoind that would store calls to getbalance and invalidate the cache when a new block or transaction affecting the wallet occurred. However, he acknowledged that this solution was not perfect since blocks arrive approximately every 10 minutes. Jan considered a better solution where cache entries affected by new transactions or blocks would be invalidated, but this would require accounting for blockchain reorganizations, which is complicated. He suggested invalidating the entire cache during reorganizations, as they occur infrequently enough to not pose a significant problem. Jan sought suggestions on where in the source code to hook into to detect blockchain reorganizations. Although the ideal solution would be for bitcoind to continuously update balances as new information became available, Jan felt unsure about making such a substantial improvement. He believed extensive testing of rare blockchain reorganizations would be necessary. For now, he preferred to let bitcoind handle account handling to avoid concerns about blockchain reorganizations.
Updated on: 2023-08-01T02:01:06.258262+00:00