Skip to content
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

[Newcomer] Improve random.repy performance #135

Open
choksi81 opened this issue Jun 2, 2014 · 2 comments
Open

[Newcomer] Improve random.repy performance #135

choksi81 opened this issue Jun 2, 2014 · 2 comments
Assignees

Comments

@choksi81
Copy link
Contributor

choksi81 commented Jun 2, 2014

Our functions in random.repy are slow. On my moderately modern !MacBook Pro 8,2:

#elements Repy Python
 1000     17ms   6ms
10000     87ms  10ms
50000    600ms  33ms

That doesn't sound terrible at first, but given that we also run on low-power platforms such as Android and !RaspberryPi, the picture changes. Under load, we see runtimes 10 to 200 times as high (for both Repy and Python on a !RasPi). As a consequence, places that use the random.repy functions become prone to timing out. This includes the node manager and Affixes trying to advertise (see r7148, and know that in unrestricted mode, the list of connports has 5000 elements).

We should (1) replace our implementation of random_sample with a port of Python's random.sample, and (2) also port Python's random.shuffle which is quite a bit faster than randomly sampling all of the elements of a list.

@choksi81 choksi81 self-assigned this Jun 2, 2014
@choksi81
Copy link
Contributor Author

choksi81 commented Jun 3, 2014

I addressed (2), random_shuffle was added in r7218.

@choksi81
Copy link
Contributor Author

choksi81 commented Jun 3, 2014

..and updated in r7318. The previous version used reversed() which is disallowed in Repy. Thanks Monzur for noticing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant