Merge "Strip Pitot links in public version of API Council caching guidelines" into main
diff --git a/api-guidelines/caching.md b/api-guidelines/caching.md index eac464d..466a415 100644 --- a/api-guidelines/caching.md +++ b/api-guidelines/caching.md
@@ -1,12 +1,5 @@ # Android API client-side caching guidelines -go/android-api-caching - -<!--* -# Document freshness: For more information, see go/fresh-source. -freshness: { owner: 'shayba' reviewed: '2024-07-04' } -*--> - [TOC] ## Motivation @@ -375,57 +368,3 @@ } } ``` - -## Review binder telemetry - -Data from droidfood and beta population can help you identify caching -opportunities, or opportunities to improve the efficacy of existing caches -through tuning. - -### Binder call counts and latencies - -Look in -[Pitot Binder metrics](https://apconsole.corp.google.com/u/0/metric_index?release=dogfood-group:Trunk%20Releases&comparison=target&device_view=standard_next&duration=28) -for trace-based metrics on binder call counts and binder call latencies. Binder -interfaces with a high volume of calls or a high latency per call are good -candidates for caching, provided that they meet the other properties listed -above. - -You will find this page particularly helpful: -[distribution of binder calls count on battery](https://apconsole.corp.google.com/u/0/metric_detail/901?release=dogfood-group:Trunk%20Releases&comparison=target&device_view=standard_next&duration=28&timeline.hideSessionThreshold=0&appLaunches=2,4,3,5,6,7) - -Additionally, you can use the go/trace-binder-spam dashboard to find examples of -binder spam from field traces. Once you found a spammed interface, you can open -associated traces to find relevant anecdotes that you can study in detail. - - - -In the screenshot above we see a list of interfaces ordered by highest calls -count first. You will notice that there are several `IPackageManager` -interfaces. Some, like `setComponentEnabledSetting`, are not candidates for -caching because they are mutative. Others, like `hasSystemFeature`, are -excellent candidates for caching, since they read a property with a clear -lifetime definition. - -### Cache sizes - -The -[Java heap classes](https://apconsole.corp.google.com/u/0/memory/java_heap_classes?release=dogfood-group:Trunk%20Releases&comparison=target&device_view=standard_next&duration=28&process=system_server) -dashboard can be used to find examples where a cache is dominating more memory -than is expected, and suggest tuning opportunities. - - - -In the screenshot above we see heap dumps with high amounts of memory retained -by an inner class of `PropertyInvalidatedCache`. Click on a heap dump to see a -dominator tree. - - - -In the screenshot above we see the dominator tree for a particular heap dump. -Notice that you can see a large cache in `ChangeIdStateCache`, and another in -`PermissionManager`. Are these sizes expected, or too large? - -Recall that you can also inspect the cache hit rate at runtime using `adb shell -dumpsys cacheinfo`. A large cache doesn't necessarily mean that the hit rate is -high.