Skip to content
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

relocate parser look ahead loops #2187

Merged
merged 6 commits into from
Jun 5, 2019
Merged

Conversation

jerch
Copy link
Member

@jerch jerch commented Jun 5, 2019

Part of #1823.

This PR relocates the read ahead loops into the proper switch cases. It further reduces code complexity (less branching) with a slight speedup for the optimized actions.

@jerch jerch changed the title relocate loop shortcuts, cleanup parse relocate parser look ahead loops Jun 5, 2019
@jerch jerch self-assigned this Jun 5, 2019
@jerch
Copy link
Member Author

jerch commented Jun 5, 2019

Speed comparison (tested with this script):

  • before:
   Context "examples/parser_throughput.js"
      Context "Parser performance - 50MB data"
         Context "print - a"
            Case "throughput" : 5 runs - average throughput: 432.44 MB/s
         Context "execute - \n"
            Case "throughput" : 5 runs - average throughput: 95.12 MB/s
         Context "escape - ESC E"
            Case "throughput" : 5 runs - average throughput: 53.92 MB/s
         Context "escape with collect - ESC % G"
            Case "throughput" : 5 runs - average throughput: 22.37 MB/s
         Context "simple csi - CSI A"
            Case "throughput" : 5 runs - average throughput: 84.30 MB/s
         Context "csi with collect - CSI ? p"
            Case "throughput" : 5 runs - average throughput: 55.03 MB/s
         Context "csi with params - CSI 1;2 m"
            Case "throughput" : 5 runs - average throughput: 104.91 MB/s
         Context "osc (small payload) - OSC 0;hi ST"
            Case "throughput" : 5 runs - average throughput: 50.15 MB/s
         Context "osc (big payload) - OSC 0;<text> ST"
            Case "throughput" : 5 runs - average throughput: 48.93 MB/s
         Context "DCS (small payload)"
            Case "throughput" : 5 runs - average throughput: 49.25 MB/s
         Context "DCS (big payload)"
            Case "throughput" : 5 runs - average throughput: 94.54 MB/s
  • after:
   Context "examples/parser_throughput.js"
      Context "Parser performance - 50MB data"
         Context "print - a"
            Case "throughput" : 5 runs - average throughput: 632.97 MB/s
         Context "execute - \n"
            Case "throughput" : 5 runs - average throughput: 89.43 MB/s
         Context "escape - ESC E"
            Case "throughput" : 5 runs - average throughput: 58.36 MB/s
         Context "escape with collect - ESC % G"
            Case "throughput" : 5 runs - average throughput: 22.37 MB/s
         Context "simple csi - CSI A"
            Case "throughput" : 5 runs - average throughput: 89.36 MB/s
         Context "csi with collect - CSI ? p"
            Case "throughput" : 5 runs - average throughput: 94.44 MB/s
         Context "csi with params - CSI 1;2 m"
            Case "throughput" : 5 runs - average throughput: 124.12 MB/s
         Context "osc (small payload) - OSC 0;hi ST"
            Case "throughput" : 5 runs - average throughput: 50.08 MB/s
         Context "osc (big payload) - OSC 0;<text> ST"
            Case "throughput" : 5 runs - average throughput: 48.31 MB/s
         Context "DCS (small payload)"
            Case "throughput" : 5 runs - average throughput: 60.97 MB/s
         Context "DCS (big payload)"
            Case "throughput" : 5 runs - average throughput: 256.35 MB/s

Note there are still two quite slow actions - "OSC" and "ESC with collect". Both do intermediate string conversion + concatenation, maybe we can get rid of that with later PRs.

@jerch jerch mentioned this pull request Jun 5, 2019
11 tasks
src/core/parser/EscapeSequenceParser.ts Show resolved Hide resolved
src/core/parser/EscapeSequenceParser.ts Show resolved Hide resolved
src/core/parser/EscapeSequenceParser.ts Outdated Show resolved Hide resolved
@Tyriar Tyriar added this to the 4.0.0 milestone Jun 5, 2019
Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after the comment is removed

@jerch jerch merged commit 69ad755 into xtermjs:master Jun 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants