ampproject / amphtml

The AMP web component framework.
https://amp.dev
Apache License 2.0
14.89k stars 3.89k forks source link

🐌 amp-mathml is painfully slow. Benchmarking amp-mathml vs. KaTeX #29729

Open hayesall opened 4 years ago

hayesall commented 4 years ago

Describe the new feature or change to an existing feature you'd like to see

The current version of amp-mathml seems to be based on MathJax. This is a huge bottleneck for pages with lots of math. An alternative version based on KaTeX might fix this.

Describe alternatives you've considered

The current implementation does work, but it doesn't deliver on the fast load times AMP intends to have.

Additional context

I cannot promise intend-to-implement I2I any time soon.

Benchmarks below.


The Benchmark

This benchmark is based on a summary of "Mirror Descent for Metric Learning: A Unified Approach" that includes 88 math blocks, mixed between inline blocks and equations.

Two versions of this web page were created:

  1. Based on amp-mathml
  2. Based on KaTeX

Reproducing

See this gist: https://gist.github.com/hayesall/33ba7aed8ebfbf0dba761cb7ba501342

git clone https://gist.github.com/hayesall/33ba7aed8ebfbf0dba761cb7ba501342 hayesall-amp-demo
cd hayesall-amp-demo
python -m http.server    # Start an HTTP server with Python 3
AMP Complient? Method URL
No KaTeX http://0.0.0.0:8000/katex.html
Yes amp-mathml http://0.0.0.0:8000/amp-mathml.html#development=1

Preview of part of the benchmark page:

mdml_section2_border

Benchmark 1: amp-mathml

All equations were rendered after around 22,000 ms:

amp-mathml-flame-chart-border

Benchmark 2: KaTeX

There is some delay in the beginning between when I refreshed the page, but the rendering took place between 1000 ms and 1200 ms, or around 200 ms.

katex_flamegraph-border

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

jaygray0919 commented 2 years ago

bump

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.