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

Compilation Performance when adding Custom Tags #131

Open
atonse opened this issue Nov 7, 2023 · 1 comment
Open

Compilation Performance when adding Custom Tags #131

atonse opened this issue Nov 7, 2023 · 1 comment

Comments

@atonse
Copy link

atonse commented Nov 7, 2023

Thank you for this awesome library, we love it 😄

We've noticed that when we add custom tags (of which we've added 8) it slows down our compiles tremendously when processing those tags. So just the tags take about 20 seconds to compile.

Do you know if this is this something that's just a limitation of nimble_parsec and some kind of Big(O) issue with the underlying algorithms or potentially how we're constructing our tags that's resulting in way more parser combinations than needed?

Here's an example of a custom tag:

In Liquid it is:

{% image file_id %}

The elixir:

  @impl true
  def spec(_parser) do
    space = Literal.whitespace(min: 0)

    ignore(BaseTag.opening_tag())
    |> ignore(space)
    |> ignore(string("image"))
    |> ignore(space)
    |> tag(Argument.argument(), :file_id)
    |> ignore(space)
    |> ignore(BaseTag.closing_tag())
  end
@edgurgel
Copy link
Owner

edgurgel commented Jul 9, 2024

Yeah the parser is quite complex and to keep it fast we avoid using lots of "defcombinators". But it's something we can revisit once we have a proper set of benchmarks 🤔.

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

2 participants