-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Base58 encoding a ~366KB byte array takes relatively forever #8
Comments
There are some links explaining the issue and graphs I made over here: The graphs were from benchmark code to show the issue, though it needs to be rebased now: I'm not sure if there are easy solutions other than just using another encoding for large inputs. base58 works just fine for small inputs. |
Thank you @davidlehn for the helpful links. Considering the need to encode at least 100s of KBs seems like base64 encoding is the way to go. Nonetheless, thank you for this helpful base58 project. Pretty tangential but... I know many blockchains use base58 encoding... is that why image NFTs can not just be encoded on chain (why really just pointers to urls)? |
Yeah, a power of 2 base encoding would probably work better, depending on your needs. The implementations of those can often be optimized better than arbitrary base N code too. I think most uses of base58 are for smaller data like addresses, signatures, hashes, and similar. The performance is fine when it's just 10s to 100s of bytes. As far as bulk data in a blockchain, it's almost certainly always not advised due to performance reasons no matter what encoding (if any) you use. In many designs you have to sync all the data between nodes, and syncing pointers and hashes is less costly than huge amounts of data. |
Thanks again @davidlehn. I'm going to close this issue. |
I'm curious why encoding a byte array of only a few hundred kilobytes results in an operation that takes 10+ minutes? I actually can't find any materials that explains why base58 encoding would struggle with a moderate amount of data. Maybe someone here can explain?
Below is some example code
You'll just need to have a base64 encoded image in the
/examples
dir to run.Running the above results in the output:
However if one does run you'll see the base64 encoding taking a couple of ms while the base58 encoding takes tens of minutes. Why?
Thanks for your responses and for your efforts in open sourcing this project.
The text was updated successfully, but these errors were encountered: