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

Performance improvements #303

Merged
merged 4 commits into from Mar 9, 2024
Merged

Performance improvements #303

merged 4 commits into from Mar 9, 2024

Conversation

timocov
Copy link
Owner

@timocov timocov commented Feb 20, 2024

Partially fixes #302

With the following input declaration file:

// index.d.ts
import { Context } from 'effect';

export declare const foobar: <Self, Shape>() => Context.TagClass<Self, string, Shape>;
export type A = string;

export {};

The execution time of ./node_modules/.bin/dts-bundle-generator src/index.d.ts --no-check dropped from 2.64s to 1.26s (more than 2x), which is much closed to just running tsc 0.96s (but still not ideal).

cmd NPM PR Diff
dts-bundle-generator src/index.d.ts --no-check 1 2.64s 1.26s -1.38s (-52%)
dts-bundle-generator src/index.d.ts 2 3.45s 2.07s -1.38s (-40%)
dts-bundle-generator src/index.ts --no-check 3.3s 1.8s -1.5s (-45%)
dts-bundle-generator src/index.ts 2 4s 2.52s -1.48s (-37%)

So overall it is around 40-50% execution time decrease on this particular example. It is worth to say that effect is a massive library and it pushes the compiler a lot in terms of types, parsing/processing/validation time.

Footnotes

  1. If all input files are declaration files then it goes much faster because there is no need in extra

  2. --no-check disables extra compilation after the job is done thus is faster, but less safer 2

@timocov
Copy link
Owner Author

timocov commented Feb 20, 2024

As the next step I'll try to reduce validation time as technically we can re-use the same caches during the validation time (when running without --no-check) to avoid processing the same files again and again, probably get drop a few extra hundreds of ms. Extracted into different issue #307 as it might not be possible without a breaking change or some refactoring.

@timocov timocov marked this pull request as ready for review March 9, 2024 16:38
@timocov timocov merged commit c092c03 into master Mar 9, 2024
4 checks passed
@timocov timocov deleted the perf-improves branch March 9, 2024 16:38
@timocov timocov added this to the 9.4 milestone Mar 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigation: Use of Context.Tag from effect causes 4x slowdown
1 participant