mojira.dev
MC-45842

Reads from java are slow due to many system calls?

I decided to strace minecraft for fun and giggles to find out that it does many read() system calls with a buffer length of 1, I found this kind of disturbing and decided to investigate. And I could only reproduce this by creating a 1 byte buffer to read into from Java. Now what's the bug? Well this seems kind of really weird, chunk files are padded to 4096 bytes, so why not read those in well 'chunks' of 4096 bytes instead? Causes less system calls and is in theory faster. Attached is a small portion of the strace where the odd read system call behavior is visible.

Linked issues

Attachments

Comments 6

Technically the system calls would be a problem with the jvm as the implementation does not have direct access to system calls. That being said, what you are describing sounds much like MC-34464, in regards to inefficient file I/O.

Is this still a concern in the current Minecraft version 14w30c or later? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

Just tested this on 14w30c, still reading out region files 1 byte at a time.

Is this still a concern in the current Minecraft version 1.8.1 Prerelease 3 or later? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

This sounds like a great candidate for the reason behind the jerky lag issue when travelling (loading new chunks) seemingly introduced in 1.8. Has any progress been made on this?

Putting 15w46a as fixed version.

Toon Schoenmakers

Erik Broes

Unconfirmed

Minecraft 14w04b, Minecraft 14w18b, Minecraft 14w31a

Minecraft 15w46a

Retrieved