Int256 type support

Hello guys,

Does anyone have suggestions regarding implementation of int256 types? ie, numerics with 79 digits.
F.e. could it be implemented using wasm udf functions in C or Rust on top of the Varbinary types and how would be performance of such math/aggregation functions?

Thanks,

1 Like

This is a good use case for Wasm UDFs (Create Wasm UDFs · SingleStore Documentation). The data could be stored as a binary(32). You could create UDFs to do math on them (like add256()) and UDAFs to aggregate them. The performance will probably be reasonably good, and usable, but will be much slower than using BIGINT because we have special code paths for that use vectorization and code generation.

3 Likes

Hi @mykhail. Did you make any progress on this? Do you think you’ll be using Wasm in production to address this need? Let us know if you have any more questions about Wasm in SingleStore.

Hi @hanson , sorry for late reply.
Thanks for your suggestion, we actually implemented WASM math and tested aggregation functions. Worth to mention it only available on Singlestore v7.9+.
So far we tested on small datasets (~100k rows) it shows near the same performance as built-in functions (10-20% longer), more tests are still to be done though.
Wasm will be definitely a way to go for us, but would be nice to know if you guys are planning to add support of big integers in future releases

3 Likes

@mykhail that’s fantastic! I’ll DM you and we can talk more.

We don’t plan to support 256-bit integers because it’s kind of narrow – we don’t think a lot of people would use it. Moreover, you can use decimal(38,0) to get up to around 38 digits of precision. So it’s a great use case for Wasm. Do you have more details you can add? Like, did you use open source code in your Wasm function and if so, can you share the git repo?

1 Like

Hi @mykhail . Any possibility you could share your source code if it’s open source?

1 Like

Hi @mykhail – how’s it going with your 256 bit int package in Wasm?
Can you post the source code here, with an Apache 2.0 license?