-
Notifications
You must be signed in to change notification settings - Fork 9
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
Sufficiently large product will hang #2
Comments
you're right, @relwell - since the products are made recursively, the deeper you go, the longer it takes (exponentially)... i've tested your case and got 10 seconds for repeat=20 and 65 seconds for repeat=30... although i've tested some ideas - involving a worker-queue or a non-recursive solution - none gave better overall performance... afar from that this is a problem, your specific problem may be solved a lot easier like that:
|
One way to get a more deterministic thread count is to create a thread per column instead of per row (where the column is the number of elements in the output list and where the row is the combination of all lists). In this way, the thread count would only be as large as the number of output columns no matter how long the lists of possible values may be. Your comment above hits at this solution already, so you may have already thought of this... Each column would be a channel, and the channel would produce the proper column combo depending on its position in the column list. Take example ListA=[1, 2, 3, 4, 5], ListB=[a, b, c, d], ListC=[!, @, #, $, %, ^] Each thread would likely need to be passed the following:
Also, this solution could allow the caller to request fewer combos than the total list of products. NOTE: I don't know if this would be more efficient, but it is more deterministic. Sorry I haven't provided any coding to help. I'm new to GoLang so I'm not very comfortable putting a hack out there that is full of issues. |
Not resolved so far..... |
Need implement if bulk of generation reached of Go max goroutines |
I've made a PR with a different approach- it may solve this issue? |
This may be fixed in latest version! |
Here's an example, with go-cartesian-product code included. Note that we're just adding in this
bitproduct
function that uses a variadic function to give us functionality like Python'sitertools.product("01", repeat=int(sys.argv[1]))
:This will spin up between 6500 and 8000 goroutines, which leads me to believe that something isn't being cleaned up when there is a sufficient degree of recursion happening.
The text was updated successfully, but these errors were encountered: