[Repo Assist] perf: pre-compute navigation menu structure once per build (O(n²) → O(n))#1129
Draft
github-actions[bot] wants to merge 4 commits intomainfrom
Draft
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>
10 tasks
…'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>
Contributor
Author
|
Commit pushed:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 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)