Skip to content

Commit

Permalink
Remove support for node 14 (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
nsavoire authored May 17, 2024
1 parent bebf35b commit e7d3e05
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 61 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
asan:
strategy:
matrix:
version: [14, 16, 18, 20, 22]
version: [16, 18, 20, 22]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -23,7 +23,7 @@ jobs:
valgrind:
strategy:
matrix:
version: [14, 16, 18, 20, 22]
version: [16, 18, 20, 22]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -40,7 +40,7 @@ jobs:
target-name: 'dd_pprof' # target name in binding.gyp
package-manager: 'npm' # npm or yarn
cache: true # enable caching of dependencies based on lockfile
min-node-version: 14
min-node-version: 16
skip: 'linux-arm linux-ia32' # skip building for these platforms

dev_publish:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
target-name: 'dd_pprof' # target name in binding.gyp
package-manager: 'npm' # npm or yarn
cache: true # enable caching of dependencies based on lockfile
min-node-version: 14
min-node-version: 16
skip: 'linux-arm linux-ia32' # skip building for these platforms

publish:
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
[pprof][pprof-url] support for Node.js.

## Prerequisites
1. Your application will need to be using Node.js 14 or greater.
1. Your application will need to be using Node.js 16 or greater.

2. The `pprof` module has a native component that is used to collect profiles
2. The `pprof` module has a native component that is used to collect profiles
with v8's CPU and Heap profilers. You may need to install additional
dependencies to build this module.
* For Linux: `pprof` has prebuilt binaries available for Linux arm64/x64,
Alpine Linux x64, macOS arm64/x64, windows x64 for Node 14/16/18/20.
Alpine Linux x64, macOS arm64/x64, windows x64 for Node 16/18/20/22.
No additional dependencies are required.
* For other environments: on environments that `pprof` does not have
prebuilt binaries for, the module
Expand Down Expand Up @@ -42,7 +42,7 @@ Install [`pprof`][npm-url] with `npm` or add to your `package.json`.
1. Update code to collect and save a profile:
```javascript
const profile = await pprof.time.profile({
durationMillis: 10000, // time in milliseconds for which to
durationMillis: 10000, // time in milliseconds for which to
// collect profile.
});
const buf = await pprof.encode(profile);
Expand All @@ -63,8 +63,8 @@ Install [`pprof`][npm-url] with `npm` or add to your `package.json`.
node --require @datadog/pprof app.js
```
2. A wall time profile for the job will be saved in
`pprof-profile-${process.pid}.pb.gz`. View the profile with command line
2. A wall time profile for the job will be saved in
`pprof-profile-${process.pid}.pb.gz`. View the profile with command line
[`pprof`][pprof-url]:
```sh
pprof -http=: pprof-profile-${process.pid}.pb.gz
Expand All @@ -79,10 +79,10 @@ Install [`pprof`][npm-url] with `npm` or add to your `package.json`.
// The maximum stack depth for samples collected.
const stackDepth = 64;
heap.start(intervalBytes, stackDepth);
heap.start(intervalBytes, stackDepth);
```
2. Collect heap profiles:
* Collecting and saving a profile in profile.proto format:
```javascript
const profile = await pprof.heap.profile();
Expand All @@ -96,11 +96,11 @@ Install [`pprof`][npm-url] with `npm` or add to your `package.json`.
```sh
pprof -http=: heap.pb.gz
```
* Collecting a heap profile with V8 allocation profile format:
```javascript
const profile = await pprof.heap.v8Profile();
```
```
[build-image]: https://github.com/Datadog/pprof-nodejs/actions/workflows/build.yml/badge.svg?branch=main
[build-url]: https://github.com/Datadog/pprof-nodejs/actions/workflows/build.yml
Expand Down
41 changes: 0 additions & 41 deletions bindings/profilers/wall.cc
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@ WallProfiler::WallProfiler(std::chrono::microseconds samplingPeriod,
// When starting a new profile, wait for one signal before and one signal
// after to reduce the likelihood that race condition occurs and one code
// event just after triggers the issue.
detectV8Bug_ = NODE_MODULE_VERSION >= NODE_16_0_MODULE_VERSION;
workaroundV8Bug_ = workaroundV8Bug && DD_WALL_USE_SIGPROF && detectV8Bug_;
collectCpuTime_ = collectCpuTime && withContexts;

Expand Down Expand Up @@ -751,11 +750,7 @@ NAN_METHOD(WallProfiler::Stop) {
Nan::ObjectWrap::Unwrap<WallProfiler>(info.Holder());

v8::Local<v8::Value> profile;
#if NODE_MODULE_VERSION < NODE_16_0_MODULE_VERSION
auto err = wallProfiler->StopImplOld(restart, profile);
#else
auto err = wallProfiler->StopImpl(restart, profile);
#endif

if (!err.success) {
return Nan::ThrowTypeError(err.msg.c_str());
Expand Down Expand Up @@ -895,39 +890,6 @@ Result WallProfiler::StopImpl(bool restart, v8::Local<v8::Value>& profile) {
return {};
}

Result WallProfiler::StopImplOld(bool restart, v8::Local<v8::Value>& profile) {
if (!started_) {
return Result{"Stop called on not started profiler."};
}

if (withContexts_ || workaroundV8Bug_) {
SignalHandler::DecreaseUseCount();
}
auto v8_profile = cpuProfiler_->StopProfiling(
Nan::New<String>(profileId_).ToLocalChecked());

if (withContexts_) {
auto contextsByNode =
GetContextsByNode(v8_profile, contexts_, startThreadCpuTime_);
profile = TranslateTimeProfile(
v8_profile, includeLines_, &contextsByNode, collectCpuTime_);
} else {
profile = TranslateTimeProfile(v8_profile, includeLines_);
}
contexts_.clear();
v8_profile->Delete();
Dispose(v8::Isolate::GetCurrent());

if (restart) {
CreateV8CpuProfiler();
profileId_ = StartInternal();
} else {
started_ = false;
}

return {};
}

NAN_MODULE_INIT(WallProfiler::Init) {
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
Local<String> className = Nan::New("TimeProfiler").ToLocalChecked();
Expand Down Expand Up @@ -972,9 +934,6 @@ NAN_MODULE_INIT(WallProfiler::Init) {
.FromJust();
}

// A new CPU profiler object will be created each time profiling is started
// to work around https://bugs.chromium.org/p/v8/issues/detail?id=11051.
// TODO: Fixed in v16. Delete this hack when deprecating v14.
v8::CpuProfiler* WallProfiler::CreateV8CpuProfiler() {
if (cpuProfiler_ == nullptr) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
Expand Down
3 changes: 1 addition & 2 deletions bindings/profilers/wall.hh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class WallProfiler : public Nan::ObjectWrap {
bool withContexts_ = false;
bool started_ = false;
bool workaroundV8Bug_;
bool detectV8Bug_;
static inline constexpr bool detectV8Bug_ = true;
bool collectCpuTime_;
bool isMainThread_;
int v8ProfilerStuckEventLoopDetected_ = 0;
Expand Down Expand Up @@ -122,7 +122,6 @@ class WallProfiler : public Nan::ObjectWrap {
Result StartImpl();
std::string StartInternal();
Result StopImpl(bool restart, v8::Local<v8::Value>& profile);
Result StopImplOld(bool restart, v8::Local<v8::Value>& profile);

CollectionMode collectionMode() {
auto res = collectionMode_.load(std::memory_order_relaxed);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
"devDependencies": {
"@types/mocha": "^10.0.1",
"@types/node": ">=14",
"@types/node": ">=16",
"@types/sinon": "^10.0.15",
"@types/tmp": "^0.2.3",
"@typescript-eslint/eslint-plugin": "^5.60.1",
Expand Down Expand Up @@ -82,6 +82,6 @@
]
},
"engines": {
"node": ">=14"
"node": ">=16"
}
}

0 comments on commit e7d3e05

Please sign in to comment.