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

chore: add some memory debugging #24970

Merged
merged 4 commits into from
Apr 6, 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
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ done
export PATH=$(npm bin):$PATH
export NODE_OPTIONS="--max-old-space-size=8196 --experimental-worker ${NODE_OPTIONS:-}"

# Temporary log memory for long builds (this may mess with tests that check stderr)
# export NODE_OPTIONS="-r $PWD/scripts/log-memory.js ${NODE_OPTIONS:-}"

if ! [ -x "$(command -v yarn)" ]; then
echo "yarn is not installed. Install it from here- https://yarnpkg.com/en/docs/install."
exit 1
Expand Down
4 changes: 4 additions & 0 deletions buildspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ phases:
# Packing aws-cdk-lib can cause memory errors. Increasing this value
# allows our build to more consistently succeed
- /sbin/sysctl -w vm.max_map_count=2251954

pre_build:
commands:
# Print our ulimits to find out if we might run into a resource limit
- ulimit -a
- /bin/bash ./scripts/cache-load.sh
build:
commands:
- codebuild-breakpoint
- 'if ${BUMP_CANDIDATE:-false}; then /bin/bash ./scripts/bump-candidate.sh; fi'
- /bin/bash ./scripts/align-version.sh
- /bin/bash ./build.sh
Expand Down
15 changes: 15 additions & 0 deletions scripts/log-memory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Script to get Node.js to print its memory usage periodically
//
// Use as follows:
//
// export NODE_OPTIONS="-r $PWD/scripts/log-memory.js ${NODE_OPTIONS:-}"
const { memoryUsage } = require('process');

const MB = 1024 * 1024;

setInterval(() => {
const now = new Date();
const HH = `0${now.getHours()}`.slice(-2);
const MM = `0${now.getMinutes()}`.slice(-2);
console.error(`[${HH}:${MM}] [node:${process.pid}] rss=${(memoryUsage.rss() / MB).toFixed(1)}`);
}, 60000).unref();