I am fairly new to Julia. I am a retired Engineer/Computer Scientist that continues to be a hobby programmer. I particularly enjoy arbitrary precision math (computation of constants, Bernoulli numbers, prime factoring…). I maintain a set of such code using C/C++, Python, Go, Rust, Ruby, Swift and Julia. One of the key pieces of code missing from my code set is a decent Quadratic Sieve program native to Julia. I found one on Github but could not get it to run. Even if I did it is pretty basic. There is one post on this forum from 2018 on the subject that basically ended with if you want one write one. I recently have had some success in converting snippets between languages using AI language converters so I though why not try to convert a whole app. So I went looking for a candidate Quadratic Sieve application. I wanted one that was complete (many on Github end with an initial commit and never result in working code. I also wanted one fairly small and well organized. I also wanted to convert an application that uses gmplib mpz’s so that they can be mapped to Julia BigInt’s.
I found one such application. I set out to convert using AI. The first attempt ended with the AI in a forever “thinking” timeout. The second and third attempt resulted in code to slow to be used. The fourth attempt resulted in working code that is reasonably performant and surprisingly error free. After much testing and adding some features including automatic parameter generation, I have uploaded the code to Github.
The code runs, and produces factors for up to 100 digit numbers. Has been tested with RSA-100. The original code is written in Rust. The Julia code is about 2.5 times slower.
The main issue now is memory usage. I have 128G of memory on my laptop and the code will use it all plus some. During the RSA-100 factoring Julia consumed 155Gbytes!!! Running the Rust version with the same parameters it never used more than 1.2G. I have tried using the heap-size-hint and it helps some. Adding GC.gc() calls at a couple of locations in the sieving code dramatically lowers memory usage but in turns kills performance (up to 100x slower run performance). So the tradeoff is reasonable performance and let Julia consume all memory or try to limit memory usage and kill performance.
So at this point I am happy to donate some code to the Julia community but somewhat disappointed with the outcome.
Please note that I have gone line by line and compared the converted code to the original and it is very close to identical. I also ensured that mutating functions and variables were used when possible.
I hope that over time, users and developers will provide recommendations and insights for improvement.
Thanks,