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

[Feature Request] Print project directory when diagnostics enabled #32496

Open
5 tasks done
AnyhowStep opened this issue Jul 20, 2019 · 3 comments
Open
5 tasks done

[Feature Request] Print project directory when diagnostics enabled #32496

AnyhowStep opened this issue Jul 20, 2019 · 3 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript

Comments

@AnyhowStep
Copy link
Contributor

AnyhowStep commented Jul 20, 2019

Search Terms

diagnostics, project directory

Suggestion

I have about 40+ sub-projects in a composite project right now and when building, it takes about 10 minutes.

It's hard to troubleshoot which projects are the bottleneck when I don't even know which projects are being built.

Enabling diagnostics only tells me how long a project took but doesn't tell me what that project is.

So, my feature request is to print the project directory when diagnostics is enabled.


At the moment, I've modified my own tsc.js,

//Find this line
reportTimeStatistic("Total time", programTime + bindTime + checkTime + emitTime);
//Replace with this snippet
reportTimeStatistic("Total time", programTime + bindTime + checkTime + emitTime);
if (program.getRootFileNames().length > 0) {
    const path = program.getRootFileNames()[0].replace(/\/[^/]+?\.[^.]+?$/, "");
    reportStatisticalValue("Project", (
        path.indexOf(program.getCurrentDirectory()) == 0 ?
            path.substr(program.getCurrentDirectory().length) :
            path
    ));
}

It works enough for me,

Files:                                      2944
Lines:                                    279749
Nodes:                                   1473021
Identifiers:                              417022
Symbols:                                  295304
Types:                                        73
Memory used:                             748010K
Assignability cache size:                      0
Identity cache size:                           0
Subtype cache size:                            0
I/O Read time:                             0.02s
Parse time:                                0.21s
Program time:                              0.84s
Bind time:                                 0.18s
printTime time:                            0.01s
Emit time:                                 0.01s
I/O Write time:                            0.01s
Total time:                                1.03s
Project:                  /src/app-route-handler

I don't really know much about the TypeScript API. There's probably a proper way to get this information but with my limited knowledge, I managed to hack that together.

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.
@AnyhowStep
Copy link
Contributor Author

AnyhowStep commented Jul 21, 2019

Thanks to that hack, I found out what gave me grief when it came to build times.

I had a generic function in a project that was used directly by about 15 sub projects (and indirectly by other sub projects). I forgot to add an explicit return type annotation to the generic function.

This project would take 3 seconds to build but the sub projects would take about 20-30s each.

The emitted .d.ts file for the generic function took up only 200+ lines but each line was thousands of characters long!

After adding the explicit return type annotation, the generic function became dozens of characters long and the ~15 sub projects now take 7-10s each.

Total time saved was ~5 minutes on cold builds. So, I cut the build time in half by adding one line of code.

Screenshots of the .d.ts, before and after, here,
typescript-eslint/typescript-eslint#730

@RyanCavanaugh RyanCavanaugh added Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript labels Jul 31, 2019
@AnyhowStep
Copy link
Contributor Author

AnyhowStep commented Sep 3, 2019

https://youtu.be/wpgKd-rwnMw?t=3748

Seems like the experimental version was outputting the name of projects it was building,
image

Building compiler ...
Building services ...

That would actually be super helpful if I can have that, too, without hacking tsc.js

@elibarzilay
Copy link
Contributor

👍 --- I ran into this too, with

tsc -b -f --diagnostics compiler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants