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

Perf: Transcript and Activity render speed #5183

Merged
merged 16 commits into from May 16, 2024
Merged

Perf: Transcript and Activity render speed #5183

merged 16 commits into from May 16, 2024

Conversation

OEvgeny
Copy link
Collaborator

@OEvgeny OEvgeny commented May 10, 2024

Fixes #4587.

Changelog Entry

  • Improved performance for BasicTranscript, in PR 5183, by @OEvgeny
  • Fixed potential memory usage issues caused by useActivitiesWithRenderer, in PR 5183, by @OEvgeny

Description

Improve performance by more carefully memoizing activity-related components. Rework the useMemoAll hook into the new useMemoized hook exposing the memoized function to be used during render phase.

Design

The main changes driving the performance boost are:

  • Introduced TranscriptActivity to memoize everything we want to reuse for activity inside of a single component
  • Make renderingElements an array of React nodes, so it could be directly returned from render
  • Better memoize props by momizing children as well, so we could take advantage of memo when children are not changing

Specific Changes

  • BasicTranscript improvements
  • Use memo for activity related components
  • Add name for some components
  • Remove useMemoAll and replace with useMemoized
  • Add tests for useMemoized
  • Add TranscriptActivity component
  • Fix tests
  • Add end-to-end tests

-

  • I have added tests and executed them locally
  • I have updated CHANGELOG.md
  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

@OEvgeny OEvgeny marked this pull request as ready for review May 15, 2024 22:56
Copy link
Contributor

@compulim compulim left a comment

Choose a reason for hiding this comment

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

Excellent. You now know the internals of our chat history. It's one of the most complex parts of Web Chat.

Let's timebox some time and understand why some snapshots need to be updated. Our snapshots tell us a lot more than we understand. They are our teachers. 👨🏻‍🏫

OEvgeny and others added 2 commits May 16, 2024 19:32
Co-authored-by: William Wong <compulim@users.noreply.github.com>
@compulim compulim merged commit aaff0e6 into main May 16, 2024
25 checks passed
@compulim compulim deleted the perf/render-deep branch May 16, 2024 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance improvement on loading chat history
2 participants