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

perf(extract): splits compiler availability and execution #804

Merged
merged 1 commit into from
Apr 30, 2023

Conversation

sverweij
Copy link
Owner

Description

  • repurposes src/extract/transpile/meta.mjs as a main entry for transpilation & data about transpilation options available in the environment to just the data about transpilation.
  • adds a new utility to check whether a transpiler is available - one that just require.resolve's the thing instead of importing or requiring it. This is a lot faster, especially when checking for big transpiler modules (e.g. typescript, babel).
  • moves transpilation itself to src/extract/transpile/index.mjs

Motivation and Context

  • Better design wise
    The meta.mjs module now only has one responsibility: providing information about the environment.

  • Gives better performance
    It reduces dependency-cruiser's startup time - loading the transpilers is now shifted to after checking the cache, so 100% cached runs are quite a bit faster. For normal runs there is almost no difference, though. Yet.

  • Enables some new performance optimizations.
    Now there's only one entry point for the transpilers (and only one module using them), it's a lot easier to optimize that as well (will be in a separate PR or commit).

How Has This Been Tested?

  • green ci
  • adapted automated non-regression tests

Performance checks

Before

100% served from cache

bin/dependency-cruise.mjs src bin test configs types tools --ignore-known --cache node_modules/.cache/dependency-cruiser/load-cached --no-progress
  Time (mean ± σ):      1.184 s ±  0.014 s    [User: 1.232 s, System: 0.191 s]
  Range (min … max):    1.169 s …  1.225 s    30 runs

without a cache

 bin/dependency-cruise.mjs src bin test configs types tools --ignore-known --no-cache --no-progress
  Time (mean ± σ):      3.074 s ±  0.028 s    [User: 4.757 s, System: 0.319 s]
  Range (min … max):    3.044 s …  3.203 s    30 runs

After

100% served from cache

On my old, 4 core mac it's about 2.4x faster than before this PR:

Benchmark 1: bin/dependency-cruise.mjs src bin test configs types tools --ignore-known --cache node_modules/.cache/dependency-cruiser/load-cached --no-progress
  Time (mean ± σ):     490.1 ms ±   6.8 ms    [User: 520.5 ms, System: 113.4 ms]
  Range (min … max):   483.9 ms … 512.8 ms    30 runs

without a cache

About the same performance (the mean is 1.005x slower, but these 0.016 s are still within the σ of both runs).

bin/dependency-cruise.mjs src bin test configs types tools --ignore-known --no-cache --no-progress
  Time (mean ± σ):      3.090 s ±  0.026 s    [User: 4.804 s, System: 0.326 s]
  Range (min … max):    3.055 s …  3.176 s    30 runs

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation only change
  • Refactor (non-breaking change which fixes an issue without changing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • 📖

    • My change doesn't require a documentation update, or ...
    • it does and I have updated it
  • ⚖️

    • The contribution will be subject to The MIT license, and I'm OK with that.
    • The contribution is my own original work.
    • I am ok with the stuff in CONTRIBUTING.md.

src/cli/index.mjs Outdated Show resolved Hide resolved
@sverweij sverweij force-pushed the perf/split-compiler-availability-and-execution branch 2 times, most recently from 79c4839 to 36b8e7e Compare April 30, 2023 15:43
@sverweij sverweij force-pushed the perf/split-compiler-availability-and-execution branch from 36b8e7e to 0772591 Compare April 30, 2023 16:33
@sverweij sverweij merged commit 4fdaf68 into develop Apr 30, 2023
@sverweij sverweij deleted the perf/split-compiler-availability-and-execution branch April 30, 2023 16:42
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