-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File read is dramatically slower #2536
Comments
Thank you for the report. Could you share the size of that file?
|
It was a log file, don't have the exact file to compare with anymore. But there shouldn't have been any special characters.
|
Thank you for the report. I’ll try and profile where the time is being spent, there are a few areas that we know could be optimised, but I’d be surprised if they add up to enough overhead to be the sole cause of the problem. |
Okay, running this through We should definitely be able to optimise this more, there's no reason to go through the buffered IO if we're simply going to fill the buffer and then copy it to a string, and we could opt for attempting to read the entire file in one go, but we'll need to do some work here because increasing the buffer size may not work well with the buffer infrastructure we use with IO syscalls at the moment. |
Right. I've got some draft changes that speed up IO by between 2 and 4 times, depending on exactly how you build TruffleRuby. I'm not ready to turn these into a PR because they need a little more work (reading 1GB files should not leave us with 1GB buffers sitting around for the lifetime of the thread which did it), and I think there is also so extra speed to be gained by combining some operations. It's not entirely clear if it is sensible to attempt to read files in one large operation, the large objects produced tend to do bad things for GC performance overall, and have the buffer problem I mentioned. I'll do some more tests and see if we can get the same speed while still doing smaller IO operations. |
We neglected to add the release milestone for this issue when it was merged in master. I've done a little benchmarking of IO performance and depending on the build configuration our read performance is either about half of MRI's, or about 1.5 times as fast. For single read operations like the one originally reported a native build of truffleruby took 0.25s to read a 98MB file, while MRI took 0.17s. I think we can close this issue for now, and possibly recheck once the new string implementation is in. |
Been experimenting with truffle. Honestly don't really know what specifically I should be looking for. But in one of the scripts I was playing with I noticed it was quite slower. Its more than just the
File.read
, but this was the easiest one to show.Am I missing something? Or is something like this just a bad usecase for truffle?
The text was updated successfully, but these errors were encountered: