JRuby

RubyIO#incrementLineno is Very Slow

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: JRuby 1.4
  • Fix Version/s: JRuby 1.5
  • Component/s: Performance
  • Labels:
    None
  • Number of attachments :
    0

Description

Through analysis of JRUBY-2810 I found that RubyIO#incrementLineno is indirectly invoked by all line-retrieving methods in RubyIO, including RubyIO#foreach and RubyIO#each_line. On large files this shows up as the largest offender in profiles, consuming nearly 40% of the total execution time.

It isn't clear through initial analysis why it is there, but if it is required, a more optimal path should be considered to improve large file scanning performance.

Please see http://gist.github.com/213949 for timings with and without incrementLineno. (Please note that these timings were all captured using the modified 'bench_io_foreach.rb' from the patch proposed on JRUBY-2810 - please use that version to do comparisons, as it has very difference characteristics than the current version in master).

Issue Links

Activity

Hide
Charles Oliver Nutter added a comment -

I made several improvements in 1bd4ca2, which seems to have reduced the overall cost of the line number updates substantially. I have also posted a question to ruby-core asking for clarification about why $. and $< seem to be intertwined for no apparently good reason. We'll leave this open until they get back to me.

Show
Charles Oliver Nutter added a comment - I made several improvements in 1bd4ca2, which seems to have reduced the overall cost of the line number updates substantially. I have also posted a question to ruby-core asking for clarification about why $. and $< seem to be intertwined for no apparently good reason. We'll leave this open until they get back to me.
Hide
Charles Oliver Nutter added a comment -

I'm actually going to mark this resolved. For now, the additional overhead of setting lineno for every line read is only a handful of field accesses. It would be nice to eliminate it, but it is at least not multiple hash hits like it was before.

WRT my email to ruby-core, there has been no real response from any core developers about what is right and what is specified behavior.

Show
Charles Oliver Nutter added a comment - I'm actually going to mark this resolved. For now, the additional overhead of setting lineno for every line read is only a handful of field accesses. It would be nice to eliminate it, but it is at least not multiple hash hits like it was before. WRT my email to ruby-core, there has been no real response from any core developers about what is right and what is specified behavior.

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: