Force parser cache flushing and GC to avoid exiting worker process early
commit8c8c8e78d43e6b9172d6d24b257a54bcb3490959
authorAndrew Kennedy <akenn@fb.com>
Fri, 11 Dec 2020 15:05:43 +0000 (11 07:05 -0800)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Fri, 11 Dec 2020 15:07:49 +0000 (11 07:07 -0800)
treefd2f5f6ce87a7cd4df6ebef17980302f7cd50f53
parent1bebccd66042491c918004f000d961c3f886f6c3
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
hphp/hack/src/typing/typing_check_service.ml