getzola/zola

Architecture for less iterations over the library

Open

#1112 aperta il 31 lug 2020

Vedi su GitHub
 (12 commenti) (0 reazioni) (0 assegnatari)Rust (1046 fork)batch import
enhancementhelp wanted

Metriche repository

Star
 (15.349 star)
Metriche merge PR
 (Merge medio 48g 17h) (4 PR mergiate in 30 g)

Descrizione

This is not exactly a bug report, but when i was investigating site::load() i realized the pages/sections collections get iterated over many times. For a simple build, it iterates over:

  • sections (loop l. 174)
  • pages (loop l. 182)
  • sections & pages (library.check_for_path_collisions() l.197)
  • pages (library.populate_taxonomies() l. 205)
  • sections and pages (self.populate_sections() l. 207, 5 times for sections, 2 for pages because of other calls inside this function)
  • sections and pages (self.render_markdown l. 208, 2 times for pages)
  • sections and pages (check_internal_links_with_anchors() l. 212)
  • sections and pages (check_external_links() l.215, only in check mode)

Without check mode, that's a total of 9 iterations over sections and 8 iterations over pages. This is only for iterations after the library is built. There may be some compiler magic behind the scenes to "reunite" some iterations in there, but my intuition is there's a lot of potential performance improvements to be investigated here.

I think some of the useless iterations are due to the absence of library structure due to the glob pattern (reuniting children pages with related sections, and building content hierarchy). Maybe a recursive descent into the content folder could help here?

Guida contributor