Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(799)

Issue 2530573002: Share field trial allocator on zygote-using Linuxes (Closed)

Created:
4 years ago by lawrencewu
Modified:
4 years ago
CC:
asvitkine+watch_chromium.org, chromium-reviews, darin-cc_chromium.org, jam, vmpstr+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Share field trial allocator on zygote-using Linuxes This passes a read-only handle to the field trial allocator on Linux (that is, on POSIX machines that use the zygote model). It works in the following way: in child_process_launcher.cc, we add our handle to shared memory, which is a file descriptor (since shared memory is really just an unnamed file), to files_to_register. The fds in this mapping get remapped in the zygote process, and then all child processes fork off the zygote, so the fds are the same in the child as in the zygote. When we spawn a new process, then, we add our fd as a switch on the command line (--field-trial-handle). Then, in the child process, we must grab this fd and read from it. But first, we have to get the correct fd using GlobalDescriptors, which is a singleton that maps from the browser process's fd (key which we have) to the remapped fd on the zygote (actual fd containing shared memory). So we use that to look it up and then read from shared memory as usual. BUG=663914 Committed: https://crrev.com/c4fe88004d0457cf00b1731c1e974c96a3cd649e Cr-Commit-Position: refs/heads/master@{#435284}

Patch Set 1 #

Patch Set 2 : cleanup #

Patch Set 3 : make handle read-only #

Total comments: 12

Patch Set 4 : address comments #

Patch Set 5 : address comments #

Patch Set 6 : ignore macosx on posix #

Patch Set 7 : clean up ifdefs #

Patch Set 8 : git rebase-update #

Patch Set 9 : git rebase-update #

Patch Set 10 : keep flag true #

Patch Set 11 : fix windows compile issue #

Patch Set 12 : fix ifdef #

Total comments: 6

Patch Set 13 : Address comments. #

Patch Set 14 : address comments #

Total comments: 4

Patch Set 15 : remove some duplicated code and cleanup #

Patch Set 16 : fix unittest #

Patch Set 17 : add posix comments #

Total comments: 2

Patch Set 18 : add comment #

Patch Set 19 : fix compile error #

Patch Set 20 : s/Handle/File/ #

Patch Set 21 : add missing include #

Patch Set 22 : use constant content descriptor #

Patch Set 23 : fix createtrialsfromcommandline calls #

Patch Set 24 : git rebase-update #

Total comments: 16

Patch Set 25 : add base:: namepsaces #

Patch Set 26 : create CreateTrialsFromDescriptor and fallback to commandline #

Patch Set 27 : remove unnecessary comment and import #

Patch Set 28 : fix compile issue #

Patch Set 29 : fallback to command line if descriptor not found #

Total comments: 2

Patch Set 30 : remove OS_NACL ifdefs #

Patch Set 31 : fix nacl compile issue #

Patch Set 32 : revert to excluding nacl in ifdef #

Total comments: 4

Patch Set 33 : make CreateTrialsFromDescriptor private #

Patch Set 34 : fix up comment for CreateTrialsFromCommandLine #

Patch Set 35 : pass -1 instead of nullptr #

Patch Set 36 : s/nullptr/-1/ #

Patch Set 37 : fix call from content_main_runner #

Total comments: 20

Patch Set 38 : address comments #

Total comments: 1

Patch Set 39 : address nits #

Patch Set 40 : move comment down #

Patch Set 41 : add check back #

Unified diffs Side-by-side diffs Delta from patch set Stats (+156 lines, -41 lines) Patch
M base/metrics/field_trial.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 5 chunks +32 lines, -17 lines 0 comments Download
M base/metrics/field_trial.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 9 chunks +102 lines, -17 lines 0 comments Download
M base/metrics/field_trial_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 2 chunks +2 lines, -4 lines 0 comments Download
M components/variations/child_process_field_trial_syncer_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 1 chunk +2 lines, -1 line 0 comments Download
M content/app/content_main_runner.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 2 chunks +12 lines, -1 line 0 comments Download
M content/browser/child_process_launcher.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 chunk +3 lines, -0 lines 0 comments Download
M content/public/common/content_descriptors.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 chunk +1 line, -0 lines 0 comments Download
M content/public/test/render_view_test.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 1 chunk +2 lines, -1 line 0 comments Download

Messages

Total messages: 143 (109 generated)
lawrencewu
Initial CL for sharing the field trial allocator on Linux. I will probably have to ...
4 years ago (2016-11-23 16:50:28 UTC) #6
Alexei Svitkine (slow)
Initial pass. https://codereview.chromium.org/2530573002/diff/40001/base/metrics/field_trial.cc File base/metrics/field_trial.cc (right): https://codereview.chromium.org/2530573002/diff/40001/base/metrics/field_trial.cc#newcode240 base/metrics/field_trial.cc:240: #elif defined(OS_POSIX) && !defined(OS_NACL) Instead of these ...
4 years ago (2016-11-23 17:49:55 UTC) #7
lawrencewu
Address comments. https://codereview.chromium.org/2530573002/diff/40001/base/metrics/field_trial.cc File base/metrics/field_trial.cc (right): https://codereview.chromium.org/2530573002/diff/40001/base/metrics/field_trial.cc#newcode240 base/metrics/field_trial.cc:240: #elif defined(OS_POSIX) && !defined(OS_NACL) On 2016/11/23 17:49:55, ...
4 years ago (2016-11-23 18:59:44 UTC) #8
lawrencewu
Verified that this falls back using the command line on Mac as intended. On 2016/11/23 ...
4 years ago (2016-11-24 16:33:28 UTC) #26
Alexei Svitkine (slow)
https://codereview.chromium.org/2530573002/diff/220001/base/metrics/field_trial.cc File base/metrics/field_trial.cc (right): https://codereview.chromium.org/2530573002/diff/220001/base/metrics/field_trial.cc#newcode8 base/metrics/field_trial.cc:8: #endif Not At the top of the file - ...
4 years ago (2016-11-24 17:44:35 UTC) #33
lawrencewu
Address comments. https://codereview.chromium.org/2530573002/diff/220001/base/metrics/field_trial.cc File base/metrics/field_trial.cc (right): https://codereview.chromium.org/2530573002/diff/220001/base/metrics/field_trial.cc#newcode8 base/metrics/field_trial.cc:8: #endif On 2016/11/24 17:44:34, Alexei Svitkine (slow) ...
4 years ago (2016-11-24 18:16:13 UTC) #35
Alexei Svitkine (slow)
https://codereview.chromium.org/2530573002/diff/260001/base/metrics/field_trial.cc File base/metrics/field_trial.cc (right): https://codereview.chromium.org/2530573002/diff/260001/base/metrics/field_trial.cc#newcode844 base/metrics/field_trial.cc:844: if (kUseSharedMemoryForFieldTrials) { This block seems to be almost ...
4 years ago (2016-11-24 18:23:19 UTC) #37
lawrencewu
Address comments. https://codereview.chromium.org/2530573002/diff/260001/base/metrics/field_trial.cc File base/metrics/field_trial.cc (right): https://codereview.chromium.org/2530573002/diff/260001/base/metrics/field_trial.cc#newcode844 base/metrics/field_trial.cc:844: if (kUseSharedMemoryForFieldTrials) { On 2016/11/24 18:23:19, Alexei ...
4 years ago (2016-11-24 18:48:59 UTC) #40
Alexei Svitkine (slow)
lgtm https://codereview.chromium.org/2530573002/diff/320001/base/metrics/field_trial.cc File base/metrics/field_trial.cc (right): https://codereview.chromium.org/2530573002/diff/320001/base/metrics/field_trial.cc#newcode799 base/metrics/field_trial.cc:799: if (global_->readonly_allocator_handle_ != kInvalidPlatformFile) Nit: Seems this if ...
4 years ago (2016-11-24 19:04:39 UTC) #41
lawrencewu
address nit https://codereview.chromium.org/2530573002/diff/320001/base/metrics/field_trial.cc File base/metrics/field_trial.cc (right): https://codereview.chromium.org/2530573002/diff/320001/base/metrics/field_trial.cc#newcode799 base/metrics/field_trial.cc:799: if (global_->readonly_allocator_handle_ != kInvalidPlatformFile) On 2016/11/24 19:04:39, ...
4 years ago (2016-11-24 19:14:57 UTC) #42
lawrencewu
@jochen: mind looking at the changes to child_process_launcher.cc? Thanks in advance.
4 years ago (2016-11-24 19:17:49 UTC) #44
lawrencewu
@jochen: Hmm, maybe you should hold off, actually. I'll take a look at those red ...
4 years ago (2016-11-25 04:31:34 UTC) #57
lawrencewu
@asvitkine, @jochen: mind taking another look?
4 years ago (2016-11-28 16:28:57 UTC) #68
Alexei Svitkine (slow)
https://codereview.chromium.org/2530573002/diff/460001/base/metrics/field_trial.cc File base/metrics/field_trial.cc (right): https://codereview.chromium.org/2530573002/diff/460001/base/metrics/field_trial.cc#newcode842 base/metrics/field_trial.cc:842: global_->field_trial_allocator_->UpdateTrackingHistograms(); We should also log this histogram on Linux. ...
4 years ago (2016-11-28 16:56:13 UTC) #73
lawrencewu
Address comments and create a method CreateTrialsFromDescriptor() that we attempt to use on Linux (and ...
4 years ago (2016-11-29 14:38:08 UTC) #90
jochen (gone - plz use gerrit)
https://codereview.chromium.org/2530573002/diff/560001/content/app/content_main_runner.cc File content/app/content_main_runner.cc (right): https://codereview.chromium.org/2530573002/diff/560001/content/app/content_main_runner.cc#newcode148 content/app/content_main_runner.cc:148: !defined(OS_ANDROID) e.g. https://cs.chromium.org/chromium/src/content/public/common/zygote_handle.h has a different condition. why OS_NACL?
4 years ago (2016-11-29 15:13:39 UTC) #91
lawrencewu
https://codereview.chromium.org/2530573002/diff/560001/content/app/content_main_runner.cc File content/app/content_main_runner.cc (right): https://codereview.chromium.org/2530573002/diff/560001/content/app/content_main_runner.cc#newcode148 content/app/content_main_runner.cc:148: !defined(OS_ANDROID) On 2016/11/29 15:13:39, jochen wrote: > e.g. https://cs.chromium.org/chromium/src/content/public/common/zygote_handle.h ...
4 years ago (2016-11-29 15:24:51 UTC) #93
lawrencewu
On 2016/11/29 15:24:51, lawrencewu wrote: > https://codereview.chromium.org/2530573002/diff/560001/content/app/content_main_runner.cc > File content/app/content_main_runner.cc (right): > > https://codereview.chromium.org/2530573002/diff/560001/content/app/content_main_runner.cc#newcode148 > ...
4 years ago (2016-11-29 15:52:35 UTC) #99
lawrencewu
On 2016/11/29 15:24:51, lawrencewu wrote: > https://codereview.chromium.org/2530573002/diff/560001/content/app/content_main_runner.cc > File content/app/content_main_runner.cc (right): > > https://codereview.chromium.org/2530573002/diff/560001/content/app/content_main_runner.cc#newcode148 > ...
4 years ago (2016-11-29 15:52:36 UTC) #100
lawrencewu
On 2016/11/29 15:52:36, lawrencewu wrote: > On 2016/11/29 15:24:51, lawrencewu wrote: > > > https://codereview.chromium.org/2530573002/diff/560001/content/app/content_main_runner.cc ...
4 years ago (2016-11-29 16:15:47 UTC) #105
Alexei Svitkine (slow)
https://codereview.chromium.org/2530573002/diff/460001/base/metrics/field_trial_unittest.cc File base/metrics/field_trial_unittest.cc (right): https://codereview.chromium.org/2530573002/diff/460001/base/metrics/field_trial_unittest.cc#newcode1151 base/metrics/field_trial_unittest.cc:1151: } Suggest keeping this test and just make it ...
4 years ago (2016-11-29 17:38:27 UTC) #108
lawrencewu
Revert to putting logic back in field_trial.cc and falling back from there. https://codereview.chromium.org/2530573002/diff/460001/base/metrics/field_trial_unittest.cc File base/metrics/field_trial_unittest.cc ...
4 years ago (2016-11-29 19:11:01 UTC) #115
lawrencewu
https://codereview.chromium.org/2530573002/diff/620001/content/app/content_main_runner.cc File content/app/content_main_runner.cc (right): https://codereview.chromium.org/2530573002/diff/620001/content/app/content_main_runner.cc#newcode156 content/app/content_main_runner.cc:156: } On 2016/11/29 17:38:27, Alexei Svitkine (slow) wrote: > ...
4 years ago (2016-11-29 19:11:20 UTC) #116
Alexei Svitkine (slow)
https://codereview.chromium.org/2530573002/diff/720001/base/metrics/field_trial.cc File base/metrics/field_trial.cc (right): https://codereview.chromium.org/2530573002/diff/720001/base/metrics/field_trial.cc#newcode773 base/metrics/field_trial.cc:773: bool result = CreateTrialsFromDescriptor(field_trial_descriptor_id); Nit: Just inline this into ...
4 years ago (2016-11-29 19:32:47 UTC) #117
lawrencewu
Address comments. https://codereview.chromium.org/2530573002/diff/720001/base/metrics/field_trial.cc File base/metrics/field_trial.cc (right): https://codereview.chromium.org/2530573002/diff/720001/base/metrics/field_trial.cc#newcode773 base/metrics/field_trial.cc:773: bool result = CreateTrialsFromDescriptor(field_trial_descriptor_id); On 2016/11/29 19:32:47, ...
4 years ago (2016-11-29 19:52:44 UTC) #120
Alexei Svitkine (slow)
lgtm https://codereview.chromium.org/2530573002/diff/720001/base/metrics/field_trial.cc File base/metrics/field_trial.cc (right): https://codereview.chromium.org/2530573002/diff/720001/base/metrics/field_trial.cc#newcode829 base/metrics/field_trial.cc:829: if (!global_) On 2016/11/29 19:52:44, lawrencewu wrote: > ...
4 years ago (2016-11-29 20:19:28 UTC) #121
lawrencewu
Address nits and had to move a comment down since git cl format was forcing ...
4 years ago (2016-11-29 20:32:55 UTC) #125
lawrencewu
Add check back https://codereview.chromium.org/2530573002/diff/720001/base/metrics/field_trial.cc File base/metrics/field_trial.cc (right): https://codereview.chromium.org/2530573002/diff/720001/base/metrics/field_trial.cc#newcode829 base/metrics/field_trial.cc:829: if (!global_) On 2016/11/29 20:19:27, Alexei ...
4 years ago (2016-11-29 21:40:18 UTC) #130
Alexei Svitkine (slow)
OK, still lgtm
4 years ago (2016-11-29 21:44:17 UTC) #132
lawrencewu
jochen@: friendly ping
4 years ago (2016-11-30 14:47:44 UTC) #135
jochen (gone - plz use gerrit)
lgtm
4 years ago (2016-11-30 14:58:07 UTC) #136
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2530573002/670009
4 years ago (2016-11-30 14:59:30 UTC) #138
commit-bot: I haz the power
Committed patchset #41 (id:670009)
4 years ago (2016-11-30 16:25:38 UTC) #141
commit-bot: I haz the power
4 years ago (2016-11-30 16:28:43 UTC) #143
Message was sent while issue was closed.
Patchset 41 (id:??) landed as
https://crrev.com/c4fe88004d0457cf00b1731c1e974c96a3cd649e
Cr-Commit-Position: refs/heads/master@{#435284}

Powered by Google App Engine
This is Rietveld 408576698