Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8ea92ad
Use timestamps to implement code hotspots
nsavoire Apr 14, 2023
0375873
typo
nsavoire Apr 14, 2023
bd31776
Initial code for code hotspots in wall profiler
szegedi Apr 19, 2023
f02e781
Maintain profilers per isolate, in a copy-on-write style map
szegedi May 8, 2023
f508a2d
Make labelSetsByNode per-profiler
szegedi May 11, 2023
221eecb
add labelsCaptured property that can be used to detect profiling samp…
szegedi May 15, 2023
71f4c4f
Linting
szegedi May 15, 2023
e28aaa2
Disable signal code on Windows
szegedi May 16, 2023
0a10aa9
Don't use LabelWrap
szegedi May 19, 2023
d25e466
Leave comments for performance improvements
szegedi May 19, 2023
c09ccce
Encapsulate profile translation, this fixes scoping of labelSetsByNod…
szegedi May 19, 2023
2b9988b
Optimize creation of reused strings etc.
szegedi May 22, 2023
8658adf
No need for unsetLabels
szegedi May 22, 2023
08be6f8
Improve RingBuffer and SampleContext move semantics
szegedi May 26, 2023
2b642a7
Restore backwards compatibility of the start method
szegedi May 30, 2023
b1a517e
Hide new functionality behind a flag
szegedi May 30, 2023
db1aa39
Add a test + fixes for the test
szegedi May 31, 2023
cdf42b1
Suggestions from Nicolas' review, minus the atomic update of profiler…
szegedi Jun 2, 2023
a30739b
Safe atomics for profiler map
szegedi Jun 5, 2023
89dc34d
unsigneds are evil
szegedi Jun 5, 2023
7898fe8
Avoid the need for clock sync by ensuring we use the same clock as V8…
szegedi Jun 6, 2023
2fb0442
Use time intervals for matching sample contexts
szegedi Jun 9, 2023
e7ce771
Remove CPU profiler tests. CpuProfiler causes crashes in tests, WONTFIX.
szegedi Jun 9, 2023
a0e18d5
Remove labelsCaptured logic
szegedi Jun 9, 2023
cda5e4f
Ensure atomic updates to labels for signal safety
szegedi Jun 9, 2023
85de533
Don't use RingBuffer.push_front
szegedi Jun 9, 2023
516a9d6
Make code signal safe, fix some minor issues
nsavoire Jun 13, 2023
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
4 changes: 4 additions & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
"bindings/location.cc",
"bindings/per-isolate-data.cc",
"bindings/sample.cc",
"bindings/translate-time-profile.cc",
"bindings/binding.cc"
],
"include_dirs": [
"bindings",
"<!(node -e \"require('nan')\")"
]
}
Expand All @@ -47,6 +49,7 @@
"bindings/location.cc",
"bindings/per-isolate-data.cc",
"bindings/sample.cc",
"bindings/translate-time-profile.cc",
"bindings/test/binding.cc",
"bindings/test/profilers/cpu.test.cc",
"bindings/test/code-event-record.test.cc",
Expand All @@ -56,6 +59,7 @@
"bindings/test/sample.test.cc"
],
"include_dirs": [
"bindings",
"<!(node -e \"require('nan')\")"
]
}
Expand Down
16 changes: 16 additions & 0 deletions bindings/binding.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 Datadog, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <nan.h>
#include <node.h>
#include <v8.h>
Expand Down
86 changes: 86 additions & 0 deletions bindings/buffer.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Copyright 2023 Datadog, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

namespace dd {
template <class T>
class RingBuffer {
public:
explicit RingBuffer(size_t capacity)
: buffer(std::make_unique<T[]>(capacity)),
capacity_(capacity),
size_(0),
back_index_(0),
front_index_(0) {}

size_t capacity() const { return capacity_; }
bool full() const { return size_ == capacity_; }
bool empty() const { return size_ == 0; }
size_t size() const { return size_; }

T& front() { return buffer[front_index_]; }
const T& front() const { return buffer[front_index_]; }

void push_back(const T& t) { push_back_(t); }
void push_back(T&& t) { push_back_(std::move(t)); }

void clear() {
while (!empty()) {
pop_front();
}
}

T pop_front() {
auto idx = front_index_;
increment(front_index_);
--size_;
return std::move(buffer[idx]);
}

private:
template <typename U>
void push_back_(U&& t) {
const bool is_full = full();

if (is_full && empty()) {
return;
}
buffer[back_index_] = std::forward<U>(t);
increment(back_index_);

if (is_full) {
// move buffer head
front_index_ = back_index_;
} else {
++size_;
}
}

void increment(size_t& idx) const {
idx = idx + 1 == capacity_ ? 0 : idx + 1;
}
void decrement(size_t& idx) const {
idx = idx == 0 ? capacity_ - 1 : idx - 1;
}

std::unique_ptr<T[]> buffer;
size_t capacity_;
size_t size_;
size_t back_index_;
size_t front_index_;
};
} // namespace dd
16 changes: 16 additions & 0 deletions bindings/code-event-record.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 Datadog, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <node.h>

#include "code-event-record.hh"
Expand Down
16 changes: 16 additions & 0 deletions bindings/code-event-record.hh
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 Datadog, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <string>
Expand Down
16 changes: 16 additions & 0 deletions bindings/code-map.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 Datadog, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <unordered_map>

#include <node.h>
Expand Down
16 changes: 16 additions & 0 deletions bindings/code-map.hh
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 Datadog, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <cstdint>
Expand Down
16 changes: 16 additions & 0 deletions bindings/cpu-time.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 Datadog, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "cpu-time.hh"

#ifdef __linux__
Expand Down
16 changes: 16 additions & 0 deletions bindings/cpu-time.hh
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 Datadog, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <cstdint>
Expand Down
31 changes: 31 additions & 0 deletions bindings/labelsets.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2023 Datadog, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <nan.h>
#include <v8-profiler.h>
#include <unordered_map>

namespace dd {

struct NodeInfo {
v8::Local<v8::Array> labelSets;
uint32_t hitcount;
};

using LabelSetsByNode = std::unordered_map<const v8::CpuProfileNode*, NodeInfo>;
} // namespace dd
16 changes: 16 additions & 0 deletions bindings/location.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 Datadog, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <utility>

#include <node.h>
Expand Down
16 changes: 16 additions & 0 deletions bindings/location.hh
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 Datadog, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <nan.h>
Expand Down
16 changes: 16 additions & 0 deletions bindings/per-isolate-data.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 Datadog, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <mutex>
#include <unordered_map>
#include <utility>
Expand Down
16 changes: 16 additions & 0 deletions bindings/per-isolate-data.hh
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 Datadog, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <nan.h>
Expand Down
Loading