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

src: save the performance milestone time origin in the AliasedArray #48708

Merged
merged 2 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
fixup! src: save the performance milestone time origin in the Aliased…
…Array
  • Loading branch information
joyeecheung committed Jul 12, 2023
commit 87402045a4a5fb53a5a3aafba780499ada7d4ead
18 changes: 13 additions & 5 deletions src/node_perf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,27 @@ PerformanceState::PerformanceState(Isolate* isolate,
root,
MAYBE_FIELD_PTR(info, observers)) {
if (info == nullptr) {
// For deserialized performance states, we'll re-initialize in
// the deserialize callback.
// For performance states initialized from scratch, reset
// all the milestones and initialize the time origin.
// For deserialized performance states, we will do the
// initialization in the deserialize callback.
ResetMilestones();
Initialize(time_origin);
}
}

PerformanceState::SerializeInfo PerformanceState::Serialize(
v8::Local<v8::Context> context, v8::SnapshotCreator* creator) {
// Reset all the milestones. We'll re-initialize them after deserialization.
void PerformanceState::ResetMilestones() {
size_t milestones_length = milestones.Length();
for (size_t i = 0; i < milestones_length; ++i) {
milestones[i] = -1;
}
}

PerformanceState::SerializeInfo PerformanceState::Serialize(
v8::Local<v8::Context> context, v8::SnapshotCreator* creator) {
// Reset all the milestones to improve determinism in the snapshot.
// We'll re-initialize them after deserialization.
ResetMilestones();

SerializeInfo info{root.Serialize(context, creator),
milestones.Serialize(context, creator),
Expand Down
1 change: 1 addition & 0 deletions src/node_perf_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class PerformanceState {

private:
void Initialize(uint64_t time_origin);
void ResetMilestones();
struct performance_state_internal {
// doubles first so that they are always sizeof(double)-aligned
double milestones[NODE_PERFORMANCE_MILESTONE_INVALID];
Expand Down