Skip to content

Performance issues related to memory #11

@mikolasstuchlik

Description

@mikolasstuchlik

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions