|
|
Created:
4 years, 9 months ago by Alexei Svitkine (slow) Modified:
4 years, 8 months ago Reviewers:
nyquist CC:
chromium-reviews, asvitkine+watch_chromium.org Base URL:
https://chromium.googlesource.com/chromium/src.git@master Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionRewrite Java histograms API implementation.
The previous version used System.identityHashCode() as a key to
cache histogram objects - but we've found that this is not safe
to do because there may be collisions.
Instead, this CL changes the code to do the caching on the Java
side, keeping pointers to the C++ Histogram objects in the cache.
This is safe to do because histogram objects are never freed, so the
pointers are guaranteed to stay valid.
BUG=535043
Committed: https://crrev.com/0f5bc5e0075fb1d3ca46bb109d6e4799b7b165e5
Cr-Commit-Position: refs/heads/master@{#385310}
Patch Set 1 : #
Total comments: 6
Patch Set 2 : Address comments. #
Messages
Total messages: 26 (16 generated)
Patchset #3 (id:40001) has been deleted
Patchset #2 (id:20001) has been deleted
Description was changed from ========== Rewrite Java histograms API implementation. The previous version used System.identityHashCode() as a key to cache histogram objects - but we've found that this is not safe to do because there may be collisions. Instead, this CL changes the code to do the caching on the Java side, keeping pointers to the C++ Histogram objects in the cache. This is safe to do because histogram objects are never freed, so the pointers are guaranteed to stay valid. BUG= ========== to ========== Rewrite Java histograms API implementation. The previous version used System.identityHashCode() as a key to cache histogram objects - but we've found that this is not safe to do because there may be collisions. Instead, this CL changes the code to do the caching on the Java side, keeping pointers to the C++ Histogram objects in the cache. This is safe to do because histogram objects are never freed, so the pointers are guaranteed to stay valid. BUG=535043 ==========
Patchset #3 (id:80001) has been deleted
Patchset #2 (id:60001) has been deleted
Patchset #2 (id:100001) has been deleted
Patchset #1 (id:1) has been deleted
Patchset #1 (id:120001) has been deleted
Patchset #2 (id:160001) has been deleted
Patchset #1 (id:140001) has been deleted
asvitkine@chromium.org changed reviewers: + nyquist@chromium.org
The CQ bit was checked by asvitkine@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1828293002/180001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1828293002/180001
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Friendly ping! For context, see the bug - the current implementation is not correct per its assumptions about system.identityhashcode.
thanks for writing a very thorough and explanatory CL description. https://codereview.chromium.org/1828293002/diff/180001/base/android/java/src/... File base/android/java/src/org/chromium/base/metrics/RecordHistogram.java (right): https://codereview.chromium.org/1828293002/diff/180001/base/android/java/src/... base/android/java/src/org/chromium/base/metrics/RecordHistogram.java:36: private static long getCachedHistogramKey(String name) { Could you add a short comment about what returning 0 entails and how native reacts to that here? https://codereview.chromium.org/1828293002/diff/180001/base/android/java/src/... base/android/java/src/org/chromium/base/metrics/RecordHistogram.java:38: return (key != null ? key : 0); Nit: I personally think it reads better to use == instead of !=. https://codereview.chromium.org/1828293002/diff/180001/base/android/record_hi... File base/android/record_histogram.cc (right): https://codereview.chromium.org/1828293002/diff/180001/base/android/record_hi... base/android/record_histogram.cc:188: static HistogramBase* HistogramFromKey(jlong j_histogram_key) { I think this deserves a short comment for new readers about why this works. You have a good explanation in your CL description.
Comments addressed. PTAL. https://codereview.chromium.org/1828293002/diff/180001/base/android/java/src/... File base/android/java/src/org/chromium/base/metrics/RecordHistogram.java (right): https://codereview.chromium.org/1828293002/diff/180001/base/android/java/src/... base/android/java/src/org/chromium/base/metrics/RecordHistogram.java:36: private static long getCachedHistogramKey(String name) { On 2016/04/01 21:37:14, nyquist wrote: > Could you add a short comment about what returning 0 entails and how native > reacts to that here? Done. https://codereview.chromium.org/1828293002/diff/180001/base/android/java/src/... base/android/java/src/org/chromium/base/metrics/RecordHistogram.java:38: return (key != null ? key : 0); On 2016/04/01 21:37:14, nyquist wrote: > Nit: I personally think it reads better to use == instead of !=. Done. https://codereview.chromium.org/1828293002/diff/180001/base/android/record_hi... File base/android/record_histogram.cc (right): https://codereview.chromium.org/1828293002/diff/180001/base/android/record_hi... base/android/record_histogram.cc:188: static HistogramBase* HistogramFromKey(jlong j_histogram_key) { On 2016/04/01 21:37:14, nyquist wrote: > I think this deserves a short comment for new readers about why this works. You > have a good explanation in your CL description. Done. Also expanded the description on the Java class.
lgtm
The CQ bit was checked by asvitkine@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1828293002/200001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1828293002/200001
Message was sent while issue was closed.
Description was changed from ========== Rewrite Java histograms API implementation. The previous version used System.identityHashCode() as a key to cache histogram objects - but we've found that this is not safe to do because there may be collisions. Instead, this CL changes the code to do the caching on the Java side, keeping pointers to the C++ Histogram objects in the cache. This is safe to do because histogram objects are never freed, so the pointers are guaranteed to stay valid. BUG=535043 ========== to ========== Rewrite Java histograms API implementation. The previous version used System.identityHashCode() as a key to cache histogram objects - but we've found that this is not safe to do because there may be collisions. Instead, this CL changes the code to do the caching on the Java side, keeping pointers to the C++ Histogram objects in the cache. This is safe to do because histogram objects are never freed, so the pointers are guaranteed to stay valid. BUG=535043 ==========
Message was sent while issue was closed.
Committed patchset #2 (id:200001)
Message was sent while issue was closed.
Description was changed from ========== Rewrite Java histograms API implementation. The previous version used System.identityHashCode() as a key to cache histogram objects - but we've found that this is not safe to do because there may be collisions. Instead, this CL changes the code to do the caching on the Java side, keeping pointers to the C++ Histogram objects in the cache. This is safe to do because histogram objects are never freed, so the pointers are guaranteed to stay valid. BUG=535043 ========== to ========== Rewrite Java histograms API implementation. The previous version used System.identityHashCode() as a key to cache histogram objects - but we've found that this is not safe to do because there may be collisions. Instead, this CL changes the code to do the caching on the Java side, keeping pointers to the C++ Histogram objects in the cache. This is safe to do because histogram objects are never freed, so the pointers are guaranteed to stay valid. BUG=535043 Committed: https://crrev.com/0f5bc5e0075fb1d3ca46bb109d6e4799b7b165e5 Cr-Commit-Position: refs/heads/master@{#385310} ==========
Message was sent while issue was closed.
Patchset 2 (id:??) landed as https://crrev.com/0f5bc5e0075fb1d3ca46bb109d6e4799b7b165e5 Cr-Commit-Position: refs/heads/master@{#385310} |