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

fix: adjust memoization and cache #298

Merged
merged 3 commits into from
May 6, 2023
Merged

fix: adjust memoization and cache #298

merged 3 commits into from
May 6, 2023

Conversation

TarikGul
Copy link
Member

@TarikGul TarikGul commented May 5, 2023

createMetadata specific env vars.

Summary:
createMetadata memoizes the call to ensure metadata is not reallocated in memory if it is the same call.

Methods that actively use createMetadata and are affected are:

  • defineMethod
  • createDecoratedTx
  • createDecoratedConstants
  • createSignedTx
  • decodeSignedTx
  • decodeSigningPayload
  • decodeUnsignedTx

NOTE: getRegistryBase uses createMetadataUnmemoized

TXWRAPPER_METADATA_CACHE_MAX

Summary:
Set the max amount of memoized calls we want in the cache. It uses an LRU cache to handle the input and output of values. This takes in an integer. Ex: export TXWRAPPER_METADATA_CACHE_MAX=10. This will default to unlimited size if the value is not inputted.

NOTES:

  • It is recommended to use a value greater 2 for the cache size as regressions have been seen in some cases for 2 or lower.

TXWRAPPER_METADATA_CACHE_MAX_AGE

Summary:
Set the TTL (Time To Live) for items in the memoized cache. This takes in an integer in the measurement of milliseconds. Ex: export TXWRAPPER_METADATA_CACHE_MAX_AGE=1000 for 1 second.

Other Changes

  • getRegistryBase uses createMetadataUnmemoized instead of createMetadata

@TarikGul TarikGul requested a review from a team as a code owner May 5, 2023 03:46
@TarikGul TarikGul changed the title [WIP] fix: adjust memoization and cache fix: adjust memoization and cache May 5, 2023
Copy link
Collaborator

@marshacb marshacb left a comment

Choose a reason for hiding this comment

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

lgtm!

@TarikGul TarikGul merged commit a0ae8c7 into main May 6, 2023
@TarikGul TarikGul deleted the tarik-fix-cache branch May 6, 2023 00:21
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.

None yet

2 participants