Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
XDK Heap Profiler collector and XDK CPUProfiler
improvement: adding total time to CPU profiler This commit is squashed from several commits and correspond for two big features: 1. XDK heap profiler collector 2. CpuProfiler: Annotation of source lines by total time in CPU Profiler this feature is in the process of upstream to chromium: https://codereview.chromium.org/1477623003/ -- feature 1: This heap profiler allows to perform deepper analysis of the JavaScript objects and is more concentrated on the allocation point of the object. Here are main deifference between CDT and XDK heap profilers: 1. CDT Heap Profiler care of the alive objects, XDK collects all info even for released ones. This allows to show the allocation chart of objects which are used by the app in each moment. Neither CDT Timeline nor CDT Heap Profiler don't allow doing this. CDT Timeline shows the whole pool size which is much more than currently refered objects, CDT Heap Profiler shows only bars of allocated and alive objects by the end of collection. The drawback of this approach - we have to call garbage collection regularly. On the other hand CDT Heap Profiler calls Garbage Collection the same way. 2. To reduce the amount of information XDK profiler groups the objects to buckets with unique key including the allocation time, release time, type, allocation call site. This allow to select any period on the timeline and analyze which objects are allocated and not released by the end of the collection. This analysis type is useful in case of big memory spikes. Just need to select on the chart where this spike starts till the maximum of the allocation memory. 3. The allocation callsite allows to annotate the sources by the self and total values of allocated memory. And it's useful to know that certain line calling library function implicitly allocates and retains megabates of data. 4. Like in CDT, XDK profiler can collect the object's retention information, but this info is stored for allocation callsite/type. It is done because we don't show unique objects and we have to show all retentions for group. It's not such efficient like for unique objects but also has a value. -- feature 2: CpuProfiler: Annotation of source lines by total time in CPU Profiler upstream to chromium: https://codereview.chromium.org/1477623003/ This patch adds source lines annotations by total time values for the CPU profile. This functionality is required for XDK CPU profiling feature and can be used for CDT CPU profiling feature after frontend modification. For source lines annotation by total time was added new StackEntry structure that substitutes CodeEntry class inside CPU profiling collection. StackEntry structure includes a pointer to CodeEntry object and source line where certain sample happened or the callee function was called. This allows recording source line number for each node in the call tree. Previously, the source line was recorded only for the sample place, so we were not able to recover source lines of caller, that prevented calculating total time for source lines. Thus the parsing stack functions use StackEntry's instances instead of CodeEntry. To store them in the hash was changed the hash function. It starts using not only CodeEntry, but also source line. Currently it looks like: CodeEntryHash(old function for calculating hash) XOR (source_line from StackEntry structure). It is needed for separation of equal CodeEntries with different source lines. Efficiency of the new hash function was checked in a separate test and obtained even better distribution inside HashMap than with the old function. These changes don't affect current CPU profiling results under CDT. The call tree stay the same because frontend merges the Nodes in the tree by CodeEntry hash only. And the source view is not annotated by the lines because it's an open question how to do this properly for CDT views. CDT frontend should be extended to support both self-time annotations of the source lines and total times annotation. Regarding transferring results to the frontend: these changes are transmitted to the frontend by adding new parameter src_line in ProfileNode token in the JSON based package. Were added wrappers for several functions which accept StackEntry by the functions, which accept old CodeEntry values to support existing tests. The new test for this functionality was added to 'test-profile-generator'
- Loading branch information