Force parser cache flushing and GC to avoid exiting worker process early
Summary:
Typechecker workers process a bucket of files (max 1000, or 500, depending on settings) at a time, in sequence. After processing each file, the worker checks OCaml's heap size, and if it exceeds a cap (e.g. set at 500Mb), the worker exits early. If the cap is not exceeded then all files in the bucket are processed and then the worker exits. In either case, the process is restarted.
Exiting the process is an extreme solution. In this diff, we instead try to continue, by flushing the parser cache, forcing a major GC, and then checking the heap size against the cap again. If it still exceeds the cap, we exit, but otherwise we continue to process files, which has the benefit that items in decl caches are retained.
Reviewed By: ljw1004
Differential Revision:
D25302218
fbshipit-source-id:
038b79d3abd81ed6aeaaacd8580c39a17d2e5870