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

Optimize Caching #823

Merged
merged 11 commits into from
Dec 9, 2020
Merged

Optimize Caching #823

merged 11 commits into from
Dec 9, 2020

Conversation

robinweser
Copy link
Owner

@robinweser robinweser commented Dec 5, 2020

Description

This PR adds a feature flag to the renderer which enables optimized caching.
Once it's stable, it'll become the new standard caching mechanism.

What it does

It adds a new layer of smart caching that enables us to run some plugins only once per class.
This can be a huge performance boost! Our own benchmarks showed improvements between 30-50% and the difference should grow with the pure amount of renders.

Plugins that are eligible for smart caching:

  • unit
  • prefixer
  • fallback-value

Downsides

The only downside is, that those plugins are "removed" from the classic plugin order and thus plugins such as the logger or validator might render different results or yield errors.
We can solve this later on by making validator an optimized plugin as well. The logger could also become an optimized plugin, but its functionality would differ.
Given that both are non-production plugins, we won't include that in this PR but handle it in a future PR to keep the scope and complexity as low as possible for this one.

Example

If required, add a code example or a link to a working example (repository).

import { createRenderer } from "fela"
import unit from "fela-plugin-unit"
import prefixer from "fela-plugin-prefixer"

const renderer = createRenderer({
  optimizeCaching: true,
  plugins: [unit(), prefixer()]
})

Packages

List all packages that have been changed.

  • fela
  • fela-plugin-prefixer
  • fela-plugin-unit
  • fela-plugin-fallback-value

Versioning

Minor

Checklist

Quality Assurance

You can also run yarn run check to run all 4 commands at once.

  • The code was formatted using Prettier (yarn run format)
  • The code has no linting errors (yarn run lint)
  • All tests are passing (yarn run test)
  • There are no flow-type errors (yarn run flow)

Changes

If one of the following checks doesn't make sense due to the type of PR, just check them.

  • Tests have been added/updated
  • Documentation has been added/updated
  • My changes have proper flow-types

@vercel
Copy link

vercel bot commented Dec 5, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/robinweser/fela/5maodrm61
✅ Preview: https://fela-git-plugin-optimisation.robinweser.vercel.app

@robinweser robinweser merged commit 0b77b45 into master Dec 9, 2020
@robinweser robinweser deleted the plugin-optimisation branch December 11, 2020 09:56
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.

1 participant