Skip to content

Commit 5af8db0

Browse files
committed
Fix #607: Improve build times drastically
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. ```
1 parent ee72508 commit 5af8db0

36 files changed

+42
-13
lines changed

_includes/tutorial-tour-list.txt

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
{% for pg in site.pages %}
2-
{% if pg.tutorial == "scala-tour" and pg.outof and pg.language == page.language %}
3-
{% assign totalPagesTour = pg.outof %}
4-
{% endif %}
5-
{% endfor %}
1+
{% assign sorted_tour_posts = site.categories.tour | sort: 'num' %}
2+
{% assign tour_posts_size = sorted_tour_posts | size %}
63

7-
{% if totalPagesTour %}
4+
{% if tour_posts_size %}
85
<ul>
9-
{% for i in (1..totalPagesTour) %}
10-
{% for pg in site.pages %}
11-
{% if pg.tutorial == "scala-tour" and pg.num and pg.num == i and pg.language == page.language %}
6+
{% for pg in sorted_tour_posts %}
7+
{% if pg.language == page.language %}
128
<li class="tour-of-scala {% if page.title == pg.title %} current-page {% endif %}">
139
<a href="{{ pg.url }}">{{ pg.title }}</a>
1410
</li>
1511
{% endif %}
1612
{% endfor %}
17-
{% endfor %}
1813
</ul>
1914
{% else %} **ERROR**. Couldn't find the total number of pages in this set of tutorial articles. Have you declared the `outof` tag in your YAML front matter?
2015
{% endif %}

_layouts/tutorial.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
layout: default
2+
layout: post
3+
permalink: /tutorials/:categories/:title/
34
---
45
{% include header.txt %}
56
<div class="wrapper">
@@ -10,8 +11,8 @@
1011

1112
<div class="span10">{% if page.title %}<h1>{{ page.title }}</h1>{% else %}<h1>{{ site.title }}</h1>{% endif %}</div>
1213

13-
{% for pg in site.pages %}
14-
{% if pg.tutorial == "scala-tour" and pg.languages %}
14+
{% for pg in site.categories.tour %}
15+
{% if pg.languages %}
1516
{% assign languages = pg.languages %}
1617
{% endif %}
1718
{% endfor %}

tutorials/tour/abstract-types.md renamed to tutorials/tour/_posts/2017-02-13-2017-02-13-abstract-types.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ title: Abstract Types
55
disqus: true
66

77
tutorial: scala-tour
8+
categories: tour
89
num: 23
910
next-page: compound-types
1011
previous-page: inner-classes

tutorials/tour/annotations.md renamed to tutorials/tour/_posts/2017-02-13-annotations.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ title: Annotations
55
disqus: true
66

77
tutorial: scala-tour
8+
categories: tour
89
num: 32
910
next-page: default-parameter-values
1011
previous-page: automatic-closures

tutorials/tour/anonymous-function-syntax.md renamed to tutorials/tour/_posts/2017-02-13-anonymous-function-syntax.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ title: Anonymous Function Syntax
55
disqus: true
66

77
tutorial: scala-tour
8+
categories: tour
89
num: 7
910
next-page: higher-order-functions
1011
previous-page: mixin-class-composition

tutorials/tour/automatic-closures.md renamed to tutorials/tour/_posts/2017-02-13-automatic-closures.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ title: Automatic Type-Dependent Closure Construction
55
disqus: true
66

77
tutorial: scala-tour
8+
categories: tour
89
num: 31
910
next-page: annotations
1011
previous-page: operators

tutorials/tour/basics.md renamed to tutorials/tour/_posts/2017-02-13-basics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ title: Basics
55
disqus: true
66

77
tutorial: scala-tour
8+
categories: tour
89
num: 2
910
next-page: unified-types
1011
previous-page: tour-of-scala

tutorials/tour/case-classes.md renamed to tutorials/tour/_posts/2017-02-13-case-classes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ title: Case Classes
55
disqus: true
66

77
tutorial: scala-tour
8+
categories: tour
89
num: 11
910
next-page: pattern-matching
1011
previous-page: currying

tutorials/tour/classes.md renamed to tutorials/tour/_posts/2017-02-13-classes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ title: Classes
55
disqus: true
66

77
tutorial: scala-tour
8+
categories: tour
89
num: 4
910
next-page: traits
1011
previous-page: unified-types

tutorials/tour/compound-types.md renamed to tutorials/tour/_posts/2017-02-13-compound-types.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ title: Compound Types
55
disqus: true
66

77
tutorial: scala-tour
8+
categories: tour
89
num: 24
910
next-page: explicitly-typed-self-references
1011
previous-page: abstract-types

0 commit comments

Comments
 (0)