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

8277397: ZGC: Add JFR event for temporary latency measurements #6454

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -131,3 +131,16 @@ void ZTracer::send_thread_phase(const char* name, const Ticks& start, const Tick
e.commit();
}
}

void ZTracer::send_thread_event(const char* name, const Ticks& start, const Ticks& end) {
NoSafepointVerifier nsv;

EventZThreadEvent e(UNTIMED);
if (e.should_commit()) {
e.set_gcId(GCId::current_or_undefined());
e.set_name(name);
e.set_starttime(start);
e.set_endtime(end);
e.commit();
}
}
@@ -39,6 +39,7 @@ class ZTracer : public GCTracer {
void send_stat_counter(const ZStatCounter& counter, uint64_t increment, uint64_t value);
void send_stat_sampler(const ZStatSampler& sampler, uint64_t value);
void send_thread_phase(const char* name, const Ticks& start, const Ticks& end);
void send_thread_event(const char* name, const Ticks& start, const Ticks& end);

public:
static ZTracer* tracer();
@@ -47,6 +48,7 @@ class ZTracer : public GCTracer {
void report_stat_counter(const ZStatCounter& counter, uint64_t increment, uint64_t value);
void report_stat_sampler(const ZStatSampler& sampler, uint64_t value);
void report_thread_phase(const char* name, const Ticks& start, const Ticks& end);
void report_thread_event(const char* name, const Ticks& start, const Ticks& end);
};

class ZTraceThreadPhase : public StackObj {
@@ -59,4 +61,15 @@ class ZTraceThreadPhase : public StackObj {
~ZTraceThreadPhase();
};

// For temporary latency measurements during development and debugging
class ZTraceThreadEvent : public StackObj {
private:
const Ticks _start;
const char* const _name;

public:
ZTraceThreadEvent(const char* name);
~ZTraceThreadEvent();
};

#endif // SHARE_GC_Z_ZTRACER_HPP
@@ -50,6 +50,12 @@ inline void ZTracer::report_thread_phase(const char* name, const Ticks& start, c
}
}

inline void ZTracer::report_thread_event(const char* name, const Ticks& start, const Ticks& end) {
if (EventZThreadEvent::is_enabled()) {
send_thread_event(name, start, end);
}
}

inline ZTraceThreadPhase::ZTraceThreadPhase(const char* name) :
_start(Ticks::now()),
_name(name) {}
@@ -58,4 +64,12 @@ inline ZTraceThreadPhase::~ZTraceThreadPhase() {
ZTracer::tracer()->report_thread_phase(_name, _start, Ticks::now());
}

inline ZTraceThreadEvent::ZTraceThreadEvent(const char* name) :
_start(Ticks::now()),
_name(name) {}

inline ZTraceThreadEvent::~ZTraceThreadEvent() {
ZTracer::tracer()->report_thread_event(_name, _start, Ticks::now());
}

#endif // SHARE_GC_Z_ZTRACER_INLINE_HPP
@@ -1034,6 +1034,11 @@
<Field type="string" name="name" label="Name" />
</Event>

<Event name="ZThreadEvent" category="Java Virtual Machine, GC, Detailed" label="ZGC Thread Event" thread="true" experimental="true">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a description to the event?
For anyone coming from outside it would really help to understand what this event is supposed to represent.

Copy link
Member Author

@stefank stefank Nov 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea.

<Field type="uint" name="gcId" label="GC Identifier" relation="GcId"/>
<Field type="string" name="name" label="Name" />
</Event>

<Event name="ZUncommit" category="Java Virtual Machine, GC, Detailed" label="ZGC Uncommit" description="Uncommitting of memory" thread="true">
<Field type="ulong" contentType="bytes" name="uncommitted" label="Uncommitted" />
</Event>
@@ -775,6 +775,11 @@
<setting name="threshold">0 ms</setting>
</event>

<event name="jdk.ZThreadEvent">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a question - do we want/need to have this event enabled for the 'low overhead profiling' setup?

Copy link
Member Author

@stefank stefank Nov 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I always use default.jfc. The profile.jfc is creating too many allocation related events to make it usable when running with ZGC. I know that there has been some plans to fix that, but I don't know if that made it into JDK 17 or not.

<setting name="enabled">true</setting>
<setting name="threshold">0 ms</setting>
</event>

<event name="jdk.ZUncommit">
<setting name="enabled">true</setting>
<setting name="threshold">0 ms</setting>
@@ -775,6 +775,11 @@
<setting name="threshold">0 ms</setting>
</event>

<event name="jdk.ZThreadEvent">
<setting name="enabled">true</setting>
<setting name="threshold">0 ms</setting>
</event>

<event name="jdk.ZUncommit">
<setting name="enabled">true</setting>
<setting name="threshold">0 ms</setting>