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

Issue 1001343002: Prefetch the native library from native code by parsing /proc/pid/maps. (Closed)

Created:
5 years, 9 months ago by Benoit L
Modified:
5 years, 7 months ago
CC:
chromium-reviews, darin-cc_chromium.org, erikwright+watch_chromium.org, petrcermak
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Prefetch the native library from native code by parsing /proc/pid/maps. Prefetching the native library by reading its pages speeds up startup on Android (see the linked bug). When loading the native library from the APK, there is no file to associate with the native library. The most reliable way to prefetch the native library pages is then to look at the pages mapped in the process address space after the native library has been loaded. To minimize disruption, the prefetch is done in a separate forked process. This patch implements the parsing of the address space mappings and the reading of pages from a forked process. Most of the work is done before the fork() to avoid potential nasty issues associated with doing work in a forked process in presence of threads. BUG=460438 Committed: https://crrev.com/0a830d2548468ecbfb324644b7ecf9ddb46d4b42 Cr-Commit-Position: refs/heads/master@{#327473}

Patch Set 1 #

Patch Set 2 : Don't rely on third party code that is not always there to parse /proc/pid/maps. #

Patch Set 3 : Typo. #

Patch Set 4 : . #

Patch Set 5 : clang format. #

Patch Set 6 : . #

Patch Set 7 : . #

Total comments: 22

Patch Set 8 : Address comments. #

Total comments: 33

Patch Set 9 : Address comments. #

Patch Set 10 : . #

Patch Set 11 : Make the current prefetching a fallback in case forking goes wrong. #

Patch Set 12 : Typo. #

Total comments: 6

Patch Set 13 : Address comments. #

Total comments: 41

Patch Set 14 : Address comments. #

Total comments: 2

Patch Set 15 : Address comments. #

Patch Set 16 : . #

Total comments: 10

Patch Set 17 : Address comments, separate function, add tests to it. #

Patch Set 18 : Re-use existing /proc/maps parsing code. #

Total comments: 10

Patch Set 19 : Address comments. #

Total comments: 4

Patch Set 20 : Move comment and disallow construction. #

Total comments: 15

Patch Set 21 : . #

Patch Set 22 : Remove the fallback, add a TODO for a UMA count of failures. #

Patch Set 23 : . #

Patch Set 24 : Add GN files. #

Patch Set 25 : . #

Patch Set 26 : Missing BASE_EXPORT. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+335 lines, -65 lines) Patch
M base/BUILD.gn 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 2 chunks +3 lines, -0 lines 0 comments Download
M base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 9 chunks +12 lines, -65 lines 0 comments Download
M base/android/library_loader/library_loader_hooks.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +5 lines, -0 lines 0 comments Download
A base/android/library_loader/library_prefetcher.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 1 chunk +67 lines, -0 lines 0 comments Download
A base/android/library_loader/library_prefetcher.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 +150 lines, -0 lines 0 comments Download
A base/android/library_loader/library_prefetcher_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 chunk +95 lines, -0 lines 0 comments Download
M base/base.gyp 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 1 chunk +1 line, -0 lines 0 comments Download
M base/base.gypi 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 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 58 (10 generated)
rmcilroy
+petrcermak Just to let you know that Petr is working on a refactor of the ...
5 years, 9 months ago (2015-03-18 15:15:02 UTC) #2
rmcilroy
+petrcermak Just to let you know that Petr is working on a refactor of the ...
5 years, 9 months ago (2015-03-18 15:15:02 UTC) #3
Benoit L
Hello, Please review this patch. Sorry about its size, but a lot of it is ...
5 years, 9 months ago (2015-03-23 13:23:11 UTC) #5
petrcermak
A couple of (mostly style) comments. https://codereview.chromium.org/1001343002/diff/110001/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java File base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java (right): https://codereview.chromium.org/1001343002/diff/110001/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java#newcode577 base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java:577: // Finds the ...
5 years, 9 months ago (2015-03-23 15:00:48 UTC) #7
Benoit L
Thank you, all done. https://codereview.chromium.org/1001343002/diff/110001/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java File base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java (right): https://codereview.chromium.org/1001343002/diff/110001/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java#newcode577 base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java:577: // Finds the ranges corresponding ...
5 years, 9 months ago (2015-03-23 16:41:58 UTC) #8
rmcilroy
Seems reasonable overall - a couple of comments. https://codereview.chromium.org/1001343002/diff/130001/base/android/library_loader/library_prefetcher.cc File base/android/library_loader/library_prefetcher.cc (right): https://codereview.chromium.org/1001343002/diff/130001/base/android/library_loader/library_prefetcher.cc#newcode44 base/android/library_loader/library_prefetcher.cc:44: std::string* ...
5 years, 9 months ago (2015-03-24 15:18:26 UTC) #9
pasko
reasonable but a bit intense on iterators to my taste, see below https://codereview.chromium.org/1001343002/diff/130001/base/android/library_loader/library_prefetcher.cc File base/android/library_loader/library_prefetcher.cc ...
5 years, 9 months ago (2015-03-24 17:10:36 UTC) #10
Benoit L
Hello, Thank you for the review. I made changes to: - Avoid using C library ...
5 years, 9 months ago (2015-03-25 10:36:19 UTC) #11
pasko
just one comment, looking further https://codereview.chromium.org/1001343002/diff/130001/base/android/library_loader/library_prefetcher.cc File base/android/library_loader/library_prefetcher.cc (right): https://codereview.chromium.org/1001343002/diff/130001/base/android/library_loader/library_prefetcher.cc#newcode136 base/android/library_loader/library_prefetcher.cc:136: ranges.push_back(std::make_pair(start, end)); On 2015/03/25 ...
5 years, 9 months ago (2015-03-25 12:40:53 UTC) #12
pasko
https://codereview.chromium.org/1001343002/diff/210001/base/android/library_loader/library_prefetcher.cc File base/android/library_loader/library_prefetcher.cc (right): https://codereview.chromium.org/1001343002/diff/210001/base/android/library_loader/library_prefetcher.cc#newcode62 base/android/library_loader/library_prefetcher.cc:62: if ((pieces_count != 5) && (pieces_count != 6)) { ...
5 years, 9 months ago (2015-03-25 12:57:58 UTC) #13
rmcilroy
https://codereview.chromium.org/1001343002/diff/130001/base/android/library_loader/library_prefetcher.cc File base/android/library_loader/library_prefetcher.cc (right): https://codereview.chromium.org/1001343002/diff/130001/base/android/library_loader/library_prefetcher.cc#newcode136 base/android/library_loader/library_prefetcher.cc:136: ranges.push_back(std::make_pair(start, end)); On 2015/03/25 10:36:18, lizeb wrote: > On ...
5 years, 9 months ago (2015-03-25 15:12:18 UTC) #14
Benoit L
Hello, - Simplified the code (removing the iterators) - Added logging when the child process ...
5 years, 8 months ago (2015-03-26 15:45:03 UTC) #15
pasko
some more high level thoughts https://codereview.chromium.org/1001343002/diff/230001/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java File base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java (right): https://codereview.chromium.org/1001343002/diff/230001/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java#newcode259 base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java:259: // Note: AsyncTasks are ...
5 years, 8 months ago (2015-03-27 11:03:37 UTC) #16
pasko
looked through the rest of files, neat stuff https://codereview.chromium.org/1001343002/diff/230001/base/android/library_loader/library_prefetcher.cc File base/android/library_loader/library_prefetcher.cc (right): https://codereview.chromium.org/1001343002/diff/230001/base/android/library_loader/library_prefetcher.cc#newcode23 base/android/library_loader/library_prefetcher.cc:23: // ...
5 years, 8 months ago (2015-03-27 13:29:28 UTC) #17
Benoit L
Thank you for the thorough review. https://codereview.chromium.org/1001343002/diff/230001/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java File base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java (right): https://codereview.chromium.org/1001343002/diff/230001/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java#newcode259 base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java:259: // Note: AsyncTasks ...
5 years, 8 months ago (2015-03-27 15:44:52 UTC) #18
pasko
On 2015/03/27 13:29:28, pasko wrote: > https://codereview.chromium.org/1001343002/diff/230001/base/android/library_loader/library_prefetcher.h#newcode41 > base/android/library_loader/library_prefetcher.h:41: // Returns true if we > ...
5 years, 8 months ago (2015-03-27 17:42:34 UTC) #19
pasko
almost there https://codereview.chromium.org/1001343002/diff/230001/base/android/library_loader/library_prefetcher.cc File base/android/library_loader/library_prefetcher.cc (right): https://codereview.chromium.org/1001343002/diff/230001/base/android/library_loader/library_prefetcher.cc#newcode45 base/android/library_loader/library_prefetcher.cc:45: // For each range, reads a byte ...
5 years, 8 months ago (2015-03-27 17:51:55 UTC) #20
Benoit L
All done, thank you. https://codereview.chromium.org/1001343002/diff/250001/base/android/library_loader/library_prefetcher.cc File base/android/library_loader/library_prefetcher.cc (right): https://codereview.chromium.org/1001343002/diff/250001/base/android/library_loader/library_prefetcher.cc#newcode95 base/android/library_loader/library_prefetcher.cc:95: // you're looking for. On ...
5 years, 8 months ago (2015-03-30 15:12:49 UTC) #21
pasko
sorry to ask for a little more testing on the late stage of the review, ...
5 years, 8 months ago (2015-03-31 12:01:43 UTC) #22
Benoit L
All done, thank you. https://codereview.chromium.org/1001343002/diff/290001/base/android/library_loader/library_prefetcher.cc File base/android/library_loader/library_prefetcher.cc (right): https://codereview.chromium.org/1001343002/diff/290001/base/android/library_loader/library_prefetcher.cc#newcode53 base/android/library_loader/library_prefetcher.cc:53: unsigned char* start_address = (unsigned ...
5 years, 8 months ago (2015-03-31 14:00:01 UTC) #23
Robert Sesek
Drive by: I was wondering if you had seen/considered using this code to parse proc ...
5 years, 8 months ago (2015-03-31 15:42:49 UTC) #25
pasko
On 2015/03/31 15:42:49, Robert Sesek wrote: > Drive by: I was wondering if you had ...
5 years, 8 months ago (2015-04-01 12:37:16 UTC) #26
chromium-reviews
Hello, Thank you for the suggestion. As Egor said, I didn't reuse this code to ...
5 years, 8 months ago (2015-04-01 12:49:31 UTC) #27
pasko
lgtm (i.e. looks good to me in the current sate; as usual, sticky only with ...
5 years, 8 months ago (2015-04-01 13:01:39 UTC) #28
pasko
Ross, can you please take another look?
5 years, 8 months ago (2015-04-01 13:02:05 UTC) #29
Robert Sesek
On 2015/04/01 12:37:16, pasko wrote: > On 2015/03/31 15:42:49, Robert Sesek wrote: > > Drive ...
5 years, 8 months ago (2015-04-01 15:11:09 UTC) #30
Benoit L
On 2015/04/01 15:11:09, Robert Sesek wrote: > On 2015/04/01 12:37:16, pasko wrote: > > On ...
5 years, 8 months ago (2015-04-01 16:55:41 UTC) #31
rmcilroy
> Ross, can you please take another look? Let me know when you've uploaded the ...
5 years, 8 months ago (2015-04-02 10:03:53 UTC) #32
pasko
lgtm with a couple of small changes https://codereview.chromium.org/1001343002/diff/330001/base/android/library_loader/library_prefetcher.h File base/android/library_loader/library_prefetcher.h (right): https://codereview.chromium.org/1001343002/diff/330001/base/android/library_loader/library_prefetcher.h#newcode11 base/android/library_loader/library_prefetcher.h:11: #include <sys/types.h> ...
5 years, 8 months ago (2015-04-02 15:50:36 UTC) #33
pasko
On 2015/04/02 10:03:53, rmcilroy wrote: > > Ross, can you please take another look? > ...
5 years, 8 months ago (2015-04-02 15:51:20 UTC) #34
Robert Sesek
https://codereview.chromium.org/1001343002/diff/330001/base/android/library_loader/library_prefetcher.cc File base/android/library_loader/library_prefetcher.cc (right): https://codereview.chromium.org/1001343002/diff/330001/base/android/library_loader/library_prefetcher.cc#newcode36 base/android/library_loader/library_prefetcher.cc:36: for (int i = 0; i < kSuffixesToMatchCount; i++) ...
5 years, 8 months ago (2015-04-02 15:58:03 UTC) #35
Benoit L
All done, thank you! https://codereview.chromium.org/1001343002/diff/330001/base/android/library_loader/library_prefetcher.cc File base/android/library_loader/library_prefetcher.cc (right): https://codereview.chromium.org/1001343002/diff/330001/base/android/library_loader/library_prefetcher.cc#newcode36 base/android/library_loader/library_prefetcher.cc:36: for (int i = 0; ...
5 years, 8 months ago (2015-04-02 16:43:48 UTC) #36
Robert Sesek
Nice, just two small things. https://codereview.chromium.org/1001343002/diff/350001/base/android/library_loader/library_prefetcher.cc File base/android/library_loader/library_prefetcher.cc (right): https://codereview.chromium.org/1001343002/diff/350001/base/android/library_loader/library_prefetcher.cc#newcode118 base/android/library_loader/library_prefetcher.cc:118: // Forks and waits ...
5 years, 8 months ago (2015-04-02 19:46:48 UTC) #37
Benoit L
Done, thank you! https://codereview.chromium.org/1001343002/diff/350001/base/android/library_loader/library_prefetcher.cc File base/android/library_loader/library_prefetcher.cc (right): https://codereview.chromium.org/1001343002/diff/350001/base/android/library_loader/library_prefetcher.cc#newcode118 base/android/library_loader/library_prefetcher.cc:118: // Forks and waits for a ...
5 years, 8 months ago (2015-04-03 09:47:16 UTC) #38
Robert Sesek
LGTM
5 years, 8 months ago (2015-04-03 20:35:32 UTC) #39
rmcilroy
Sorry for the delay (vacation and traveling now). Code looks reasonable, however I'm a bit ...
5 years, 8 months ago (2015-04-07 12:17:27 UTC) #40
Benoit L
Hello, I have updated the CL to address your comments. I still think that forking ...
5 years, 8 months ago (2015-04-16 13:28:48 UTC) #41
rmcilroy
Sorry for the delay. Generally looks fine now, but let's remove the fallback. https://codereview.chromium.org/1001343002/diff/370001/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java File ...
5 years, 8 months ago (2015-04-23 15:09:43 UTC) #42
Benoit L
Done, thank you. The histogram will be in a forthcoming CL. https://codereview.chromium.org/1001343002/diff/370001/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java File base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java (right): ...
5 years, 8 months ago (2015-04-24 14:24:36 UTC) #43
pasko
still lgtm
5 years, 8 months ago (2015-04-24 14:44:46 UTC) #44
rmcilroy
Lgtm, thanks!
5 years, 8 months ago (2015-04-24 19:45:21 UTC) #45
Benoit L
Hello jam. Please review (for OWNERS approval) the base/*.{gyp,gypi,gn} changes in this CL. Thank you!
5 years, 7 months ago (2015-04-27 16:37:44 UTC) #47
jam
On 2015/04/27 16:37:44, lizeb wrote: > Hello jam. > > Please review (for OWNERS approval) ...
5 years, 7 months ago (2015-04-27 21:38:21 UTC) #48
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1001343002/470001
5 years, 7 months ago (2015-04-28 14:09:16 UTC) #51
commit-bot: I haz the power
Try jobs failed on following builders: android_clang_dbg_recipe on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/android_clang_dbg_recipe/builds/71147)
5 years, 7 months ago (2015-04-28 14:57:31 UTC) #53
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1001343002/490001
5 years, 7 months ago (2015-04-29 10:43:58 UTC) #56
commit-bot: I haz the power
Committed patchset #26 (id:490001)
5 years, 7 months ago (2015-04-29 11:52:03 UTC) #57
commit-bot: I haz the power
5 years, 7 months ago (2015-04-29 11:53:00 UTC) #58
Message was sent while issue was closed.
Patchset 26 (id:??) landed as
https://crrev.com/0a830d2548468ecbfb324644b7ecf9ddb46d4b42
Cr-Commit-Position: refs/heads/master@{#327473}

Powered by Google App Engine
This is Rietveld 408576698