Conversation
Replace GetNavigationEntries (called once per page) with GetNavigationEntriesFactory, which pre-computes the expensive filter/group/sort structure once and returns a cheap closure that only applies IsActive flags and generates HTML. For a site with n pages, this reduces: - sorting/grouping: from O(n × n log n) to O(n log n) - File.Exists calls for template detection: from 2n to 2 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…'Performance' '### Performance' is not a recognised Keep a Changelog subsection. Ionide.KeepAChangelog.Tasks 0.3.3 enforces the standard categories (Added, Changed, Deprecated, Fixed, Removed, Security), causing the build to fail with IKC0002. Rename to '### Changed'. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Commit pushed:
|
|
/repo-assist Assess unit testing for this area, and add more unit tests |
|
✓ Repo Assist completed successfully at {run-ended}. |
This comment has been minimized.
This comment has been minimized.
|
/repo-assist Assess unit testing for this area, and add more unit tests by updating this PR |
|
✓ Repo Assist completed successfully at {run-ended}. |
15 tests covering: - Empty input → empty output - Single uncategorized model → Documentation header - None currentPagePath → no active item - Matching/non-matching page path → correct active state - Exactly one active item among multiple pages - Exclusion of isOtherLang, non-HTML, and index file models - ignoreUncategorized flag (true and false) - Category ordering by CategoryIndex - Item ordering within a category by Index - Factory idempotency (multiple calls, same result) - Per-page active state correctness across successive calls Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Commit pushed:
|
|
🤖 This is an automated response from Repo Assist. I've added 15 unit tests for
All 135 tests pass (120 existing + 15 new).
|
|
@nojaf This is a good perf optimization, plus added testing, I'll merge it. |
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
fsdocs buildcalledGetNavigationEntriesonce per output page to generate the sidebar navigation HTML. Each call did the full work: filter doc models, group by category, sort categories, sort items within each group, and check the filesystem for custom menu templates. With n pages this resulted in O(n²) work overall.This PR replaces
GetNavigationEntrieswithGetNavigationEntriesFactory, which separates the expensive structure computation from the cheap HTML rendering:File.Exists(template check)Change
DocContent.GetNavigationEntriesFactory(input, docModels, ignoreUncategorized)— pre-computes the sorted groups and template check once, returnsstring option -> string.GetNavigationEntries(only used internally in two call sites, both updated).runDocContentPhase1, a singlegetNavEntriesfactory closure is created; the per-page loop callsgetNavEntries (Some currentPagePath)instead of repeating the full computation.Impact
For a site with 50 pages: ~49 fewer sort passes and ~98 fewer
File.Existscalls per build / watch cycle. For large sites (200+ pages) the savings grow proportionally.Trade-offs
GetNavigationEntriesFactoryclosure holds a reference tosortedGroups(the pre-sorted(string * LiterateDocModel) list list). Memory footprint is the same as before (the models were already in memory).Test Status
✅ All tests passed (281 Markdown + 120 Literate + 30 CodeFormat + 92 ApiDocs + 8 fsdocs-tool = 531 tests, 0 failures)