microsoft / microsoft/BotFramework-WebChat

Performance: <BasicTranscript> should use useMemoArrayMap() to memoize the result

Open
#2,711 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backlog feature-request
Dominant language
HTML
Stars
1.8k
Forks
1.6k
Avg merge
22h 58m
Merged PRs (30d)
2

Description

Feature Request

Note: the performance gain here is minimal. Reducing a O(n) of object creation/destruction on every incoming/outgoing activity.

Excerpt from the code.

// TODO: [P2] We can also use useMemoArrayMap() for this function.
//       useMemoArrayMap(array, mapper) will need to be modified to useMemoArrayMap(array, mapper, getDeps).
//       This is because the deps for every item is not itself anymore. It will include activityElements[index + 1].
const activityElementsWithMetadata = useMemo(
)

Implementation

  • Modify useMemoArrayMap(array, mapper)
    • Change it to useMemoArrayMap(array, mapper, getDeps = (item, index) => [item])
    • getDeps allow the mapper to cache the per-item deps
    • Modify prevResult = prevMapperCalls.find() to look for an array of deps, instead of value

[Enhancement]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating useMemoArrayMap and the implementation, then read how the current activityElementsWithMetadata memoization works. Update the utility to accept per-item dependencies and apply it to the transcript mapping; done means the requested memoization path is used without changing the resulting metadata.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.