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

Performance issues related to memory #11

Open
mikolasstuchlik opened this issue Nov 1, 2021 · 1 comment
Open

Performance issues related to memory #11

mikolasstuchlik opened this issue Nov 1, 2021 · 1 comment

Comments

@mikolasstuchlik
Copy link

Hello,

I have been playing with the package recently and I have experienced some issues.

The program seems to struggle with larger texts. At first I suspected, there might be an unreasonable amount of copying involved. After some debugging, I've came to conclusion, that this is in fact a problem with stack related to usage of recursion.

Reproduction example:

        let grammar = Grammar(start: "initial") {
            "initial"       --> n("initial") <+> t("a")
                            <|> t()
        }

        let parser = EarleyParser(grammar: grammar)
        let text = String.init(repeating: "a", count: 2500)
        let syntaxTree = try parser.syntaxTree(for: text )

I'm trying to work with files aroung 10K characters. At this time, I am able to work with 2000 characters long texts using this simple grammar.

For the time being, I will try to find a workaroud. I might have time to fix the issue in the future.

@mikolasstuchlik
Copy link
Author

My work so far is here: https://github.com/mikolasstuchlik/Covfefe/tree/fix/stack-overflow

I have been able to solve recursion of EarleyParser.buildSyntaxTrees( ~~~ ).resolve( ~~~ ) but my stress test still does not work, since there is also a recursion on EarleyParser.buildSyntaxTrees( ~~~ ) which now crashes the program.

Since performace is not my main objective, there is a significant performace degradation.

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

No branches or pull requests

1 participant