forked from google/pprof-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 5
Associate label sets with wall profiles #105
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
Merged
Merged
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 0375873
typo
nsavoire bd31776
Initial code for code hotspots in wall profiler
szegedi f02e781
Maintain profilers per isolate, in a copy-on-write style map
szegedi f508a2d
Make labelSetsByNode per-profiler
szegedi 221eecb
add labelsCaptured property that can be used to detect profiling samp…
szegedi 71f4c4f
Linting
szegedi e28aaa2
Disable signal code on Windows
szegedi 0a10aa9
Don't use LabelWrap
szegedi d25e466
Leave comments for performance improvements
szegedi c09ccce
Encapsulate profile translation, this fixes scoping of labelSetsByNod…
szegedi 2b9988b
Optimize creation of reused strings etc.
szegedi 8658adf
No need for unsetLabels
szegedi 08be6f8
Improve RingBuffer and SampleContext move semantics
szegedi 2b642a7
Restore backwards compatibility of the start method
szegedi b1a517e
Hide new functionality behind a flag
szegedi db1aa39
Add a test + fixes for the test
szegedi cdf42b1
Suggestions from Nicolas' review, minus the atomic update of profiler…
szegedi a30739b
Safe atomics for profiler map
szegedi 89dc34d
unsigneds are evil
szegedi 7898fe8
Avoid the need for clock sync by ensuring we use the same clock as V8…
szegedi 2fb0442
Use time intervals for matching sample contexts
szegedi e7ce771
Remove CPU profiler tests. CpuProfiler causes crashes in tests, WONTFIX.
szegedi a0e18d5
Remove labelsCaptured logic
szegedi cda5e4f
Ensure atomic updates to labels for signal safety
szegedi 85de533
Don't use RingBuffer.push_front
szegedi 516a9d6
Make code signal safe, fix some minor issues
nsavoire File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.