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

refactor(util): use newer java memory args #34

Merged
merged 3 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions __tests__/__snapshots__/otp-runner.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ exports[`otp-runner mocked runner tests successes should use otp 2.x to build a
exports[`otp-runner unit tests should generate 1.x build cli arguments 1`] = `
Array [
"-jar",
"-Xmx7902848k",
"-XX:MaxRAMPercentage=80",
"./temp-test-files/ok.jar",
"--build",
"temp-test-files/default",
Expand All @@ -268,7 +268,7 @@ Array [
exports[`otp-runner unit tests should generate 1.x serve cli arguments 1`] = `
Array [
"-jar",
"-Xmx7902848k",
"-XX:MaxRAMPercentage=80",
"./temp-test-files/ok.jar",
"--server",
"--graphs",
Expand All @@ -281,7 +281,7 @@ Array [
exports[`otp-runner unit tests should generate 2.x build cli arguments 1`] = `
Array [
"-jar",
"-Xmx7902848k",
"-XX:MaxRAMPercentage=80",
"./temp-test-files/ok.jar",
"--build",
"--save",
Expand All @@ -292,7 +292,7 @@ Array [
exports[`otp-runner unit tests should generate 2.x serve cli arguments 1`] = `
Array [
"-jar",
"-Xmx7902848k",
"-XX:MaxRAMPercentage=80",
"./temp-test-files/ok.jar",
"--load",
"./temp-test-files/",
Expand Down
4 changes: 2 additions & 2 deletions __tests__/test-utils/mocks/cli-processes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const fs = require('fs-extra')

const { TEMP_TEST_FOLDER } = require('../constants')

Check warning on line 5 in __tests__/test-utils/mocks/cli-processes.js

View workflow job for this annotation

GitHub Actions / test-build-release

There should be at least one empty line between import groups
const { addCustomExecaMock, addCustomSpawnMock } = require('./modules')

/**
Expand Down Expand Up @@ -85,7 +85,7 @@
function mockOTPGraphBuild (shouldPass = false, otpV2 = false) {
const javaArgs = [
'-jar',
'-Xmx7902848k'
'-XX:MaxRAMPercentage=80'
]
const baseFolder = otpV2
? `${TEMP_TEST_FOLDER}/otp2-base-folder`
Expand Down Expand Up @@ -157,7 +157,7 @@
}) {
const javaArgs = [
'-jar',
'-Xmx7902848k'
'-XX:MaxRAMPercentage=80'
]
if (otpV2) {
javaArgs.push(`./${TEMP_TEST_FOLDER}/ok-otp-2.jar`)
Expand Down
9 changes: 1 addition & 8 deletions lib/util.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const os = require('os')
const stream = require('stream')
const {promisify} = require('util')

Expand Down Expand Up @@ -31,13 +30,7 @@ module.exports.downloadFileIfNeeded = async function ({ dest, uri }) {
* the given jar file.
*/
module.exports.getBaseOTPArgs = function (jarFile) {
// Use potentially all available memory minus 2GB for the OS, but use a
// minimum of 1.5GB to run OTP.
const memoryToUse = Math.max(
Math.round(os.totalmem() / 1000 - 2097152),
1500000
)
return ['-jar', `-Xmx${memoryToUse}k`, jarFile]
return ['-jar', '-XX:MaxRAMPercentage=80', jarFile]
}

module.exports.waitOneSecond = async function () {
Expand Down
Loading