Commit f2ffd5e5 authored by ruuda's avatar ruuda Committed by Commit bot

[Eraser] Remove chrome://tcmalloc

The chrome://tcmalloc page has been superseded by the memory-infra
category of chrome://tracing. The page no longer provides enough value
to justify its complexity in the codebase, so unlaunch it in the light
of Project Eraser.

Furthermore, this allows removing |base::allocator::GetStats|, which is
not used anywhere except in chrome:://tcmalloc. Detailed information
about memory allocators is available in the memory-infra category of
chrome://tracing. Unlike |GetStats|, which was implemented for tcmalloc
only, memory-infra provides detailed information about all allocators.

BUG=560250

Review URL: https://codereview.chromium.org/1468993003

Cr-Commit-Position: refs/heads/master@{#361402}
parent a423527b
......@@ -9,15 +9,6 @@
namespace base {
namespace allocator {
void GetStats(char* buffer, int buffer_length) {
DCHECK_GT(buffer_length, 0);
thunks::GetStatsFunction get_stats_function = thunks::GetGetStatsFunction();
if (get_stats_function)
get_stats_function(buffer, buffer_length);
else
buffer[0] = '\0';
}
void ReleaseFreeMemory() {
thunks::ReleaseFreeMemoryFunction release_free_memory_function =
thunks::GetReleaseFreeMemoryFunction();
......@@ -25,12 +16,6 @@ void ReleaseFreeMemory() {
release_free_memory_function();
}
void SetGetStatsFunction(thunks::GetStatsFunction get_stats_function) {
DCHECK_EQ(thunks::GetGetStatsFunction(),
reinterpret_cast<thunks::GetStatsFunction>(NULL));
thunks::SetGetStatsFunction(get_stats_function);
}
void SetReleaseFreeMemoryFunction(
thunks::ReleaseFreeMemoryFunction release_free_memory_function) {
DCHECK_EQ(thunks::GetReleaseFreeMemoryFunction(),
......
......@@ -14,19 +14,10 @@
namespace base {
namespace allocator {
// Request that the allocator print a human-readable description of the current
// state of the allocator into a null-terminated string in the memory segment
// buffer[0,buffer_length-1].
//
// |buffer| must point to a valid piece of memory
// |buffer_length| must be > 0.
BASE_EXPORT void GetStats(char* buffer, int buffer_length);
// Request that the allocator release any free memory it knows about to the
// system.
BASE_EXPORT void ReleaseFreeMemory();
// These settings allow specifying a callback used to implement the allocator
// extension functions. These are optional, but if set they must only be set
// once. These will typically called in an allocator-specific initialization
......@@ -36,9 +27,6 @@ BASE_EXPORT void ReleaseFreeMemory();
// these pointers are set before any other threads attempt to call the above
// functions.
BASE_EXPORT void SetGetStatsFunction(
thunks::GetStatsFunction get_stats_function);
BASE_EXPORT void SetReleaseFreeMemoryFunction(
thunks::ReleaseFreeMemoryFunction release_free_memory_function);
......
......@@ -17,18 +17,9 @@ namespace thunks {
// can depend on it. This file can't depend on anything else in base, including
// logging.
static GetStatsFunction g_get_stats_function = NULL;
static ReleaseFreeMemoryFunction g_release_free_memory_function = NULL;
static GetNumericPropertyFunction g_get_numeric_property_function = NULL;
void SetGetStatsFunction(GetStatsFunction get_stats_function) {
g_get_stats_function = get_stats_function;
}
GetStatsFunction GetGetStatsFunction() {
return g_get_stats_function;
}
void SetReleaseFreeMemoryFunction(
ReleaseFreeMemoryFunction release_free_memory_function) {
g_release_free_memory_function = release_free_memory_function;
......
......@@ -15,10 +15,6 @@ namespace thunks {
// new allocator extension from a specific allocator implementation to base.
// See allocator_extension.h to see the interface that base exports.
typedef void (*GetStatsFunction)(char* buffer, int buffer_length);
void SetGetStatsFunction(GetStatsFunction get_stats_function);
GetStatsFunction GetGetStatsFunction();
typedef void (*ReleaseFreeMemoryFunction)();
void SetReleaseFreeMemoryFunction(
ReleaseFreeMemoryFunction release_free_memory_function);
......
......@@ -7,7 +7,6 @@
#include <limits>
#include <vector>
#include "base/allocator/allocator_extension.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
......
......@@ -414,10 +414,6 @@ class ContentMainRunnerImpl : public ContentMainRunner {
}
#if defined(USE_TCMALLOC)
static void GetStatsThunk(char* buffer, int buffer_length) {
MallocExtension::instance()->GetStats(buffer, buffer_length);
}
static bool GetNumericPropertyThunk(const char* name, size_t* value) {
return MallocExtension::instance()->GetNumericProperty(name, value);
}
......@@ -456,7 +452,6 @@ class ContentMainRunnerImpl : public ContentMainRunner {
tc_set_new_mode(1);
// On windows, we've already set these thunks up in _heap_init()
base::allocator::SetGetStatsFunction(GetStatsThunk);
base::allocator::SetGetNumericPropertyFunction(GetNumericPropertyThunk);
base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk);
......
......@@ -8,7 +8,6 @@
#include "base/metrics/histogram.h"
#include "base/metrics/statistics_recorder.h"
#include "content/browser/histogram_controller.h"
#include "content/browser/tcmalloc_internals_request_job.h"
#include "content/common/child_process_messages.h"
#include "content/public/common/content_switches.h"
......
......@@ -6,7 +6,6 @@
#include "base/tracked_objects.h"
#include "content/browser/profiler_controller_impl.h"
#include "content/browser/tcmalloc_internals_request_job.h"
#include "content/common/child_process_messages.h"
namespace content {
......@@ -26,9 +25,6 @@ bool ProfilerMessageFilter::OnMessageReceived(const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP(ProfilerMessageFilter, message)
IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ChildProfilerData,
OnChildProfilerData)
#if defined(USE_TCMALLOC)
IPC_MESSAGE_HANDLER(ChildProcessHostMsg_TcmallocStats, OnTcmallocStats)
#endif
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
......@@ -43,11 +39,4 @@ void ProfilerMessageFilter::OnChildProfilerData(
sequence_number, profiler_data, process_type_);
}
#if defined(USE_TCMALLOC)
void ProfilerMessageFilter::OnTcmallocStats(const std::string& output) {
AboutTcmallocOutputs::GetInstance()->OnStatsForChildProcess(
peer_pid(), process_type_, output);
}
#endif
}
......@@ -36,10 +36,6 @@ class ProfilerMessageFilter : public BrowserMessageFilter {
int sequence_number,
const tracked_objects::ProcessDataSnapshot& profiler_data);
#if defined(USE_TCMALLOC)
void OnTcmallocStats(const std::string& output);
#endif
content::ProcessType process_type_;
DISALLOW_COPY_AND_ASSIGN(ProfilerMessageFilter);
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/tcmalloc_internals_request_job.h"
#include "base/allocator/allocator_extension.h"
#include "content/common/child_process_messages.h"
#include "content/public/browser/browser_child_process_host_iterator.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/process_type.h"
#include "net/base/net_errors.h"
namespace content {
// static
AboutTcmallocOutputs* AboutTcmallocOutputs::GetInstance() {
return base::Singleton<AboutTcmallocOutputs>::get();
}
AboutTcmallocOutputs::AboutTcmallocOutputs() {}
AboutTcmallocOutputs::~AboutTcmallocOutputs() {}
void AboutTcmallocOutputs::OnStatsForChildProcess(
base::ProcessId pid, int process_type,
const std::string& output) {
std::string header = GetProcessTypeNameInEnglish(process_type);
base::StringAppendF(&header, " PID %d", static_cast<int>(pid));
SetOutput(header, output);
}
void AboutTcmallocOutputs::SetOutput(const std::string& header,
const std::string& output) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
outputs_[header] = output;
}
void AboutTcmallocOutputs::DumpToHTMLTable(std::string* data) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
data->append("<table width=\"100%\">\n");
for (AboutTcmallocOutputsType::const_iterator oit = outputs_.begin();
oit != outputs_.end();
oit++) {
data->append("<tr><td bgcolor=\"yellow\">");
data->append(oit->first);
data->append("</td></tr>\n");
data->append("<tr><td><pre>\n");
data->append(oit->second);
data->append("</pre></td></tr>\n");
}
data->append("</table>\n");
outputs_.clear();
}
TcmallocInternalsRequestJob::TcmallocInternalsRequestJob(
net::URLRequest* request, net::NetworkDelegate* network_delegate)
: net::URLRequestSimpleJob(request, network_delegate) {
}
#if defined(USE_TCMALLOC)
void RequestTcmallocStatsFromChildRenderProcesses() {
RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator());
while (!it.IsAtEnd()) {
it.GetCurrentValue()->Send(new ChildProcessMsg_GetTcmallocStats);
it.Advance();
}
}
void AboutTcmalloc(std::string* data) {
data->append("<!DOCTYPE html>\n<html>\n<head>\n");
data->append(
"<meta http-equiv=\"Content-Security-Policy\" "
"content=\"object-src 'none'; script-src 'none'\">");
data->append("<title>tcmalloc stats</title>");
data->append("</head><body>");
// Display any stats for which we sent off requests the last time.
data->append("<p>Stats as of last page load;");
data->append("reload to get stats as of this page load.</p>\n");
data->append("<table width=\"100%\">\n");
AboutTcmallocOutputs::GetInstance()->DumpToHTMLTable(data);
data->append("</body></html>\n");
// Populate the collector with stats from the local browser process
// and send off requests to all the renderer processes.
char buffer[1024 * 32];
base::allocator::GetStats(buffer, sizeof(buffer));
std::string browser("Browser");
AboutTcmallocOutputs::GetInstance()->SetOutput(browser, buffer);
for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) {
iter.Send(new ChildProcessMsg_GetTcmallocStats);
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(
&RequestTcmallocStatsFromChildRenderProcesses));
}
#endif
int TcmallocInternalsRequestJob::GetData(
std::string* mime_type,
std::string* charset,
std::string* data,
const net::CompletionCallback& callback) const {
mime_type->assign("text/html");
charset->assign("UTF8");
data->clear();
#if defined(USE_TCMALLOC)
AboutTcmalloc(data);
#endif
return net::OK;
}
} // namespace content
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_TCMALLOC_INTERNALS_REQUEST_JOB_H_
#define CONTENT_BROWSER_TCMALLOC_INTERNALS_REQUEST_JOB_H_
#include <map>
#include "base/basictypes.h"
#include "base/memory/singleton.h"
#include "base/process/process.h"
#include "build/build_config.h" // USE_TCMALLOC
#include "net/url_request/url_request_simple_job.h"
namespace content {
class AboutTcmallocOutputs {
public:
// Returns the singleton instance.
static AboutTcmallocOutputs* GetInstance();
// Records the output for a specified header string.
void SetOutput(const std::string& header, const std::string& output);
void DumpToHTMLTable(std::string* data);
// Callback for output returned from a child process. Adds
// the output for a canonical process-specific header string that
// incorporates the pid.
void OnStatsForChildProcess(base::ProcessId pid,
int process_type,
const std::string& output);
private:
AboutTcmallocOutputs();
~AboutTcmallocOutputs();
// A map of header strings (e.g. "Browser", "Renderer PID 123")
// to the tcmalloc output collected for each process.
typedef std::map<std::string, std::string> AboutTcmallocOutputsType;
AboutTcmallocOutputsType outputs_;
friend struct base::DefaultSingletonTraits<AboutTcmallocOutputs>;
DISALLOW_COPY_AND_ASSIGN(AboutTcmallocOutputs);
};
class TcmallocInternalsRequestJob : public net::URLRequestSimpleJob {
public:
TcmallocInternalsRequestJob(net::URLRequest* request,
net::NetworkDelegate* network_delegate);
int GetData(std::string* mime_type,
std::string* charset,
std::string* data,
const net::CompletionCallback& callback) const override;
protected:
~TcmallocInternalsRequestJob() override {}
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(TcmallocInternalsRequestJob);
};
} // namespace content
#endif // CONTENT_BROWSER_TCMALLOC_INTERNALS_REQUEST_JOB_H_
......@@ -26,7 +26,6 @@
#include "content/browser/net/view_blob_internals_job_factory.h"
#include "content/browser/net/view_http_cache_job_factory.h"
#include "content/browser/resource_context_impl.h"
#include "content/browser/tcmalloc_internals_request_job.h"
#include "content/browser/webui/shared_resources_data_source.h"
#include "content/browser/webui/url_data_source_impl.h"
#include "content/public/browser/browser_context.h"
......@@ -484,14 +483,6 @@ class ChromeProtocolHandler
request, network_delegate, blob_storage_context_->context());
}
#if defined(USE_TCMALLOC)
// Next check for chrome://tcmalloc/, which uses its own job type.
if (request->url().SchemeIs(kChromeUIScheme) &&
request->url().host() == kChromeUITcmallocHost) {
return new TcmallocInternalsRequestJob(request, network_delegate);
}
#endif
// Next check for chrome://histograms/, which uses its own job type.
if (request->url().SchemeIs(kChromeUIScheme) &&
request->url().host() == kChromeUIHistogramHost) {
......
......@@ -8,7 +8,6 @@
#include <string>
#include "base/allocator/allocator_extension.h"
#include "base/base_switches.h"
#include "base/basictypes.h"
#include "base/command_line.h"
......@@ -662,9 +661,6 @@ bool ChildThreadImpl::OnMessageReceived(const IPC::Message& msg) {
#if defined(OS_WIN)
IPC_MESSAGE_HANDLER(ChildProcessMsg_SetMojoParentPipeHandle,
OnSetMojoParentPipeHandle)
#endif
#if defined(USE_TCMALLOC)
IPC_MESSAGE_HANDLER(ChildProcessMsg_GetTcmallocStats, OnGetTcmallocStats)
#endif
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
......@@ -742,16 +738,6 @@ void ChildThreadImpl::OnSetMojoParentPipeHandle(
}
#endif
#if defined(USE_TCMALLOC)
void ChildThreadImpl::OnGetTcmallocStats() {
std::string result;
char buffer[1024 * 32];
base::allocator::GetStats(buffer, sizeof(buffer));
result.append(buffer);
Send(new ChildProcessHostMsg_TcmallocStats(result));
}
#endif
ChildThreadImpl* ChildThreadImpl::current() {
return g_lazy_tls.Pointer()->Get();
}
......
......@@ -238,9 +238,6 @@ class CONTENT_EXPORT ChildThreadImpl
#if defined(OS_WIN)
void OnSetMojoParentPipeHandle(const IPC::PlatformFileForTransit& file);
#endif
#if defined(USE_TCMALLOC)
void OnGetTcmallocStats();
#endif
void EnsureConnected();
......
......@@ -121,11 +121,6 @@ IPC_MESSAGE_CONTROL1(ChildProcessMsg_GetChildHistogramData,
IPC_MESSAGE_CONTROL1(ChildProcessMsg_SetProcessBackgrounded,
bool /* background */)
#if defined(USE_TCMALLOC)
// Sent to child process to request tcmalloc stats.
IPC_MESSAGE_CONTROL0(ChildProcessMsg_GetTcmallocStats)
#endif
#if defined(OS_MACOSX)
// Sent to child processes to tell them what token to use when registering
// and/or acquiring IOSurfaces.
......@@ -201,12 +196,6 @@ IPC_MESSAGE_CONTROL3(ChildProcessHostMsg_AllocatedSharedBitmap,
IPC_MESSAGE_CONTROL1(ChildProcessHostMsg_DeletedSharedBitmap,
cc::SharedBitmapId)
#if defined(USE_TCMALLOC)
// Reply to ChildProcessMsg_GetTcmallocStats.
IPC_MESSAGE_CONTROL1(ChildProcessHostMsg_TcmallocStats,
std::string /* output */)
#endif
// Asks the browser to create a gpu memory buffer.
IPC_SYNC_MESSAGE_CONTROL5_1(ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer,
gfx::GpuMemoryBufferId /* new_id */,
......
......@@ -1458,8 +1458,6 @@
'browser/streams/stream_write_observer.h',
'browser/system_message_window_win.cc',
'browser/system_message_window_win.h',
'browser/tcmalloc_internals_request_job.cc',
'browser/tcmalloc_internals_request_job.h',
'browser/theme_helper_mac.h',
'browser/theme_helper_mac.mm',
'browser/time_zone_monitor.cc',
......
......@@ -83,10 +83,6 @@ class GpuChildThread : public ChildThreadImpl {
void OnDisableWatchdog();
void OnGpuSwitched();
#if defined(USE_TCMALLOC)
void OnGetGpuTcmalloc();
#endif
void BindProcessControlRequest(
mojo::InterfaceRequest<ProcessControl> request);
......
......@@ -31,7 +31,6 @@ const char kChromeUIMediaInternalsHost[] = "media-internals";
const char kChromeUINetworkViewCacheHost[] = "view-http-cache";
const char kChromeUIResourcesHost[] = "resources";
const char kChromeUIServiceWorkerInternalsHost[] = "serviceworker-internals";
const char kChromeUITcmallocHost[] = "tcmalloc";
const char kChromeUITracingHost[] = "tracing";
const char kChromeUIWebRTCInternalsHost[] = "webrtc-internals";
......
......@@ -39,7 +39,6 @@ CONTENT_EXPORT extern const char kChromeUIMediaInternalsHost[];
CONTENT_EXPORT extern const char kChromeUINetworkViewCacheHost[];
CONTENT_EXPORT extern const char kChromeUIResourcesHost[];
CONTENT_EXPORT extern const char kChromeUIServiceWorkerInternalsHost[];
CONTENT_EXPORT extern const char kChromeUITcmallocHost[];
CONTENT_EXPORT extern const char kChromeUITracingHost[];
CONTENT_EXPORT extern const char kChromeUIWebRTCInternalsHost[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment