codeql icon indicating copy to clipboard operation
codeql copied to clipboard

Javascript: Add environment variables to allow specifying memory sizes

Open mbg opened this issue 8 months ago • 0 comments

Summary

This PR improves the situation described in https://github.com/github/codeql/issues/16780 where halving the available CODEQL_RAM between the Typescript and JVM processes can lead to an out-of-memory condition.

Approach

This PR modifies the autobuild.(sh|cmd) scripts to add two new environment variables, CODEQL_JAVASCRIPT_TS_MEMORY and CODEQL_JAVASCRIPT_JVM_MAX_MEMORY, which can be used to specify the amounts of memory that should be available to Typescript and the JVM, respectively.

The implementation is intended to work as follows:

  • CODEQL_JAVASCRIPT_TS_MEMORY and CODEQL_JAVASCRIPT_JVM_MAX_MEMORY are used to set the values for LGTM_TYPESCRIPT_RAM and jvm_args, respectively.
  • If CODEQL_RAM is set, then we will automatically calculate the values for CODEQL_JAVASCRIPT_TS_MEMORY and CODEQL_JAVASCRIPT_JVM_MAX_MEMORY if one or both are not set.
    • If either CODEQL_JAVASCRIPT_TS_MEMORY or CODEQL_JAVASCRIPT_JVM_MAX_MEMORY is set, but the other isn't, then we calculate the missing value by subtracting the present value from CODEQL_RAM.
    • If both are missing, then we use half of the available CODEQL_RAM as before.
  • If CODEQL_RAM is not set, then we use whatever values for CODEQL_JAVASCRIPT_TS_MEMORY and CODEQL_JAVASCRIPT_JVM_MAX_MEMORY that are available, if any.

mbg avatar Jun 21 '24 11:06 mbg