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

Antora preview performance issues #907

Open
alaindresse opened this issue Sep 26, 2024 · 7 comments
Open

Antora preview performance issues #907

alaindresse opened this issue Sep 26, 2024 · 7 comments
Labels

Comments

@alaindresse
Copy link
Contributor

Preview update performance is excessively slow (minutes to update a preview on an M1 Pro mac when the source is changed) in large repos with many symlinks (e.g. for nx monorepos with react-native apps and libs).

Using the proposed APIs for findFiles greatly improves the situation, but until that API is finalized, it can only be used with code insiders and it cannot be used in an extension published to the marketplace.

@alaindresse
Copy link
Contributor Author

@ggrossetie a couple things I've seen in the code that might have an impact on performance.

  • reading all files from modules/*/{attachments,examples,images,pages,partials,assets}/** for all antora folders. Is that necessary ?

    • in src/features/antora/antoraDocument.ts, in function getAntoraDocumentContext the code goes through all the antora configs, and for each config, finds all the files in the module folders, and reads the content in the line contents: Buffer.from((await vscode.workspace.fs.readFile(file))).
    • Doesn't this call do quite a lot of file reads (particularly if there are symlinks to e.g. source folders in partials) of which only a couple would actually be used when doing an include ?
      • .contents seems to be used in src/features/antora/includeProcessor.ts and src/features/antora/resolveIncludeFile.ts
  • In src/features/asciidoctorExtensions.ts, function getExtensionFilesInWorkspace, do we really need a findFiles ? Couldn't we have a setting that identifies the one or more extension files to read (the list would probably not change that often).

@ggrossetie
Copy link
Member

reading all files from modules/*/{attachments,examples,images,pages,partials,assets}/** for all antora folders. Is that necessary ?

I think we could potentially lazy load contents (i.e., load contents when we actually need it) but we need to retrieve all the files in order to build a "complete" content catalog.

@alaindresse
Copy link
Contributor Author

reading all files from modules/*/{attachments,examples,images,pages,partials,assets}/** for all antora folders. Is that necessary ?

I think we could potentially lazy load contents (i.e., load contents when we actually need it) but we need to retrieve all the files in order to build a "complete" content catalog.

I was indeed referring to lazy loading the contents. The list of files is clearly needed for suggestions and completion.

@ggrossetie
Copy link
Member

I was indeed referring to lazy loading the contents. The list of files is clearly needed for suggestions and completion.

I think that's an excellent idea, feel free to submit a pull request to lazy load the contents

@ggrossetie
Copy link
Member

I remember now, include processor must be synchronous in Asciidoctor. So we cannot use vscode.workspace.fs.readFile(file) since it's an asynchronous function. I think that's the reason why we are eagerly loading contents.

@alaindresse
Copy link
Contributor Author

What I would consider:

  • Check if fs from node.js is available when we create the content catalog
    • If not available, we preload the contents to use as today
    • If so, we do not preload (e.g. setting contents to undefine), and we use fs.readFileSync in the include processor to add contents whenever contents is undefined.

@alaindresse
Copy link
Contributor Author

Quite busy these days, but I'm not dropping the ball

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants