Commit Graph

9 Commits (beafc128e382fbe17f9ccf79e35daf784ba2d663)

Author SHA1 Message Date
Nate Smith 673232919b notes 2023-12-09 16:29:49 -08: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