Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ RUN apt-get update && apt-get -y -q install \
# shared library.
ENV PKG_CONFIG_PATH=/usr/local/ssl/lib/pkgconfig
RUN mkdir /tmp/openssl && cd /tmp/openssl && \
curl -sL https://github.com/openssl/openssl/archive/OpenSSL_1_1_1f.tar.gz | \
curl -sL https://github.com/openssl/openssl/archive/OpenSSL_1_1_1t.tar.gz | \
tar xzv --strip=1 && \
./config no-shared -fPIC --openssldir=/usr/local/ssl --prefix=/usr/local/ssl && \
make && make install_sw && \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ RUN apk --no-cache add \
ENV PKG_CONFIG_PATH=/usr/local/ssl/lib/pkgconfig
ENV JAVA_PATH=/usr/lib/jvm/java-11-openjdk/
RUN mkdir /tmp/openssl && cd /tmp/openssl && \
curl -sL https://github.com/openssl/openssl/archive/OpenSSL_1_1_1f.tar.gz | \
curl -sL https://github.com/openssl/openssl/archive/OpenSSL_1_1_1t.tar.gz | \
tar xzv --strip=1 && \
./config no-shared -fPIC --openssldir=/usr/local/ssl --prefix=/usr/local/ssl && \
make && make install_sw && \
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ CFLAGS = \
-Wno-array-bounds \
-g0 \
-DSTANDALONE_BUILD \
-D_GNU_SOURCE \
-DENABLE_HEAP_SAMPLING
-D_GNU_SOURCE

ifeq ($(machine_type),$(filter $(machine_type),aarch64 arm64))
# Building on an ARM64 machine.
Expand Down
1 change: 1 addition & 0 deletions src/proto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ void ProfileProtoBuilder::Populate(
int64_t count = trace.second;
if (count != 0) {
std::vector<uint64_t> locations;
locations.reserve(trace.first.frames.size());
for (const auto &frame : trace.first.frames) {
locations.push_back(LocationID(jni, frame));
}
Expand Down
1 change: 1 addition & 0 deletions src/threads.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ int64_t ThreadTable::Size() const {
std::vector<pid_t> ThreadTable::Threads() const {
std::vector<pid_t> tids;
std::lock_guard<std::mutex> lock(thread_mutex_);
tids.reserve(threads_.size());
for (const auto& t : threads_) {
tids.push_back(t.first);
}
Expand Down
1 change: 1 addition & 0 deletions src/throttler_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ bool APIThrottler::WaitNext() {
}

api::CreateProfileRequest req;
req.mutable_profile_type()->Reserve(types_.size());
for (const auto& type : types_) {
req.add_profile_type(type);
}
Expand Down
21 changes: 0 additions & 21 deletions third_party/javaprofiler/heap_sampler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ bool HeapMonitor::CreateGCWaitingThread(jvmtiEnv* jvmti, JNIEnv* jni) {
}

bool HeapMonitor::Supported(jvmtiEnv *jvmti) {
#ifdef ENABLE_HEAP_SAMPLING
jvmtiCapabilities caps;
memset(&caps, 0, sizeof(caps));
if (jvmti->GetPotentialCapabilities(&caps) != JVMTI_ERROR_NONE) {
Expand All @@ -347,9 +346,6 @@ bool HeapMonitor::Supported(jvmtiEnv *jvmti) {
return false;
}
return true;
#else
return false;
#endif
}

void HeapMonitor::AddSample(JNIEnv *jni_env, jthread thread, jobject object,
Expand Down Expand Up @@ -421,16 +417,13 @@ void HeapMonitor::WaitForShutdown() {
}

void HeapMonitor::AddCallback(jvmtiEventCallbacks *callbacks) {
#ifdef ENABLE_HEAP_SAMPLING
callbacks->SampledObjectAlloc = &SampledObjectAlloc;
callbacks->GarbageCollectionFinish = &GarbageCollectionFinish;
#endif
}

// Currently, we enable once and forget about it.
bool HeapMonitor::Enable(jvmtiEnv *jvmti, JNIEnv* jni, int sampling_interval,
bool use_jvm_trace) {
#ifdef ENABLE_HEAP_SAMPLING
if (!Supported(jvmti)) {
LOG(WARNING) << "Heap sampling is not supported by the JVM, disabling the "
<< " heap sampling monitor";
Expand Down Expand Up @@ -495,13 +488,9 @@ bool HeapMonitor::Enable(jvmtiEnv *jvmti, JNIEnv* jni, int sampling_interval,
}

return true;
#else
return false;
#endif
}

void HeapMonitor::Disable() {
#ifdef ENABLE_HEAP_SAMPLING
jvmtiEnv *jvmti = jvmti_.load();
if (!jvmti) {
return;
Expand All @@ -516,47 +505,37 @@ void HeapMonitor::Disable() {

// Notify the agent thread that we are done.
google::javaprofiler::HeapMonitor::GetInstance()->ShutdownGCWaitingThread();

#else
// Do nothing: we never enabled ourselves.
#endif
}

std::unique_ptr<perftools::profiles::Profile> HeapMonitor::GetHeapProfiles(
JNIEnv* env, bool force_gc) {
#ifdef ENABLE_HEAP_SAMPLING
// Note: technically this means that you cannot disable the sampler and then
// get the profile afterwards; this could be changed if needed.
if (jvmti_) {
return GetInstance()->storage_.GetHeapProfiles(env, sampling_interval_,
force_gc);
}
#endif
return EmptyHeapProfile(env);
}

std::unique_ptr<perftools::profiles::Profile> HeapMonitor::GetPeakHeapProfiles(
JNIEnv* env, bool force_gc) {
#ifdef ENABLE_HEAP_SAMPLING
// Note: technically this means that you cannot disable the sampler and then
// get the profile afterwards; this could be changed if needed.
if (jvmti_) {
return GetInstance()->storage_.GetPeakHeapProfiles(env, sampling_interval_);
}
#endif
return EmptyHeapProfile(env);
}

std::unique_ptr<perftools::profiles::Profile>
HeapMonitor::GetGarbageHeapProfiles(JNIEnv* env, bool force_gc) {
#ifdef ENABLE_HEAP_SAMPLING
// Note: technically this means that you cannot disable the sampler and then
// get the profile afterwards; this could be changed if needed.
if (jvmti_) {
return GetInstance()->storage_.GetGarbageHeapProfiles(
env, sampling_interval_, force_gc);
}
#endif
return EmptyHeapProfile(env);
}

Expand Down