Commit Graph

9 Commits (master)

Author SHA1 Message Date
Noelle Leigh c6aed375da Support Python 3.12
Python 3.12 no longer supports using non-integer values as arguments for
random functions (see [Changes in the Python API for 3.12][0]). This PR
casts `CONST_RARITY_MAX` to an integer to prevent a `TypeError` from
being raised.

[0]: https://docs.python.org/3/whatsnew/3.12.html#changes-in-the-python-api
2024-03-03 17:20:32 -05:00
Nate Smith ad0d78e133 oops 2023-12-09 16:14:19 -08:00
Nate Smith 26df7b5a1f adjust mutation rarity to account for reduced number of life iterations 2023-12-08 21:42:24 -08:00
Nate Smith 9162888a7d consolidate autosave into life thread 2023-12-06 21:52:40 -08:00
Nate Smith 8d45997537 fix scoping on death_check change even more 2023-12-06 21:38:13 -08:00
Nate Smith 84bb89b48c fix scoping on death_check change more 2023-12-06 21:37:12 -08:00
Nate Smith be770c6b5e fix scoping on death_check change 2023-12-06 21:36:15 -08:00
Nate Smith ed7498bd4a reduce CPU usage dramatically
I noticed that on tilde.town users with a high botany score used up a
lot of CPU cycles. I skimmed through the code and didn't immediately see
any tight loops, but after profiling against a user's borrowed .botany
directory I saw the culprit: the score increase thread.

This thread was designed to increase the user's score by 1 every time
the thread did an iteration of its infinite loop. It would sleep for an
interval scaled *down* based on how high a user's generation bonus was.
This meant that the sleep interval trended towards zero, creating a
tight loop for high scoring users.

This commit changes the code to use a constant sleep inteveral but scale
the score increment *up* based on generation.

I also removed the death check thread entirely since we were already
checking for death in the score thread. I also short circuited the death
check.

This had the effect of reducing CPU load for a high scoring user by a
factor of about 50.
2023-12-06 21:08:43 -08:00
Nate Smith ea358f641d move Plant to its own module
Without this, trying to run this against cProfiler fails because pickler
can't find Plant in the "current" module. It's an annoying quirk of
pickle+cProfiler.
see: https://stackoverflow.com/questions/53890693/cprofile-causes-pickling-error-when-running-multiprocessing-python-code

this commit also adds a bunch of notes.
2023-12-04 22:04:00 -08:00