summaryrefslogtreecommitdiffstats
path: root/net/tools
diff options
context:
space:
mode:
authordigit@chromium.org <digit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-11 00:46:14 +0000
committerdigit@chromium.org <digit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-11 00:46:14 +0000
commit78d5af3ef2c6362f029aff45ee4db733c91d8c89 (patch)
treee2291a7a0e1ba125f6ee267da5835149baf521ac /net/tools
parent61cb25a82241fb3f298493264db341584de34862 (diff)
downloadchromium_src-78d5af3ef2c6362f029aff45ee4db733c91d8c89.zip
chromium_src-78d5af3ef2c6362f029aff45ee4db733c91d8c89.tar.gz
chromium_src-78d5af3ef2c6362f029aff45ee4db733c91d8c89.tar.bz2
net: Remove 70KB of relocatable string pointers.
Profiling shows that effective_tld_names.cc generates more than 70 KB of tables containing constant pointers to strings. On Linux and Android, this makes the tables relocatable, which means: - The tables are placed in the non-shareable RELRO section of the ELF library. On Android, each Chromium process will require 70 KB of private RAM to store them. - The pointers need to be relocated by the dynamic linker at load time, slowing down startup time (mainly due to the extra page faults, especially during a cold boot). This patch removes these pointers by generating tables that only contain offsets into a common string pool, using the gperf -P option and modifying the caller of the generated function to perform the relocation at runtime. On Android, this patch should save a little RAM in each Chromium process. It will also slightly speed up startup / library loading. BUG=249747,245442 R=nyquist@chromium.org, pam@chromium.org Review URL: https://codereview.chromium.org/18341004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210990 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/tools')
-rw-r--r--net/tools/tld_cleanup/README2
-rw-r--r--net/tools/tld_cleanup/tld_cleanup_util.cc27
2 files changed, 14 insertions, 15 deletions
diff --git a/net/tools/tld_cleanup/README b/net/tools/tld_cleanup/README
index ac563cc..a7f137d 100644
--- a/net/tools/tld_cleanup/README
+++ b/net/tools/tld_cleanup/README
@@ -22,7 +22,7 @@ When updating src/net/base/registry_controlled_domains/effective_tld_names.dat:
6. Run gperf on the new effective_tld_names.gperf:
pushd src/net/base/registry_controlled_domains;
- gperf -a -L "C++" -C -c -o -t -k '*' -NFindDomain -D -m 10 \
+ gperf -a -L "C++" -C -c -o -t -k '*' -NFindDomain -P -K name_offset -D -m 10 \
effective_tld_names.gperf > effective_tld_names.cc;
popd;
It will produce a new effective_tld_names.cc.
diff --git a/net/tools/tld_cleanup/tld_cleanup_util.cc b/net/tools/tld_cleanup/tld_cleanup_util.cc
index 9cda566..efdc99b 100644
--- a/net/tools/tld_cleanup/tld_cleanup_util.cc
+++ b/net/tools/tld_cleanup/tld_cleanup_util.cc
@@ -29,20 +29,19 @@ namespace tld_cleanup {
// been created with write access.
bool WriteRules(const RuleMap& rules, const base::FilePath& outfile) {
std::string data;
- data.append(
-"%{\n"
-"// Copyright 2012 The Chromium Authors. All rights reserved.\n"
-"// Use of this source code is governed by a BSD-style license that can be\n"
-"// found in the LICENSE file.\n\n"
-"// This file is generated by net/tools/tld_cleanup/.\n"
-"// DO NOT MANUALLY EDIT!\n"
-"%}\n"
-"struct DomainRule {\n"
-" const char *name;\n"
-" int type; // flags: 1: exception, 2: wildcard, 4: private\n"
-"};\n"
-"%%\n"
- );
+ data.append("%{\n"
+ "// Copyright 2012 The Chromium Authors. All rights reserved.\n"
+ "// Use of this source code is governed by a BSD-style license "
+ "that can be\n"
+ "// found in the LICENSE file.\n\n"
+ "// This file is generated by net/tools/tld_cleanup/.\n"
+ "// DO NOT MANUALLY EDIT!\n"
+ "%}\n"
+ "struct DomainRule {\n"
+ " int name_offset;\n"
+ " int type; // flags: 1: exception, 2: wildcard, 4: private\n"
+ "};\n"
+ "%%\n");
for (RuleMap::const_iterator i = rules.begin(); i != rules.end(); ++i) {
data.append(i->first);