Skip to content

Add an upper limit text size for element text caching #215

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

schwartzmx
Copy link
Member

  • Adds an upper limit to reduce chance of storing large strings in the cache which can increase memory of the cache map

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 18, 2024
@@ -448,6 +448,7 @@ export type ALElementTextOptions = Types.Options<
updateText?: <T extends ALElementText>(elementText: T, domSource: ALDOMTextSource) => void;
getText?: <T extends ALElementText>(elementTexts: T[]) => ALElementText;
enableElementTextCache?: boolean;
elementCacheTextLengthLimit?: number;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should apply this limit only for caching, or in general for the elementText?
It might be useful to say, if text is large, probably our algorithm is not working correctly.
In that case, may be instead of just not caching, we can replace it with something very clear like: !$ELEMENT$TEXT$TOO$LARGE$! (something we know is very unlikely to exist in the application itself).
This way, we still get the perf benefit of large text.

With this implementation, we actually going to turn off caching for the worst offender, i.e. large text extraction!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that is a good point and I was thinking about that as well.
The issue though is I didn't want to cause any havoc with any existing reliance on large text, but we could look at going with your suggested approach behind a flag.

- Adds an upper limit to reduce chance of storing large strings in the cache which can increase memory of the cache map
Copy link
Contributor

@reshadi reshadi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants