Improve base58 encoding performace by reducing useless iteration #4713

pull 4tar wants to merge 2 commits into bitcoin:master from 4tar:base58_encoding_improve changing 1 files +9 −5
  1. 4tar commented at 6:05 AM on August 17, 2014: contributor

    In populating the b58 vector, don't need to go through the whole vector but just those valid bytes.

    Signed-off-by: Huang Le 4tarhl@gmail.com

  2. Improve base58 encoding performace by reducing useless iteration
    Signed-off-by: Huang Le <4tarhl@gmail.com>
    cb2bd8348a
  3. 4tar commented at 6:09 AM on August 17, 2014: contributor

    In my local testing this patch can improve b58 encoding performance by around 85%, it doesn't achieve the 100% theoretical gain due to extra comparing ops introduced in the iteration..

  4. luke-jr commented at 6:27 AM on August 17, 2014: member

    How does this compare with luke-jr/bfgminer#540's implementation? About the same? I was thinking we should throw the C base58 encode/decode in a simple, small, library, and just use it in both.

  5. 4tar commented at 6:34 AM on August 17, 2014: contributor

    @luke-jr They are actually the same, just C/C++ implementation.

  6. Remove the useless assert() since it is guaranteed by the loop condition
    Signed-off-by: Huang Le <4tarhl@gmail.com>
    f2c3cb626e
  7. sipa commented at 11:40 AM on August 17, 2014: member

    I wanted to avoid complicating the code for something so little performance critical, but I'm fine with improving it.

    How was this benchmarked? Large number of address-sized data, or very large amounts of data to convert? I would expect the actual conversion loop to be fast compared to other overhead.

  8. sipa commented at 11:41 AM on August 17, 2014: member

    Also, decoding can get the same optimization.

  9. laanwj commented at 12:36 PM on August 17, 2014: member

    Not sure about this. We don't have a requirement for high-performance base58 encoding and decoding in bitcoin core. I'd like to avoid over-optimizing things not on the critical path. Security and ease of understanding is more important here.

  10. 4tar commented at 1:46 PM on August 17, 2014: contributor

    @sipa The testing was done by encoding address-sized data for many times, so it should bring performance gain in real cases. @laanwj Sure, I fully understand we don't really need optimize the encoding/decoding since it's not critical for the app...

  11. luke-jr commented at 2:41 PM on August 17, 2014: member

    FWIW, I've imported the C version to https://github.com/luke-jr/libbase58 , which could be used either as a shared library or a subtree.

  12. laanwj added the label Improvement on Aug 18, 2014
  13. BitcoinPullTester commented at 4:15 PM on August 18, 2014: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4713_f2c3cb626e37542d0cedd958e2bcc3b7d6c71938/ for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  14. laanwj commented at 7:56 AM on September 25, 2014: member

    Closing this; sorry for that, but as said optimizing base58 is not that critical for us, and I don't like the risk of the extra complexity introducing a subtle bug.

  15. laanwj closed this on Sep 25, 2014

  16. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-22 06:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me