d-dd / cyNaoko

Naoko but for CyTube modified for a Vocaloid channel
BSD 2-Clause "Simplified" License
1 stars 1 forks source link

Limit chat INSERTs. #16

Open d-dd opened 10 years ago

d-dd commented 10 years ago

When the chat goes too fast (spam) Naoko has trouble writing each line to its sqlite database. It uses up a lot of disk and CPU, until it can no longer catch up and times out to the server. Chat logging could be limited to at most once every second. When there is more than one line in a second, multiple lines will be cached and wait to be inserted in one transaction. In the event of a crash, the most data loss that will happen (because of this change) is one second of chat.

d-dd commented 10 years ago

After some tests, I found out that the database chat logging itself wasn't the reason for the restart. When there are too many chatMsg frames, Naoko must process each one, and if it takes too long, it reaches the (heartbeat) TIMEOUT before the heartbeat is felt (because it's so far behind the queue).

The database does slow things down; after a spam session all database operations are blocked until the chat messages are written, so this may still be good to implement.

d-dd commented 10 years ago

Turning down (up?) the loglevel (so almost nothing is logged/printed to stdout) improved performance during spam quite a bit running on a Raspberry Pi.