solid icon indicating copy to clipboard operation
solid copied to clipboard

Compilation Performance when adding Custom Tags

Open atonse opened this issue 1 year ago • 1 comments

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

atonse avatar Nov 07 '23 18:11 atonse