Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add experimental new memoizers: autotrack and weakmap#605

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
markerikson merged 9 commits intomasterfromfeature/5.0-experimental-memoizers
May 10, 2023

Conversation

@markerikson
Copy link
Contributor

@markeriksonmarkerikson commentedApr 12, 2023
edited
Loading

This PR:

There's a good chance that these could go into v4.x, but I'm putting them in a 5.x-based build branch for now.

Status and Tradeoffs

Currently,autotrack andweakMap seem to actually work and pass tests.signalis runs but doesn't memoize properly.

autotrack works well! I can confirm that if you do something liketodos => todos.map(t => t.id), and then flipt.completed, it willnot recalculate. However, it also is definitely slower thandefaultMemoize. The question is whether the slowness is enough to matter in practice. On the flip side, the fact that it can recalculate a lot less often in some cases means that there'd be fewer re-renders.

weakMap is closer in speed todefaultMemoize. Haven't done significant testing on it yet. Seems like there's some amount of multi-size behavior by default, but haven't figured out how that grows over time or gets GC'd.

Resources / inspiration / places I swiped code from:

bhollis and tichopad reacted with hooray emojiChrisRast and davidkpiano reacted with eyes emoji
@markerikson
Copy link
ContributorAuthor

Aaaand the build is totally busted due to some Reselect -> RTK -> Reselect dependency thing.

Will worry about that later.

@markeriksonmarkeriksonforce-pushed thefeature/5.0-experimental-memoizers branch 2 times, most recently from9467048 to27c412bCompareApril 15, 2023 02:51
@codesandbox-ci
Copy link

codesandbox-cibot commentedApr 18, 2023
edited
Loading

This pull request is automatically built and testable inCodeSandbox.

To see build info of the built libraries, clickhere or the icon next to each commit SHA.

Latest deployment of this branch, based on commit41959cd:

SandboxSource
VanillaConfiguration
Vanilla TypescriptConfiguration

@markeriksonmarkeriksonforce-pushed thefeature/5.0-experimental-memoizers branch 2 times, most recently from8c62e90 tob644c27CompareApril 18, 2023 18:26
@markeriksonmarkeriksonforce-pushed thefeature/5.0-experimental-memoizers branch 2 times, most recently from1b61862 to2d43549CompareApril 27, 2023 01:19
@markeriksonmarkerikson changed the titleAdd experimental new memoizers: autotrack, weakmap, and signalisAdd experimental new memoizers: autotrack, weakmap, ~~and signalis~~May 10, 2023
@markeriksonmarkerikson changed the titleAdd experimental new memoizers: autotrack, weakmap, ~~and signalis~~Add experimental new memoizers: autotrack and weakmapMay 10, 2023
@markeriksonmarkeriksonforce-pushed thefeature/5.0-experimental-memoizers branch fromb5499d6 to499b734CompareMay 10, 2023 03:09
@markeriksonmarkeriksonforce-pushed thefeature/5.0-experimental-memoizers branch fromc7abf78 to7efdeeaCompareMay 10, 2023 03:22
@markeriksonmarkerikson marked this pull request as ready for reviewMay 10, 2023 03:36
@markerikson
Copy link
ContributorAuthor

Updates since the original PR creation:

  • Deleted thesignalisMemoize implementation. It didn't work right.
  • Cleaned upautotrackMemoize andweakmapMemoize
  • Did some testing onweakmapMemoize in conjunction with@crutchcorn and concluded thatweakmapMemoize haseffectively an infinite cache size, in that the use ofWeakMaps will keep around cached values as long as the args are still in memory, and then clean up the cached values as soon as those args are GC'd.
  • Split the unit tests into several files just for readability, and to enable adding copy-pastes of the "basic selector" tests using bothautotrackMemoize andweakmapMemoize

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@markerikson

[8]ページ先頭

©2009-2025 Movatter.jp