From my last playing around with primes post, I've finally managed to segment the sieving algorithm. This does a few different things:
- Reduces memory usage. Now the usage is proportional to the number of primes found plus some small fixed buffer.
- Increases locality when sieving. This should help with performance.
- Hopefully makes parallelization easier/possible.
- Finding the first x primes becomes a relatively straightforward and quick task.