Optimized binary-to-hex converter (ToHex) #562

pull luke-jr wants to merge 1 commits into bitcoin:master from luke-jr:optimize_ToHex changing 3 files +25 −4
  1. luke-jr commented at 8:53 PM on October 4, 2011: member

    Part of JoelKatz's 4diff patch.

  2. gavinandresen commented at 2:22 PM on October 5, 2011: contributor

    If the "cache getwork" patch is applied, does this matter?

  3. luke-jr commented at 3:12 PM on October 5, 2011: member

    The original "cache getwork" patch used this. I split them up for code cleanliness. If this one is merged first, I can rebase the FastGetWork code and bring it back to its original state from JoelKatz.

  4. Optimized binary-to-hex converter (ToHex) 26e973c2b2
  5. laanwj commented at 12:16 PM on October 23, 2011: member

    I appreciate that you're trying to optimize bitcoin, but please don't add any fixed-sized buffers! I rather have somewhat slower code than potential security holes.

  6. luke-jr commented at 11:27 PM on October 28, 2011: member

    Fixed-size buffers are not a security hole, only misuse of them. That being said, I have not checked over this patch for security checks either.

  7. laanwj commented at 6:58 AM on October 29, 2011: member

    I think we all know that already Luke. The thing is, people make mistakes, and they are usually not all found on the first time around code inspection. It's playing with fire, in a way, and should be restricted imo to direct interaction with hw, OS-level libraries and such stuff. I'd prefer to err on the safe side in financial sw.

  8. luke-jr commented at 12:50 PM on October 29, 2011: member

    Sure, but that ignores the fact that this code has had a lot of real-world production testing in probably 90% of pools (and even required by PSJ)

  9. cgaebel commented at 10:20 PM on November 2, 2011: none

    I don't understand the concern here. If you look in the context of this patch, there's plenty of fixed buffer usage already.

    What would make sense is to instead make the buffer size a result of a constexpr calculation, but in this case that really seems like overkill.

  10. laanwj commented at 10:38 PM on November 2, 2011: member

    That's exactly my concern. I'd like to reduce fixed buffer use not increase it. C++ has introduced all kinds of stuff exactly to not have to muck around with them.

    Also, this does not completely replace the old HexStr function, so this means that the source will now be littered with not one but two hex conversion utility functions.

    I would prefer if he just optimized the current HexStr function, which is very possible in a similar way, as it seems to be the strprintf and string concatenation that make it slow. Writing to a fixed buffer instead of returning a std::string is likely a unnecessary micro-optimization.

  11. gavinandresen commented at 3:29 PM on December 2, 2011: contributor

    I have a few problems with this code, starting with it doesn't follow the bitcoin coding conventions (e.g. nLen instead of len). And I agree with laanwj RE: optimizing HexStr instead.

    But I'll go back to my original question: does this have any measurable effect on performance if the bypass-JSON-and-return-a-cached-response-to-getwork patch is applied? What is the performance of getwork with/without: Just this patch Just the bypass-JSON-cache-getwork patch Both this AND the cache-getwork patch

    I think it is a bad idea to add another (potentially unsafe if you use it wrong!) way of converting to hex, unless it gives a really significant (on the order of "you can serve twice as many getwork requests with one bitcoind") performance advantage.

  12. gavinandresen closed this on Dec 2, 2011

  13. luke-jr commented at 9:52 PM on January 11, 2012: member

    Pull #565 includes performance testing for this.

  14. laanwj referenced this in commit 88dc2d6c6a on Apr 21, 2012
  15. sipa referenced this in commit 7dbe393629 on Apr 21, 2012
  16. kR105-zz referenced this in commit 85878a3fc9 on Apr 22, 2012
  17. sje397 referenced this in commit ce091036a7 on Apr 22, 2012
  18. coblee referenced this in commit 294df59aea on Jul 17, 2012
  19. coblee referenced this in commit fa27abf991 on Jul 17, 2012
  20. sipa referenced this in commit cc05fa919a on Mar 30, 2019
  21. sipa referenced this in commit 1e32413e52 on Mar 30, 2019
  22. sipa referenced this in commit 54245985fb on Mar 31, 2019
  23. sipa referenced this in commit 3fe71bbd95 on Apr 2, 2019
  24. LongShao007 referenced this in commit 3d9a3d2063 on Jul 15, 2019
  25. LongShao007 referenced this in commit 8af66f3427 on Jul 15, 2019
  26. LongShao007 referenced this in commit 807f206f73 on Jul 15, 2019
  27. fjahr referenced this in commit 870a977644 on Jul 24, 2019
  28. kallewoof referenced this in commit ec62262c51 on Oct 4, 2019
  29. kallewoof referenced this in commit c866f52e2a on Oct 4, 2019
  30. KolbyML referenced this in commit bc86927231 on Sep 4, 2020
  31. backpacker69 referenced this in commit ef89673ace on Mar 28, 2021
  32. lateminer referenced this in commit 3c9f919a30 on May 5, 2021
  33. DrahtBot 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-13 18:16 UTC

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