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

feat: cache module metadata & cacheable deserialize #2082

Open
wants to merge 28 commits into
base: v2-dev
Choose a base branch
from

Conversation

shulandmimi
Copy link
Member

@shulandmimi shulandmimi commented Feb 9, 2025

Description:

module metadata cache(Replace write_plugin_cache, plugin_cache_loaded)

  1. module metadata cache
// write cache
context.cache_manager.module_cache.write_metadata(key, name, value)

// read cache
context.cache_manager.module_cache.read_metadata_ref(key, name)
  1. Cacheable deserialize_bytes remove unused self param
module.deserialize_bytes(bytes);
// =>
Module::deserialize_bytes(bytes);
  1. combine cache item to files

The cached content will be allocated to some files based on the name, with a maximum of 16 files in total.

https://github.com/farm-fe/farm/pull/2082/files#diff-93e90e2f791f9d64f51ed1c604bd2ad5303e41d37d243f9a05ebd3bbe98b7275R74

    sha256(name.as_bytes(), 32)
      .chars()
      .fold(0u8, |r, i| (r + i as u8) % 16)
  1. merge store

Combine module, plugin, and custom store into one

  1. store add shutdown fn

BREAKING CHANGE:

Related issue (if exists):

Copy link

changeset-bot bot commented Feb 9, 2025

🦋 Changeset detected

Latest commit: f797e18

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

💥 An error occurred when fetching the changed packages and changesets in this PR
Some errors occurred when validating the changesets config:
The package or glob expression "farm-docs" is specified in the `ignore` option but it is not found in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.

@shulandmimi shulandmimi marked this pull request as ready for review February 10, 2025 12:49
Base automatically changed from feat/multi-source-map-codegen to v2-dev February 10, 2025 15:32
@shulandmimi shulandmimi changed the title feat: cache module metadata & cachable deserialize feat: cache module metadata & cacheable deserialize Feb 17, 2025
content_map.insert(k, v);
if context.cache_manager.enable {
if let Some(cache) = context
.cache_manager
Copy link
Member

Choose a reason for hiding this comment

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

This way is the same as plugin_cache_load, we want the cache key control by the module instead of the plugin, so we may need to add a API like context.cache_manager.add_module_extra_info the these info will be appended when write the module cache.

When reading cache, we can use handle_persistent_cached_module hook to restore the cache back to the plugin

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.

3 participants