Angular Compiler is REALLY slow

On my machine, outside of Docker, running ngc -p .[0] to compile my project takes 17 seconds. Within Docker, it takes a bit over an hour.

For comparison, the standard TypeScript compiler (tsc -p .) runs in 4 seconds outside of Docker and in 10 seconds within Docker.

I can’t imagine what ngc might be doing to upset Docker so much, but something is definitely wrong here.


0: https://github.com/angular/angular/tree/master/modules/@angular/compiler-cli

In Docker, are you running out of a mounted volume? If so, this issue likely falls under this problem: File access in mounted volumes extremely slow, CPU bound

That was my first thought as well, but just tested to make sure and it looks like this is reproducible either way. (I also can’t imagine that ngc would be super heavy on filesystem operations, at least not significantly more so than tsc.)

@cyph, that is very surprising. Could you please open an issue on https://github.com/docker/for-mac/issues with details of the container build/run you are performing, an example project/template set, and the exact command inside and outside of the container?

Well, I’d just set up a test case that I was about to submit there, but now I can’t reproduce the issue outside of mounted volumes. Not 100% why it was the case before, but I think I might’ve accidentally had a symlink to a mounted volume directory inside my non-mounted copy.

In any case, it looks like this is exactly what @tomfrost suggested, not a separate issue.

@cyph a test case would still be very useful. 17s -> 1h+ is far larger than expected for the current latency model of osxfs (~10x not ~180x). It is quite likely that your ngc workload triggers an unknown performance problem. Would it be possible to share your reproduction so that we could study it to understand why it suffers extremely poor performance?

Ah got it, not a problem then. Just pushed what I had for the test project to https://github.com/buu700/docker-ngc-test, which is just using the Angular quickstart project for now since the Cyph code needed to reproduce the problem isn’t in our public branch yet. The results with this version aren’t anything close to what I was seeing with the Cyph code (52-second compile time), so I’ll let you know after it’s been updated.

Okay, got a test case: https://github.com/buu700/upgradeadapter-ngc-test

This repo is actually for an unrelated Angular issue, but it just so happens to reproduce this issue as well if you throw out the cp -a /test /test.tmp ; cd /test.tmp line from the readme. (With that line included, ngc takes 17 seconds; without it, I gave up and killed the process after 37.5 minutes.)

1 Like