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

Exponential rendering time using createRichTextObjectResolver #374

Open
Piwaii opened this issue Aug 18, 2023 · 6 comments
Open

Exponential rendering time using createRichTextObjectResolver #374

Piwaii opened this issue Aug 18, 2023 · 6 comments
Assignees

Comments

@Piwaii
Copy link

Piwaii commented Aug 18, 2023

Brief bug description

We are rendering a big article with markup (56000 characters) using createRichTextObjectResolver and it takes more than 25 seconds to answer.

Repro steps

  1. Create a big rich text article with markup (more than 50000 characters)
  2. Try to render it with createRichTextObjectResolver
  3. See error or too much time to render

Expected behavior

Event if it's a big article, it should render in a reasonable time (avoiding possible timeouts)

Test environment

  • Platform : nextjs and nodejs
  • Browser : all
  • SDK Version 12.4.3

Additional context

We tested it in a little project (repo can be shared on demand) and the results are these :

  • 3209 characters: resolved in 89ms
  • 11633 characters: resolved in 544ms
  • 34483 characters: resolved in 3938ms
  • 51071 characters: resolved in 8886ms
  • 74730 characters: resolved in 21306ms
@Simply007
Copy link
Contributor

Sorry to hear that @Piwaii,

Can you provide the data you used for the testing? I am interested in the complexity of the input.

We are currently working on the replacement for rich text resolution to unify the capabilities. Would you be willing to try to render your data using Ritch text resolver?

An example of use could be seen in the README of the linked repository, or on https://github.com/Simply007/kontent-starter-corporate-next-js/blob/main/src/components/RichText.js.

@Piwaii
Copy link
Author

Piwaii commented Aug 18, 2023

Indeed this new lib is very efficient :

rendering 74730 characters
  - before was resolved in 22271ms with createRichTextObjectResolver()
  - now is resolved in 8ms with nodeParse()

we will definitely follow this new repo :)

thank you very much @Simply007

@Simply007
Copy link
Contributor

Thanks for sharing the result! It looks awesome.

Parsing seems very efficient. Have you just parsed the input, or also used the resolution library (i,e, linked https://www.npmjs.com/package/@portabletext/react)?

@Piwaii
Copy link
Author

Piwaii commented Aug 18, 2023

We measured only the parsing

@davshoward
Copy link

An example of use could be seen in the README of the linked repository, or on https://github.com/Simply007/kontent-starter-corporate-next-js/blob/main/src/components/RichText.js.

This is great - thank you. Is there an example of this using TypeScript? Adds an extra layer of complexity :-p

@Enngage
Copy link
Contributor

Enngage commented Nov 1, 2023

I'm looking into implementing a simpler (RegEx & replace) based solution in this SDK as a replacement for the browser / parse5 parser that this SDK currently uses. I've implemented it in another project already and saw a huge improvement in speed.. what took 1 minute using the node.js parser now takes under a second in new implementation.

I'm hoping to look into this in near future, but can't promise anything just yet ;)

@Enngage Enngage self-assigned this Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants