zowe / docs-site

Documentation for the Zowe project
https://docs.zowe.org/
Creative Commons Attribution 4.0 International
69 stars 135 forks source link

[dev] Docs-site memory optimization #2766

Open zFernand0 opened 1 year ago

zFernand0 commented 1 year ago

These are some suggestions that came out as a result of discussions on how the docs-site could optimize its memory usage.

Benefits After implementing all of these suggestions, we could see the following benefits:

1000TurquoisePogs commented 1 year ago

note on jpgs & pngs - webms are supported on everything these days, and are generally smaller so it can be a relatively automated process to do it on every image that comes in. it's lossy, but hopefully not an issue.

1000TurquoisePogs commented 1 year ago

I did research on this over the weekend and found many complaints about docusaurus from other users. Simply, it scales badly with quantity of markdown files.

There are things you can do to buy yourself time. As seen in https://github.com/facebook/docusaurus/issues/4765 You can:

The above will fix your builds, perhaps indefinitely, but as they're band-aids to the problem, also consider:

t1m0thyj commented 1 year ago

~I did some research on this last night and it seems we may be able to reduce memory usage by changing our images to be static assets.~

Tested that in this PR and it got past the Out of Memory error. I think this could buy us a lot of time, since our text content is way smaller than images. The main concern I have about this approach is whether performance would suffer for users browsing the site (see https://docusaurus.io/docs/markdown-features/assets#static-assets).

Edit: After further testing, it seems there were other factors involved which tainted initial testing, and changing images to be static would actually increase our memory usage rather than decreasing it.

KUGDev commented 1 year ago

Just some proposals in here. I've looked through the docs directory. There is a dir called "versioned_docs" that is 2 GB approx. Maybe it would be cool to make some versioning based on diffs (something like the GitHub has) instead of carrying all of the versions as is? From my pov, it will reduce the amount of the used space. The second proposal: move all the media (GIFs, images, videos) away from the repo and in the docs repo just bring references to that media files if it is possible. The third one: restrict somehow a size of media files to be no more than some reasonable size (10-20-30 MB). Probably, I can make some research on the proposals, or at least help someone who is interested.

t1m0thyj commented 1 year ago

Update to a newer version of docusaurus. We're running a 2 year old beta. I managed to update it to a newer beta before hitting breaking changes that I couldn't find documentation on so I stopped bothering for now.

Made an attempt at this in the test-docusaurus-update-timothy branch if anyone is curious to investigate.

~Got pretty far in the process of upgrading from v2.0.0-beta to the latest version (currently v2.4.0). Had to add some Webpack polyfills and update some Docusaurus imports, but after doing that the latest error has me kind of stuck. Every page fails to build with this error: TypeError: Cannot read properties of undefined (reading 'label')~

Update: Thanks @traeok for fixing the build to work with 2.4.0: https://github.com/zowe/docs-site/pull/2865