-
Notifications
You must be signed in to change notification settings - Fork 130
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
Very slow incremental compilation (2.6x slower) compared to tsc #549
Comments
I'm afraid I cannot do anything without seeing the project. I do see that you have a complicated configuration with rootDir, rootDirs, paths, include and exclude, that might have some influence on the performance. Could you maybe check whether the performance problems are caused by |
Sure! How would I do that? |
You could create a task which only invokes gulp.task('foo', () =>
tsProject.src()
); |
@esprehn Have you tried to measure the performance of |
I have a simpler example. I haven't really seen a difference between the first time Runtimes
|
@ivogabe Sorry I didn't get a chance to look at this. We switched all our projects to calling tsc directly instead since it was so much faster. I'll see if I can try using gulp-typescript again later this week, const { execSync, spawn } = require('child_process');
gulp.task('compileSources', () => new Promise((resolve, reject) => {
const tsc = spawn('tsc', [], { stdio: 'inherit' });
tsc.on('exit', (code) => {
if (!code) {
resolve();
} else {
reject();
}
});
}));
gulp.task('watchSources', () => {
spawn('tsc', ['-w'], { stdio: 'inherit' });
}); |
@GregRos could you measure the running time of gulp.task('build', function() {
return appProject.src();
}); @esprehn I understand that. Could you add a simple task to measure the performance of const tsProject = ts.createProject('tsconfig.json');
gulp.task('foo', () =>
tsProject.src()
); |
That completes in 100ms for me. Testing it looks like tsc 2.7.2 takes the same amount of time (if not longer) on the first compile, and then is nearly instant for later compiles. It's a lot more than 2.6x now, close to 100x faster (0.07 seconds vs 6.6 seconds). gulp-typescript seems to always take 6-8 seconds. Looking at the diagnostics difference I think tsc is not reloading all the types for each incremental compile (57770 for first compile, 238 for second, see below) while gulp-typescript is. gulpfile.js const gulp = require('gulp');
const { spawn } = require('child_process');
const ts = require('gulp-typescript');
const tsProject = ts.createProject('./tsconfig.json');
gulp.task('compileWithGulpTypeScript', () => {
const t1 = Date.now();
const src = tsProject.src();
console.log('.src()', Date.now() - t1);
const t2 = Date.now();
const transformer = tsProject();
console.log('transformer', Date.now() - t2);
return src
.pipe(transformer)
.pipe(gulp.dest('artifacts'));
});
gulp.task('compileWithGulpTypeScript-watch', () => {
gulp.watch(['src/**/*.ts'], ['compileWithGulpTypeScript'])
});
gulp.task('watchSources', () => {
// tsc --watch clears the shell, so we use a gross hack around it.
// https://github.com/Microsoft/TypeScript/issues/21295#issuecomment-367571059
spawn(`tsc -w | awk '{ gsub(/\\033c/, "") system("")}1'`, {
stdio: 'inherit',
shell: true,
});
}); Output from gulp-typescript
Output from tsc
tsc with --diagnostics turned on
|
@ivogabe By the following part of my message:
I meant that the |
Hello - we're seeing this as well. The incremental builds are an order of magnitude slower than what tsc gives. Any news regarding this? |
@marcghorayeb I've pretty much lost interest in this project personally and switched to invoking |
@GregRos That's what I'd like to avoid ;) On a side note, how do you handle launching both at the same time? |
@marcghorayeb I don't. I keep tsc running and rerun gulp whenever I want to publish/start the application. |
I haven't been able to replicate this yet. Could you try this with the latest alpha release? You can install it with |
@ivogabe I tried the alpha.1, unfortunately the results are the same (even worse in most cases). |
Maybe it's possible to use new typescript watch api with gulp? |
I've stopped debugging/using this plugin... Lack of time to debug it unfortunately. |
Any progress on this issue? It is quite slow for me as well. I'm using: "gulp-typescript": "^5.0.0-alpha.3" |
Is it safe to assume that this project is abandoned? |
I personally don't have enough interest in this issue to invest my time in it, currently. We probably need to adapt a newer API from TypeScript. If someone wants to work on this, I'd suggest to dive into the TypeScript api and we could chat if you run into problems. |
I'm interested in this issue, but a prerequisite is understanding what is causing performance issues. If someone following this issue has the knowledge needed to answer the question, I appreciate your help! |
I've posted an answer on your StackOverflow question, let me know if anything is unclear. |
Thanks @ivogabe , this is very helpful. Do you think it would help if the TS Compiler API enabled us to do async io instead of relying on fs.readFileSync for files not available in the vinyl stream? |
I think that the compilation is compute-bound, not IO-bound. Most of the time is spent on the real type checking and the emit, the cost for IO is probably only a small part. Async IO would then not give a (major) improvement in compile times, but it would increase the complexity of the compiler. But that's just my guess, maybe you can somehow profile how much time is spent doing IO stuff. You could maybe benchmark the compiler on a SSD and a HDD and take a look at the difference in compile time. |
@ivogabe I'd watch microsoft/TypeScript#29978, and avoid spinning off a full language service if you don't need to. That can provide incremental subsequent compilations for both |
TS Compiler API now supports --incremental 🎉 🎉 ! |
Any progress being made? If not, is there any easy replacements for gulp-typescript? |
1 similar comment
Any progress being made? If not, is there any easy replacements for gulp-typescript? |
Thanks to the team for creating gulp-typescript. Would love to see the incremental compile feature fixed! I wish our friends at Microsoft would help pony up a bounty since this is their recommended method for using TypeScript with Gulp https://www.typescriptlang.org/docs/handbook/gulp.html Thanks again |
With "gulp-typescript": "3.2.3",
Expected behavior:
Should be as fast as tsc -w
Actual behavior:
Very slow, gulp does:
Your gulpfile:
tsconfig.json
Include your tsconfig, if related to this issue.
The text was updated successfully, but these errors were encountered: