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

Slow Page index with many pages #183

Open
rhartmann opened this issue Jan 17, 2025 · 3 comments
Open

Slow Page index with many pages #183

rhartmann opened this issue Jan 17, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@rhartmann
Copy link
Contributor

rhartmann commented Jan 17, 2025

It seems that every access of the Page Index /-/index loads and parses the markdown of every .md file in the repository to assemble the ToC of each file. While I am aware this is required for Toggle page headers, I noticed somewhat slow loading times when dropping 330-ish files into Otterwiki. Header depth of most pages is 3 or below. Every hit of /-/index takes ~3-4 seconds to parse all the pages, which will cause acceptance issues with some people.

I did some tests using empty strings or loading only the first 200 bytes per file from storage. Both improved loading times of the Page Index greatly (<0.2 seconds) at the cost of not having page headers available for display. I suppose the markdown parsing is the costly part.

On top of that, showing all the page headers for 300+ pages is not very helpful. The Page Index is utterly long and cluttered when showing page headers.

I'd love to have the loading of page headers either be opt-in, cached, asynchronous (when the page already shows) or on-demand (when the user hits the toggle).

@redimp redimp added the enhancement New feature or request label Jan 17, 2025
@redimp
Copy link
Owner

redimp commented Jan 17, 2025

Hey @rhartmann, thank you for reporting this issue.

When I implemented this I thought about caching the page structure .. but I like your idea of loading this on-demand better. Will check and think about both approaches to solve this.

@rhartmann
Copy link
Contributor Author

Maybe another useful approach: Introduce an environment variable to make it configurable. Like:

if len(md_files) > int(app.config.get('LOAD_HEADERS_PAGE_LIMIT', 50)):
  # Too many pages. Do not load page headers (and hide or disable the toggle)

This also provides opt-out (you could set it to 0 to never load page headers) and could be combined with cache, asynchronous or on-demand.

@redimp
Copy link
Owner

redimp commented Jan 21, 2025

The code for caching the headers is ready and will be released in the next version. Working on other issues that I want to include too. Planing to release it this week. 🤞

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

No branches or pull requests

2 participants