Save log on thread other than render thread
Is your feature request related to a problem? Please describe.
[22:40:03] [Render thread/INFO]: [ChatLog.serialize] Saving...
[22:40:07] [Render thread/INFO]: [ChatLog.serialize] Saved the chat log containing 11236 messages and 108 sent messages to '<>/logs/chatlog.json' in 4.026 seconds
So my game was frozen for 4.026 seconds.
Describe the solution you'd like Use a seperate thread instead of render thread to save logs.
Describe alternatives you've considered
ForkJoinPool.commonPool().execute()
Additional context I've created a workaround in my fork: https://github.com/layou233/ChatPatches/commit/32ea2639693d881eaa10a68e1cbb1ace7e8e990e However, this ignores data race conditions, and I think concurrent safety issues should be considered. I'm not familiar with this mod, so opening an issue here. :)
thanks for the report! to be honest i know next to nothing about multithreading in java, so i'll have to do some research before i implement this to avoid any fatal errors. but i will definitely keep this in mind when deep diving! in the meantime, perhaps consider trimming some of those 11k messages?
Sometimes it's not the size of the text that's causing the long pauses because I/O operations are really unpredictable. It could be a bottleneck on the hard drive, anti-virus software, or a bad Windows kernel update. So if no one else reports the same issue, I think we can put it on hold until it's fully fixed. In the meantime I can use my fork and look for a solution. Thanks for your work!
https://github.com/layou233/ChatPatches/commit/d1a2488345e48a7e8bc1f5e7b7ca555d1e8751cb
Based on my last commit. My idea is to synchronize list operations and copy on serialization.
i like these ideas, i've implemented the synchronized part in the dev-stage omnivers branch, but i'm still trying to find the best way to queue the tasks to be executed, as minecraft does interact with threads quite a bit behind the scenes. i have a few potential candidates so when i can i will look into those!
impl'd this in the in-dev omnivers branch, if you'd like to take a look yourself. it's currently only available in 1.20.2 but will expand to newer versions soon (:
Didn't notice the Minecraft IO pool thread, it's great!
Haven't tried yet but the code LGTM. 🥰
implemented in 8.0-alpha.1!