haxe icon indicating copy to clipboard operation
haxe copied to clipboard

[jvm] sys.io.File.read is a huge performance trap

Open Simn opened this issue 1 year ago • 2 comments

import haxe.io.Input;
import haxe.io.BytesInput;

function main() {
	var input:Input = sys.io.File.read("eval.zip");
	// input = new BytesInput(input.readAll()); // that line
	try {
		var zip = haxe.zip.Reader.readZip(input);
		trace("Read");
	} catch (e:Dynamic) {
		trace(e);
	}
	input.close();
}
target without that line with
JVM 8.101 0.637
Eval 7.781 8.454
HL 2.463 1.952
C++ 5.486 2.879
jprofiler_U1f4rNqre5

Simn avatar Jan 12 '24 07:01 Simn

I don't know if this is how real Java devs handle this, but it's faster for me.

Simn avatar Jan 30 '24 16:01 Simn

I reverted that change because the interaction between the buffer and the random access doesn't work the way I thought it would, which breaks all tell() offsets.

Surely there must be a straightforward fix for this...

Simn avatar Jan 30 '24 19:01 Simn