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

Jekyll/Liquid generation is dead-slow because of tutorial ToC #607

Closed
dragos opened this issue Oct 21, 2016 · 12 comments
Closed

Jekyll/Liquid generation is dead-slow because of tutorial ToC #607

dragos opened this issue Oct 21, 2016 · 12 comments
Labels

Comments

@dragos
Copy link

dragos commented Oct 21, 2016

All the time is spent in several nested loops computing the table of contents for tutorials. Unfortunately Liquid is a pretty poor language so there aren't any obvious workarounds, but it's definitely worth investigating. Once I commented those loops times went down to around 1s.

Maybe a solution using categories or tags would reduce the number of iterations (350 pages, but only 33 are part of the Scala tour).

$ bundle exec jekyll serve --profile --incremental
Configuration file: /Users/dragos/workspace/git/scala.github.com/_config.yml
            Source: /Users/dragos/workspace/git/scala.github.com
       Destination: /Users/dragos/workspace/git/scala.github.com/_site
 Incremental build: enabled
      Generating... 
    Liquid Warning: Liquid syntax error (line 164): Unexpected character { in "{{{` and `}}" in overviews/scaladoc/for-library-authors.md

Filename                                                           | Count |     Bytes |    Time
-------------------------------------------------------------------+-------+-----------+--------
_layouts/tutorial.html                                             |   132 | 20395.38K | 202.110
_includes/tutorial-tour-list.txt                                   |   133 | 18740.42K | 197.912
_includes/tutorial-toc.txt                                         |   132 | 18618.52K | 196.613
_layouts/overview-large.html                                       |   164 | 24041.61K | 151.205
_includes/toc-large.txt                                            |   164 | 20639.72K | 144.796
tutorials/index.md                                                 |     1 |   184.98K |   1.759
_layouts/overview.html                                             |    36 |  1177.23K |   1.444
es/overviews/index.md                                              |     1 |    41.87K |   0.729
_includes/localized-overview-index.txt                             |     1 |    41.71K |   0.728
_includes/header.txt                                               |   369 |  1777.55K |   0.456
@jarrodu
Copy link
Member

jarrodu commented Oct 21, 2016

I am not sure if speed is really something that need to optimized for. It is just an annoyance.

What is your motivation for working on it?

@SethTisue
Copy link
Member

SethTisue commented Oct 21, 2016

@jarrodwb getting the site build down time from minutes to seconds seems like a pretty sweet improvement to me, if it can be done!

@jarrodu
Copy link
Member

jarrodu commented Oct 21, 2016

Okay you convinced me. ;)

@SethTisue
Copy link
Member

at scala/scala-lang#493 (comment) Simon seemed to be saying this was fixed in his fork, so it might be worth looking there and trying to find what the relevant change was

@heathermiller
Copy link
Member

heathermiller commented Oct 21, 2016

Just to respond to @dragos's description; yes I think there's a way to get rid of all of the loops. Back when I built this whole thing, there were no categories or tags built into Jekyll (they were only available as plugins, which were incompatible with GitHub pages, so we couldn't ever use them before). I had commented at length about this problem elsewhere in this repo in an issue (will look for it); but basically the difference is that categories seem to be an actual array of things under the name of your category that you can revisit rather than having to traverse every page on the whole site again and again and again.

@SethTisue
Copy link
Member

SethTisue commented Oct 21, 2016

I had commented at length about this problem elsewhere in this repo in an issue

probably this comment and this followup

@SethTisue
Copy link
Member

I dug around and found this old description of the problem (and a solution) from Simon:

if you traverse every document ever written on every page that could need it, things will be slow.
my compile time is around 0.9 seconds per page by just not doing that. e. g. we have languages: [en, es, de, ko] already in the frontmatter, so we don't need to traverse all the files looking for a translation for every translation. my approach is slightly more low-tec, but it works: If I say that I have a translation, it just links to it.

@charafau
Copy link
Contributor

charafau commented Nov 2, 2016

I was talking with Simon the other day. This is what he said:

https://github.com/soc/scala-lang/blob/gh-pages/documentation/tutorial/java/index.md
languages: [en, de, es, ko]

It is not perfect (as you need to add translations manually) but I don't think that translations are added that often. (check raw file)

@SethTisue SethTisue added the Bug label Nov 10, 2016
@adamvoss
Copy link

adamvoss commented Dec 4, 2016

Link is broken since that repository does not exist anymore. Here is a mirror:

https://github.com/dwijnand/scala-lang/blob/soc/documentation/tutorial/java/index.md

@SethTisue
Copy link
Member

@heathermiller
Copy link
Member

Another thing we can do: if there is some kind of Jekyll plugin that'll help us speed things up, we could consider building/serving docs.scala-lang.org on an EPFL machine. Both hosting on GitHub and hosting on EPFL machines have their drawbacks, but one relative benefit of running on EPFL infrastructure is our ability to use stuff like plugins. Just brainstorming.

jvican added a commit to jvican/docs.scala-lang that referenced this issue Feb 13, 2017
Per @dragos's suggestion, this commit implements a new approach to
generate table of contents that uses internally populated Jekyll data
structures to speed up listing and matching posts that are from the same
category.

As categories are only populated by posts and our current tutorials are
pages, this commits turns pages into posts and makes sure that their
permalinks correspond to the current ones.

Build times are now around two minutes, see the following profile
information from Jekyll:

```
jvican in /data/rw/code/scala/scala.github.com                                                                                                                 [11:02:40]
> $ bundle exec jekyll serve --profile                                                                                                           [±drone-integration ●●●]
Configuration file: /data/rw/code/scala/scala.github.com/_config.yml
Configuration file: /data/rw/code/scala/scala.github.com/_config.yml
            Source: /data/rw/code/scala/scala.github.com
       Destination: /data/rw/code/scala/scala.github.com/_site
 Incremental build: disabled. Enable with --incremental
      Generating...

Filename                                                           | Count |     Bytes |   Time
-------------------------------------------------------------------+-------+-----------+-------
_layouts/overview-large.html                                       |   164 | 26568.57K | 92.778
_includes/toc-large.txt                                            |   164 | 23156.00K | 88.934
_layouts/tutorial.html                                             |   199 |  3005.98K |  1.350
_layouts/overview.html                                             |    37 |  1190.86K |  0.953
_includes/tutorial-toc.txt                                         |   199 |   267.11K |  0.455
es/overviews/index.md                                              |     1 |    46.66K |  0.443
_includes/localized-overview-index.txt                             |     1 |    46.49K |  0.443
_includes/tutorial-tour-list.txt                                   |   200 |   244.89K |  0.432
_includes/header.txt                                               |   439 |  2114.25K |  0.347
_layouts/cheatsheet.html                                           |     6 |   225.08K |  0.217
_includes/cheatsheet-sidebar.txt                                   |     6 |    42.70K |  0.207
style/index.md                                                     |     1 |    68.00K |  0.184
_includes/footer.txt                                               |   449 |   855.91K |  0.175
tutorials/index.md                                                 |     1 |    54.34K |  0.168
_includes/footerbar.txt                                            |   458 |   767.51K |  0.116
_includes/topbar.txt                                               |   419 |   822.04K |  0.110
_includes/pager.txt                                                |   363 |    27.10K |  0.079
_layouts/sip.html                                                  |    29 |   626.83K |  0.079
_layouts/guides-index.html                                         |     4 |    55.73K |  0.069
_includes/disqus.txt                                               |   386 |   324.89K |  0.044
_layouts/sip-landing.html                                          |    10 |   171.17K |  0.038
_includes/toc.txt                                                  |    66 |    17.62K |  0.034
_layouts/default.html                                              |   261 | 29198.78K |  0.030
_includes/allsids.txt                                              |    10 |    17.88K |  0.019
_layouts/index.html                                                |     7 |   261.62K |  0.011
_includes/sips-topbar.txt                                          |    39 |    31.73K |  0.008
sips/pending/_posts/2016-01-11-static-members.md                   |     1 |    10.23K |  0.004
_includes/index-header.txt                                         |     7 |    53.96K |  0.004
_includes/cheatsheet-header.txt                                    |     6 |    57.92K |  0.003
_layouts/contribute.html                                           |     1 |    21.40K |  0.003
_includes/frontpage-footer.txt                                     |     9 |    15.29K |  0.003
sips/sip-list.md                                                   |     1 |     3.19K |  0.003
sips/completed/_posts/2016-06-25-trailing-commas.md                |     1 |    10.62K |  0.002
_layouts/news-coursera.html                                        |     1 |    26.31K |  0.002
_layouts/frontpage.html                                            |     1 |    13.17K |  0.002
_layouts/page.html                                                 |     1 |    14.69K |  0.002
_layouts/glossary.html                                             |     1 |    65.08K |  0.002
_layouts/search.html                                               |     1 |    12.77K |  0.002
_includes/contributing-header.txt                                  |     2 |    12.13K |  0.001
sips/minutes-list.md                                               |     1 |     0.76K |  0.001
ja/overviews/collections/concrete-mutable-collection-classes.md    |     1 |    13.02K |  0.001
overviews/collections/concrete-mutable-collection-classes.md       |     1 |    11.09K |  0.001
ja/overviews/collections/overview.md                               |     1 |     8.73K |  0.001
_includes/header-coursera.txt                                      |     1 |     5.21K |  0.001
_includes/frontpage-header.txt                                     |     1 |     4.94K |  0.001
es/overviews/parallel-collections/concrete-parallel-collections.md |     1 |    13.97K |  0.001
overviews/parallel-collections/concrete-parallel-collections.md    |     1 |    12.57K |  0.001
sips/sip-template.md                                               |     1 |     4.30K |  0.001
overviews/collections/concrete-immutable-collection-classes.md     |     1 |    14.17K |  0.001
_includes/glossary-header.txt                                      |     1 |    10.10K |  0.001

                    done in 123.422 seconds.
```
heathermiller added a commit that referenced this issue Feb 13, 2017
Fix #607: Improve build times drastically
@SethTisue
Copy link
Member

yay!!! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants