PlummersSoftwareLLC / Primes

Prime Number Projects in C#/C++/Python
https://plummerssoftwarellc.github.io/PrimeView/
2.44k stars 575 forks source link

Elixir: Improve performance of solution 2 using the Tasks API #908

Closed DeemoONeill closed 1 year ago

DeemoONeill commented 1 year ago

Description

This improves on solution 2 and spawns as many tasks as there are schedulers to make the most of the available hardware which should see a nice improvement on the hardware that these tests run on.

I'm happy to remake this pull request as a new solution if that is more appropriate.

Contributing requirements

rbergen commented 1 year ago

@DeemoONeill Thanks for submitting this. This PR changes one of the key characteristics of the solution (parallelism), which can't be considered a straightforward optimization of the existing solution. I think there are two things you could do:

Generally speaking, we prefer multiple implementations in one solution over individual solutions because it saves Docker resources (images, build time, etc,.), but I think a new solution would not be out of order per se.

DeemoONeill commented 1 year ago

Thanks for the feedback, I'll add the parallelised version as a second run in main then.

First it will run the existing solution and then the _parr version

rbergen commented 1 year ago

That sounds like a great approach to me. Thanks!

DeemoONeill commented 1 year ago

Ok, main now does the sequential run, writes to stdout, then does the parr run and writes to stdout.

This keeps the original version and adds in a multiple core version.