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

Slow Parser Initialization. #243

Closed
bd82 opened this issue Aug 1, 2016 · 0 comments
Closed

Slow Parser Initialization. #243

bd82 opened this issue Aug 1, 2016 · 0 comments

Comments

@bd82
Copy link
Member

bd82 commented Aug 1, 2016

The Problem:

The first initialization and/or running of a parser instance may be very slow.
This only happens on the first initialization or parsing due to a very ineffective algorithm
used to compute the lookahead functions.

This only happens with some grammars:

Temporary Workaround for 99% of use cases:

Pass a smaller than the default (5) maxLookahead in the parser's constructor:

function CssParser(input) {
        chevrotain.Parser.call(this, input, cssTokens, {
                maxLookahead : 3 // by default this is 5
            });
        ...
@bd82 bd82 added the Bug 🪲 label Aug 1, 2016
@bd82 bd82 changed the title Slow Parser Initialization Slow Parser Initialization. Aug 27, 2016
bd82 pushed a commit that referenced this issue Aug 27, 2016
…of DFS.

This avoids performance issues with the initialization of some parsers
As alot of unnesscary work was done which was determined by the configured maxLookahead
instead of the actual lookahead required for the specific grammar.

Thanks to @levin81 for algorithmic assistance.

Fixes #243
bd82 pushed a commit that referenced this issue Aug 27, 2016
…of DFS.

This avoids performance issues with the initialization of some parsers
As alot of unnesscary work was done which was determined by the configured maxLookahead
instead of the actual lookahead required for the specific grammar.

Thanks to @levin81 for algorithmic assistance.

Fixes #243
bd82 pushed a commit that referenced this issue Aug 27, 2016
…of DFS.

This avoids performance issues with the initialization of some parsers
As alot of unnesscary work was done which was determined by the configured maxLookahead
instead of the actual lookahead required for the specific grammar.

Thanks to @levin81 for algorithmic assistance.

Fixes #243
@bd82 bd82 closed this as completed in #269 Aug 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant