已合并
docs: hidebug 补充 ProfilerOptions 扩展配置接口说明 #160539
王俊龙创建于 24 天前
docs: hidebug 补充 ProfilerOptions 扩展配置接口说明 #160539
已合并
共 5 个文件变更+325-15
| @@ -368,6 +368,16 @@ HiDebug提供修改转储堆快照级别的接口。 | |||
| 368 | |--------|------| | 368 | |--------|------| |
| 369 | | OH_HiDebug_StartProfiler | 按指定类型启动资源分配栈信息采集,须与OH_HiDebug_StopProfiler配对使用。<br/>**说明**:从API version 24开始,支持该接口。 | | 369 | | OH_HiDebug_StartProfiler | 按指定类型启动资源分配栈信息采集,须与OH_HiDebug_StopProfiler配对使用。<br/>**说明**:从API version 24开始,支持该接口。 | |
| 370 | | OH_HiDebug_StopProfiler | 停止资源分配栈信息采集,须与OH_HiDebug_StartProfiler配对使用。<br/>**说明**:从API version 24开始,支持该接口。 | | 370 | | OH_HiDebug_StopProfiler | 停止资源分配栈信息采集,须与OH_HiDebug_StartProfiler配对使用。<br/>**说明**:从API version 24开始,支持该接口。 | |
| 371 | +| OH_HiDebug_CreateProfilerOptions | 创建资源Profiler配置对象。须与OH_HiDebug_DestroyProfilerOptions配对使用。<br/>**说明**:从API版本26.1.0开始,支持该接口。 | | ||
| 372 | +| OH_HiDebug_DestroyProfilerOptions | 释放通过OH_HiDebug_CreateProfilerOptions创建的配置对象。<br/>**说明**:从API版本26.1.0开始,支持该接口。 | | ||
| 373 | +| OH_HiDebug_SetMaxAsyncNestingDepth | 设置异步调用最大嵌套深度(也称为最大嵌套层数)。<br/>**说明**:从API版本26.1.0开始,支持该接口。 | | ||
| 374 | +| OH_HiDebug_SetMaxAsyncTaskStackDepth | 设置异步任务函数的最大回栈深度。<br/>**说明**:从API版本26.1.0开始,支持该接口。 | | ||
| 375 | +| OH_HiDebug_SetSampleIntervalBytes | 设置采样间隔,单位字节。<br/>**说明**:从API版本26.1.0开始,支持该接口。 | | ||
| 376 | +| OH_HiDebug_SetStatisticsIntervalSec | 设置统计间隔,单位秒。<br/>**说明**:从API版本26.1.0开始,支持该接口。 | | ||
| 377 | +| OH_HiDebug_SetMaxStackDepth | 设置最大回栈深度。<br/>**说明**:从API版本26.1.0开始,支持该接口。 | | ||
| 378 | +| OH_HiDebug_SetFilterSize | 设置内存分配过滤大小。<br/>**说明**:从API版本26.1.0开始,支持该接口。 | | ||
| 379 | +| OH_HiDebug_SetMaxDurationSec | 设置最大采集时长,单位秒。<br/>**说明**:从API版本26.1.0开始,支持该接口。 | | ||
| 380 | +| OH_HiDebug_StartProfilerWithOptions | 按指定资源类型和配置开启资源分配栈信息采集。须与OH_HiDebug_StopProfiler配对使用。<br/>**说明**:从API版本26.1.0开始,支持该接口。 | | ||
| 371 | 381 | ||
| 372 | ## 导出内存快照 | 382 | ## 导出内存快照 |
| 373 | 383 | ||
| @@ -66,6 +66,7 @@ | |||
| 66 | - [HiDebug_ProcessSamplerConfig](capi-hidebug-hidebug-processsamplerconfig.md) | 66 | - [HiDebug_ProcessSamplerConfig](capi-hidebug-hidebug-processsamplerconfig.md) |
| 67 | - [OH_HiDebug_ResProfilerConfig](capi-hidebug-oh-hidebug-resprofilerconfig.md) | 67 | - [OH_HiDebug_ResProfilerConfig](capi-hidebug-oh-hidebug-resprofilerconfig.md) |
| 68 | - [OH_HiDebug_ProfilingResult](capi-hidebug-oh-hidebug-profilingresult.md) | 68 | - [OH_HiDebug_ProfilingResult](capi-hidebug-oh-hidebug-profilingresult.md) |
| 69 | + - [OH_HiDebug_ProfilerOptions](capi-hidebug-oh-hidebug-profileroptions.md) | ||
| 69 | - [HiTraceId](capi-hitrace-hitraceid.md) | 70 | - [HiTraceId](capi-hitrace-hitraceid.md) |
| 70 | - 错误码<!--performance-analysis-errcode--> | 71 | - 错误码<!--performance-analysis-errcode--> |
| 71 | - [Faultlogger错误码](errorcode-faultlogger.md) | 72 | - [Faultlogger错误码](errorcode-faultlogger.md) |
| @@ -23,6 +23,12 @@ | |||
| 23 | 23 | ||
| 24 | ## 汇总 | 24 | ## 汇总 |
| 25 | 25 | ||
| 26 | +### 结构体 | ||
| 27 | + | ||
| 28 | +| 名称 | typedef关键字 | 描述 | | ||
| 29 | +| -- | -- | -- | | ||
| 30 | +| [OH_HiDebug_ProfilerOptions](capi-hidebug-oh-hidebug-profileroptions.md) | OH_HiDebug_ProfilerOptions | 资源采集配置结构体前向声明。 | | ||
| 31 | + | ||
| 26 | ### 函数 | 32 | ### 函数 |
| 27 | 33 | ||
| 28 | | 名称 | typedef关键字 | 描述 | | 34 | | 名称 | typedef关键字 | 描述 | |
| @@ -61,6 +67,16 @@ | |||
| 61 | | [void OH_HiDebug_PushAsyncContext(uint64_t ctx)](#oh_hidebug_pushasynccontext) | - | Profiler辅助接口,将AsyncContext压入运行上下文栈表。 | | 67 | | [void OH_HiDebug_PushAsyncContext(uint64_t ctx)](#oh_hidebug_pushasynccontext) | - | Profiler辅助接口,将AsyncContext压入运行上下文栈表。 | |
| 62 | | [void OH_HiDebug_PopAsyncContext(uint64_t ctx)](#oh_hidebug_popasynccontext) | - | Profiler辅助接口,将AsyncContext从运行上下文栈表中弹出。 | | 68 | | [void OH_HiDebug_PopAsyncContext(uint64_t ctx)](#oh_hidebug_popasynccontext) | - | Profiler辅助接口,将AsyncContext从运行上下文栈表中弹出。 | |
| 63 | | [void OH_HiDebug_ReleaseAsyncContext(uint64_t ctx)](#oh_hidebug_releaseasynccontext) | - | Profiler辅助接口,将AsyncContext释放给系统。 | | 69 | | [void OH_HiDebug_ReleaseAsyncContext(uint64_t ctx)](#oh_hidebug_releaseasynccontext) | - | Profiler辅助接口,将AsyncContext释放给系统。 | |
| 70 | +| [OH_HiDebug_ProfilerOptions* OH_HiDebug_CreateProfilerOptions(void)](#oh_hidebug_createprofileroptions) | - | 创建资源Profiler配置对象。 | | ||
| 71 | +| [HiDebug_ErrorCode OH_HiDebug_DestroyProfilerOptions(OH_HiDebug_ProfilerOptions* opts)](#oh_hidebug_destroyprofileroptions) | - | 释放通过[OH_HiDebug_CreateProfilerOptions](capi-hidebug-h.md#oh_hidebug_createprofileroptions)创建的配置对象。 | | ||
| 72 | +| [HiDebug_ErrorCode OH_HiDebug_SetMaxAsyncNestingDepth(OH_HiDebug_ProfilerOptions* opts, uint32_t depth)](#oh_hidebug_setmaxasyncnestingdepth) | - | 设置异步调用的最大嵌套深度(也称为最大嵌套层数)。 | | ||
| 73 | +| [HiDebug_ErrorCode OH_HiDebug_SetMaxAsyncTaskStackDepth(OH_HiDebug_ProfilerOptions* opts, uint32_t depth)](#oh_hidebug_setmaxasynctaskstackdepth) | - | 设置异步任务函数的最大回栈深度。 | | ||
| 74 | +| [HiDebug_ErrorCode OH_HiDebug_SetSampleIntervalBytes(OH_HiDebug_ProfilerOptions* opts, uint32_t bytes)](#oh_hidebug_setsampleintervalbytes) | - | 设置采样间隔,单位为Byte。 | | ||
| 75 | +| [HiDebug_ErrorCode OH_HiDebug_SetStatisticsIntervalSec(OH_HiDebug_ProfilerOptions* opts, uint32_t seconds)](#oh_hidebug_setstatisticsintervalsec) | - | 设置统计间隔,单位为s。 | | ||
| 76 | +| [HiDebug_ErrorCode OH_HiDebug_SetMaxStackDepth(OH_HiDebug_ProfilerOptions* opts, uint32_t depth)](#oh_hidebug_setmaxstackdepth) | - | 设置最大回栈深度。 | | ||
| 77 | +| [HiDebug_ErrorCode OH_HiDebug_SetFilterSize(OH_HiDebug_ProfilerOptions* opts, uint32_t size)](#oh_hidebug_setfiltersize) | - | 设置内存分配过滤大小。 | | ||
| 78 | +| [HiDebug_ErrorCode OH_HiDebug_SetMaxDurationSec(OH_HiDebug_ProfilerOptions* opts, uint32_t seconds)](#oh_hidebug_setmaxdurationsec) | - | 设置最大采集时长,单位为s。 | | ||
| 79 | +| [HiDebug_ErrorCode OH_HiDebug_StartProfilerWithOptions(OH_HiDebug_ResourceType type, OH_HiDebug_ProfilerOptions* opts, OH_HiDebug_ProfilingCallback callback)](#oh_hidebug_startprofilerwithoptions) | - | 按指定资源类型和配置开启当前进程资源分配栈信息采集功能。 | | ||
| 64 | 80 | ||
| 65 | ## 函数说明 | 81 | ## 函数说明 |
| 66 | 82 | ||
| @@ -603,15 +619,25 @@ HiDebug_ErrorCode OH_HiDebug_StartProfiler(OH_HiDebug_ResourceType type, OH_HiDe | |||
| 603 | 619 | ||
| 604 | 异步启动当前进程资源采集功能。<br>回调函数只在终止采集(含系统自动停止采集)时调用,其携带采集资源类型和采集文件路径。<br>若采集异常,则文件路径为NULL。 | 620 | 异步启动当前进程资源采集功能。<br>回调函数只在终止采集(含系统自动停止采集)时调用,其携带采集资源类型和采集文件路径。<br>若采集异常,则文件路径为NULL。 |
| 605 | 621 | ||
| 606 | -> **注意:** | 622 | +**规格和约束:** |
| 607 | -> | 623 | + |
| 608 | -> 1. 当前接口每24小时可调用10次; | 624 | +1. 采集配额限制:<br> |
| 609 | -> 2. 采集资源的目标进程仅支持调用接口进程本身; | 625 | + - 应用(单应用独享):每日最多可采集2次;同一时刻,最高支持应用内2个进程并行采集。<br> |
| 610 | -> 3. 系统CPU占用率超过70%或内存可用空间少于15%或存储可用空间少于15%时,接口将调用失败并返回对应错误码; | 626 | + - 进程(单进程独享):同一时刻,仅支持启动1个采集任务。<br> |
| 611 | -> 4. 当接口与命令行工具或系统采集任务发生冲突时,将调用失败,并返回相应的错误码; | 627 | + 以上配额限制仅对非debug应用生效,debug应用不受此约束。<br> |
| 612 | -> 5. 同一个应用如存在多个进程,此接口最多可同时启动4个; | 628 | +2. 系统负载熔断机制:<br> |
| 613 | -> 6. 采集结果将保存在应用沙箱/data/storage/el2/base/files/目录下,文件名为“资源采集类型-进程名-进程号-时间戳.htrace”。 | 629 | + 当系统触发以下任一负载保护条件时,API采集请求将被拒绝,并返回相应错误码:<br> |
| 614 | -> 7. 从API版本26.0.0开始,该接口将尽量丢弃已释放内存调用栈数据,减少采集文件大小,进一步降低采集过程中的性能开销。 | 630 | + - CPU限制:整机系统CPU占用率超过70%。<br> |
| 631 | + - 内存限制:整机系统可用内存低于2GB。<br> | ||
| 632 | + - 存储限制:整机系统可用存储空间低于存储阈值,阈值为系统总存储容量的3%与15GB中的较大值。<br> | ||
| 633 | +3. 并发冲突约束:<br> | ||
| 634 | + - 当API采集与命令行工具或系统采集任务发生冲突时,API采集请求将被拒绝,并返回相应错误码。<br> | ||
| 635 | +4. 采集结果保存:<br> | ||
| 636 | + - 存储路径:采集到的调用栈日志文件将自动保存在应用沙箱/data/storage/el2/base/files/目录下。<br> | ||
| 637 | + - 文件名规则:“资源采集类型-进程名-进程号-时间戳.htrace”。<br> | ||
| 638 | +5. 权限约束:<br> | ||
| 639 | + - 采集资源的目标进程仅支持调用接口进程本身,不支持跨进程采集。<br> | ||
| 640 | + | ||
| 615 | 641 | ||
| 616 | **起始版本:** 24 | 642 | **起始版本:** 24 |
| 617 | 643 | ||
| @@ -627,7 +653,7 @@ HiDebug_ErrorCode OH_HiDebug_StartProfiler(OH_HiDebug_ResourceType type, OH_HiDe | |||
| 627 | 653 | ||
| 628 | | 类型 | 说明 | | 654 | | 类型 | 说明 | |
| 629 | | -- | -- | | 655 | | -- | -- | |
| 630 | -| [HiDebug_ErrorCode](capi-hidebug-type-h.md#hidebug_errorcode) | 返回结果码:<br> HIDEBUG_RES_PROF_SUCCESS:启动资源采集成功。<br> HIDEBUG_RES_PROF_INVALID_ARG:资源采集参数无效。<br> HIDEBUG_RES_PROF_INVALID_MAX_DURATION:资源采集最大持续时间参数无效。<br> HIDEBUG_RES_PROF_INVALID_FILTER_SIZE:资源采集过滤大小参数无效。<br> HIDEBUG_RES_PROF_INVALID_MAX_STACK_DEPTH:资源采集最大回栈深度参数无效。<br> HIDEBUG_RES_PROF_INVALID_STATISTICS_INTERVAL:资源采集统计间隔参数无效。<br> HIDEBUG_RES_PROF_INVALID_SAMPLE_INTERVAL:资源采集采样大小参数无效。<br> HIDEBUG_RES_PROF_INVALID_RESOURCE_TYPE:资源采集类型参数无效。<br> HIDEBUG_RES_PROF_PERMISSION_DENIED:资源采集权限不足,采集资源的目标进程仅支持调用接口进程本身。<br> HIDEBUG_RES_PROF_ALREADY_STARTED:资源采集重复启动。<br> HIDEBUG_RES_PROF_PROCESS_OVERLIMIT:资源采集进程数超出 4 个限制。<br> HIDEBUG_RES_PROF_CONFLICT:资源采集与命令行工具或系统采集任务冲突。<br> HIDEBUG_RES_PROF_DAILY_QUOTA_EXCEEDED:资源采集每日配额超出 10 次限制。<br> HIDEBUG_RES_PROF_CPU_OVERLOADED:系统 CPU 处于高负载状态,CPU 占用率超过 70%。<br> HIDEBUG_RES_PROF_MEM_PRESSURE_CRITICAL:内存可用空间紧张,可用空间少于 15%。<br> HIDEBUG_RES_PROF_STORAGE_PRESSURE_CRITICAL:存储可用空间紧张,可用空间少于 15%。<br> HIDEBUG_RES_PROF_FAILURE:启动资源采集失败。 | | 656 | +| [HiDebug_ErrorCode](capi-hidebug-type-h.md#hidebug_errorcode) | 返回结果码:<br> HIDEBUG_RES_PROF_SUCCESS:启动资源采集成功。<br> HIDEBUG_RES_PROF_INVALID_ARG:资源采集参数无效。<br> HIDEBUG_RES_PROF_INVALID_MAX_DURATION:资源采集最大持续时间参数无效。<br> HIDEBUG_RES_PROF_INVALID_FILTER_SIZE:资源采集过滤大小参数无效。<br> HIDEBUG_RES_PROF_INVALID_MAX_STACK_DEPTH:资源采集最大回栈深度参数无效。<br> HIDEBUG_RES_PROF_INVALID_STATISTICS_INTERVAL:资源采集统计间隔参数无效。<br> HIDEBUG_RES_PROF_INVALID_SAMPLE_INTERVAL:资源采集采样大小参数无效。<br> HIDEBUG_RES_PROF_INVALID_RESOURCE_TYPE:资源采集类型参数无效。<br> HIDEBUG_RES_PROF_PERMISSION_DENIED:资源采集权限不足,采集资源的目标进程仅支持调用接口进程自身。<br> HIDEBUG_RES_PROF_ALREADY_STARTED:资源采集重复启动。<br> HIDEBUG_RES_PROF_PROCESS_OVERLIMIT:资源采集并行进程数超出限制,整机最多4个不同应用并行采集,应用内最多2个进程并行采集。<br> HIDEBUG_RES_PROF_CONFLICT:资源采集与命令行工具或系统采集任务冲突。<br> HIDEBUG_RES_PROF_DAILY_QUOTA_EXCEEDED:资源采集每日配额超出限制,整机每日最多4次,应用每日最多2次。<br> HIDEBUG_RES_PROF_CPU_OVERLOADED:整机系统CPU占用率超过70%。<br> HIDEBUG_RES_PROF_MEM_PRESSURE_CRITICAL:整机系统可用内存低于2GB。<br> HIDEBUG_RES_PROF_STORAGE_PRESSURE_CRITICAL:整机系统可用存储空间低于存储阈值,阈值为总存储容量的3%与15GB中的较大值。<br> HIDEBUG_RES_PROF_FAILURE:启动资源采集失败。 | |
| 631 | 657 | ||
| 632 | ### OH_HiDebug_StopProfiler() | 658 | ### OH_HiDebug_StopProfiler() |
| 633 | 659 | ||
| @@ -798,3 +824,248 @@ Profiler辅助接口,将AsyncContext释放给系统。 | |||
| 798 | | 参数项 | 描述 | | 824 | | 参数项 | 描述 | |
| 799 | | -- | -- | | 825 | | -- | -- | |
| 800 | | uint64_t ctx | 由[OH_HiDebug_AcquireAsyncContext()](#oh_hidebug_acquireasynccontext)获取的异步线程上下文。 | | 826 | | uint64_t ctx | 由[OH_HiDebug_AcquireAsyncContext()](#oh_hidebug_acquireasynccontext)获取的异步线程上下文。 | |
| 827 | + | ||
| 828 | +### OH_HiDebug_CreateProfilerOptions() | ||
| 829 | + | ||
| 830 | +```c | ||
| 831 | +OH_HiDebug_ProfilerOptions* OH_HiDebug_CreateProfilerOptions(void) | ||
| 832 | +``` | ||
| 833 | + | ||
| 834 | +**描述** | ||
| 835 | + | ||
| 836 | +创建资源Profiler配置对象。 | ||
| 837 | + | ||
| 838 | +**起始版本:** 26.1.0 | ||
| 839 | + | ||
| 840 | +**返回:** | ||
| 841 | + | ||
| 842 | +| 类型 | 说明 | | ||
| 843 | +| -- | -- | | ||
| 844 | +| [OH_HiDebug_ProfilerOptions*](capi-hidebug-oh-hidebug-profileroptions.md) | 指向OH_HiDebug_ProfilerOptions结构体的指针,当创建失败时返回NULL。 | | ||
| 845 | + | ||
| 846 | +### OH_HiDebug_DestroyProfilerOptions() | ||
| 847 | + | ||
| 848 | +```c | ||
| 849 | +HiDebug_ErrorCode OH_HiDebug_DestroyProfilerOptions(OH_HiDebug_ProfilerOptions* opts) | ||
| 850 | +``` | ||
| 851 | + | ||
| 852 | +**描述** | ||
| 853 | + | ||
| 854 | +释放通过[OH_HiDebug_CreateProfilerOptions](capi-hidebug-h.md#oh_hidebug_createprofileroptions)创建的配置对象。 | ||
| 855 | + | ||
| 856 | +**起始版本:** 26.1.0 | ||
| 857 | + | ||
| 858 | +**参数:** | ||
| 859 | + | ||
| 860 | +| 参数项 | 描述 | | ||
| 861 | +| -- | -- | | ||
| 862 | +| [OH_HiDebug_ProfilerOptions](capi-hidebug-oh-hidebug-profileroptions.md)* opts | 指向OH_HiDebug_ProfilerOptions结构体的指针,不能为NULL。 | | ||
| 863 | + | ||
| 864 | +**返回:** | ||
| 865 | + | ||
| 866 | +| 类型 | 说明 | | ||
| 867 | +| -- | -- | | ||
| 868 | +| [HiDebug_ErrorCode](capi-hidebug-type-h.md#hidebug_errorcode) | 返回结果码:<br> HIDEBUG_SUCCESS:操作成功。<br> HIDEBUG_RES_PROF_INVALID_ARG:opts为空指针。 | | ||
| 869 | + | ||
| 870 | +### OH_HiDebug_SetMaxAsyncNestingDepth() | ||
| 871 | + | ||
| 872 | +```c | ||
| 873 | +HiDebug_ErrorCode OH_HiDebug_SetMaxAsyncNestingDepth(OH_HiDebug_ProfilerOptions* opts, uint32_t depth) | ||
| 874 | +``` | ||
| 875 | + | ||
| 876 | +**描述** | ||
| 877 | + | ||
| 878 | +设置异步调用的最大嵌套深度(也称为最大嵌套层数)。 | ||
| 879 | + | ||
| 880 | +**起始版本:** 26.1.0 | ||
| 881 | + | ||
| 882 | +**参数:** | ||
| 883 | + | ||
| 884 | +| 参数项 | 描述 | | ||
| 885 | +| -- | -- | | ||
| 886 | +| [OH_HiDebug_ProfilerOptions](capi-hidebug-oh-hidebug-profileroptions.md)* opts | 指向OH_HiDebug_ProfilerOptions结构体的指针,不能为NULL。 | | ||
| 887 | +| uint32_t depth | 允许的最大异步嵌套深度,取值范围为[1, 16]。 | | ||
| 888 | + | ||
| 889 | +**返回:** | ||
| 890 | + | ||
| 891 | +| 类型 | 说明 | | ||
| 892 | +| -- | -- | | ||
| 893 | +| [HiDebug_ErrorCode](capi-hidebug-type-h.md#hidebug_errorcode) | 返回结果码:<br> HIDEBUG_SUCCESS:操作成功。<br> HIDEBUG_RES_PROF_INVALID_ARG:opts为空指针。<br> HIDEBUG_RES_PROF_INVALID_MAX_ASYNC_NESTING_DEPTH:资源采集异步嵌套深度参数无效。| | ||
| 894 | + | ||
| 895 | +### OH_HiDebug_SetMaxAsyncTaskStackDepth() | ||
| 896 | + | ||
| 897 | +```c | ||
| 898 | +HiDebug_ErrorCode OH_HiDebug_SetMaxAsyncTaskStackDepth(OH_HiDebug_ProfilerOptions* opts, uint32_t depth) | ||
| 899 | +``` | ||
| 900 | + | ||
| 901 | +**描述** | ||
| 902 | + | ||
| 903 | +设置异步任务函数的最大回栈深度。 | ||
| 904 | + | ||
| 905 | +**起始版本:** 26.1.0 | ||
| 906 | + | ||
| 907 | +**参数:** | ||
| 908 | + | ||
| 909 | +| 参数项 | 描述 | | ||
| 910 | +| -- | -- | | ||
| 911 | +| [OH_HiDebug_ProfilerOptions](capi-hidebug-oh-hidebug-profileroptions.md)* opts | 指向OH_HiDebug_ProfilerOptions结构体的指针,不能为NULL。 | | ||
| 912 | +| uint32_t depth | 最大异步任务回栈深度,取值范围为[1, 256]。 | | ||
| 913 | + | ||
| 914 | +**返回:** | ||
| 915 | + | ||
| 916 | +| 类型 | 说明 | | ||
| 917 | +| -- | -- | | ||
| 918 | +| [HiDebug_ErrorCode](capi-hidebug-type-h.md#hidebug_errorcode) | 返回结果码:<br> HIDEBUG_SUCCESS:操作成功。<br> HIDEBUG_RES_PROF_INVALID_ARG:opts为空指针。<br> HIDEBUG_RES_PROF_INVALID_MAX_ASYNC_TASK_STACK_DEPTH:资源采集异步任务回栈深度参数无效。| | ||
| 919 | + | ||
| 920 | +### OH_HiDebug_SetSampleIntervalBytes() | ||
| 921 | + | ||
| 922 | +```c | ||
| 923 | +HiDebug_ErrorCode OH_HiDebug_SetSampleIntervalBytes(OH_HiDebug_ProfilerOptions* opts, uint32_t bytes) | ||
| 924 | +``` | ||
| 925 | + | ||
| 926 | +**描述** | ||
| 927 | + | ||
| 928 | +设置采样间隔,单位为Byte。 | ||
| 929 | + | ||
| 930 | +**起始版本:** 26.1.0 | ||
| 931 | + | ||
| 932 | +**参数:** | ||
| 933 | + | ||
| 934 | +| 参数项 | 描述 | | ||
| 935 | +| -- | -- | | ||
| 936 | +| [OH_HiDebug_ProfilerOptions](capi-hidebug-oh-hidebug-profileroptions.md)* opts | 指向OH_HiDebug_ProfilerOptions结构体的指针,不能为NULL。 | | ||
| 937 | +| uint32_t bytes | 采样间隔,取值范围为[384, 4294967295],单位为Byte。 | | ||
| 938 | + | ||
| 939 | +**返回:** | ||
| 940 | + | ||
| 941 | +| 类型 | 说明 | | ||
| 942 | +| -- | -- | | ||
| 943 | +| [HiDebug_ErrorCode](capi-hidebug-type-h.md#hidebug_errorcode) | 返回结果码:<br> HIDEBUG_SUCCESS:操作成功。<br> HIDEBUG_RES_PROF_INVALID_ARG:opts为空指针。<br> HIDEBUG_RES_PROF_INVALID_SAMPLE_INTERVAL:采样间隔参数无效。 | | ||
| 944 | + | ||
| 945 | +### OH_HiDebug_SetStatisticsIntervalSec() | ||
| 946 | + | ||
| 947 | +```c | ||
| 948 | +HiDebug_ErrorCode OH_HiDebug_SetStatisticsIntervalSec(OH_HiDebug_ProfilerOptions* opts, uint32_t seconds) | ||
| 949 | +``` | ||
| 950 | + | ||
| 951 | +**描述** | ||
| 952 | + | ||
| 953 | +设置统计间隔,单位为s。 | ||
| 954 | + | ||
| 955 | +**起始版本:** 26.1.0 | ||
| 956 | + | ||
| 957 | +**参数:** | ||
| 958 | + | ||
| 959 | +| 参数项 | 描述 | | ||
| 960 | +| -- | -- | | ||
| 961 | +| [OH_HiDebug_ProfilerOptions](capi-hidebug-oh-hidebug-profileroptions.md)* opts | 指向OH_HiDebug_ProfilerOptions结构体的指针,不能为NULL。 | | ||
| 962 | +| uint32_t seconds | 统计间隔,取值范围为[1, 3600],单位为s。 | | ||
| 963 | + | ||
| 964 | +**返回:** | ||
| 965 | + | ||
| 966 | +| 类型 | 说明 | | ||
| 967 | +| -- | -- | | ||
| 968 | +| [HiDebug_ErrorCode](capi-hidebug-type-h.md#hidebug_errorcode) | 返回结果码:<br> HIDEBUG_SUCCESS:操作成功。<br> HIDEBUG_RES_PROF_INVALID_ARG:opts为空指针。<br> HIDEBUG_RES_PROF_INVALID_STATISTICS_INTERVAL:统计间隔参数无效。 | | ||
| 969 | + | ||
| 970 | +### OH_HiDebug_SetMaxStackDepth() | ||
| 971 | + | ||
| 972 | +```c | ||
| 973 | +HiDebug_ErrorCode OH_HiDebug_SetMaxStackDepth(OH_HiDebug_ProfilerOptions* opts, uint32_t depth) | ||
| 974 | +``` | ||
| 975 | + | ||
| 976 | +**描述** | ||
| 977 | + | ||
| 978 | +设置最大回栈深度。 | ||
| 979 | + | ||
| 980 | +**起始版本:** 26.1.0 | ||
| 981 | + | ||
| 982 | +**参数:** | ||
| 983 | + | ||
| 984 | +| 参数项 | 描述 | | ||
| 985 | +| -- | -- | | ||
| 986 | +| [OH_HiDebug_ProfilerOptions](capi-hidebug-oh-hidebug-profileroptions.md)* opts | 指向OH_HiDebug_ProfilerOptions结构体的指针,不能为NULL。 | | ||
| 987 | +| uint32_t depth | 最大回栈深度,取值范围为[1, 30]。 | | ||
| 988 | + | ||
| 989 | +**返回:** | ||
| 990 | + | ||
| 991 | +| 类型 | 说明 | | ||
| 992 | +| -- | -- | | ||
| 993 | +| [HiDebug_ErrorCode](capi-hidebug-type-h.md#hidebug_errorcode) | 返回结果码:<br> HIDEBUG_SUCCESS:操作成功。<br> HIDEBUG_RES_PROF_INVALID_ARG:opts为空指针。<br> HIDEBUG_RES_PROF_INVALID_MAX_STACK_DEPTH:最大回栈深度参数无效。 | | ||
| 994 | + | ||
| 995 | +### OH_HiDebug_SetFilterSize() | ||
| 996 | + | ||
| 997 | +```c | ||
| 998 | +HiDebug_ErrorCode OH_HiDebug_SetFilterSize(OH_HiDebug_ProfilerOptions* opts, uint32_t size) | ||
| 999 | +``` | ||
| 1000 | + | ||
| 1001 | +**描述** | ||
| 1002 | + | ||
| 1003 | +设置内存分配过滤大小。 | ||
| 1004 | + | ||
| 1005 | +**起始版本:** 26.1.0 | ||
| 1006 | + | ||
| 1007 | +**参数:** | ||
| 1008 | + | ||
| 1009 | +| 参数项 | 描述 | | ||
| 1010 | +| -- | -- | | ||
| 1011 | +| [OH_HiDebug_ProfilerOptions](capi-hidebug-oh-hidebug-profileroptions.md)* opts | 指向OH_HiDebug_ProfilerOptions结构体的指针,不能为NULL。 | | ||
| 1012 | +| uint32_t size | 过滤大小阈值,取值范围为[1, 4294967295],单位为Byte。 | | ||
| 1013 | + | ||
| 1014 | +**返回:** | ||
| 1015 | + | ||
| 1016 | +| 类型 | 说明 | | ||
| 1017 | +| -- | -- | | ||
| 1018 | +| [HiDebug_ErrorCode](capi-hidebug-type-h.md#hidebug_errorcode) | 返回结果码:<br> HIDEBUG_SUCCESS:操作成功。<br> HIDEBUG_RES_PROF_INVALID_ARG:opts为空指针。<br> HIDEBUG_RES_PROF_INVALID_FILTER_SIZE:过滤大小参数无效。 | | ||
| 1019 | + | ||
| 1020 | +### OH_HiDebug_SetMaxDurationSec() | ||
| 1021 | + | ||
| 1022 | +```c | ||
| 1023 | +HiDebug_ErrorCode OH_HiDebug_SetMaxDurationSec(OH_HiDebug_ProfilerOptions* opts, uint32_t seconds) | ||
| 1024 | +``` | ||
| 1025 | + | ||
| 1026 | +**描述** | ||
| 1027 | + | ||
| 1028 | +设置最大采集时长,单位为s。 | ||
| 1029 | + | ||
| 1030 | +**起始版本:** 26.1.0 | ||
| 1031 | + | ||
| 1032 | +**参数:** | ||
| 1033 | + | ||
| 1034 | +| 参数项 | 描述 | | ||
| 1035 | +| -- | -- | | ||
| 1036 | +| [OH_HiDebug_ProfilerOptions](capi-hidebug-oh-hidebug-profileroptions.md)* opts | 指向OH_HiDebug_ProfilerOptions结构体的指针,不能为NULL。 | | ||
| 1037 | +| uint32_t seconds | 最大采集时长,取值范围为[1, 3600],单位为s。 | | ||
| 1038 | + | ||
| 1039 | +**返回:** | ||
| 1040 | + | ||
| 1041 | +| 类型 | 说明 | | ||
| 1042 | +| -- | -- | | ||
| 1043 | +| [HiDebug_ErrorCode](capi-hidebug-type-h.md#hidebug_errorcode) | 返回结果码:<br> HIDEBUG_SUCCESS:操作成功。<br> HIDEBUG_RES_PROF_INVALID_ARG:opts为空指针。<br> HIDEBUG_RES_PROF_INVALID_MAX_DURATION:最大持续采集时间参数无效。 | | ||
| 1044 | + | ||
| 1045 | +### OH_HiDebug_StartProfilerWithOptions() | ||
| 1046 | + | ||
| 1047 | +```c | ||
| 1048 | +HiDebug_ErrorCode OH_HiDebug_StartProfilerWithOptions(OH_HiDebug_ResourceType type, OH_HiDebug_ProfilerOptions* opts, OH_HiDebug_ProfilingCallback callback) | ||
| 1049 | +``` | ||
| 1050 | + | ||
| 1051 | +**描述** | ||
| 1052 | + | ||
| 1053 | +按指定资源类型和配置开启当前进程资源分配栈信息采集功能。 | ||
| 1054 | + | ||
| 1055 | +**起始版本:** 26.1.0 | ||
| 1056 | + | ||
| 1057 | +**参数:** | ||
| 1058 | + | ||
| 1059 | +| 参数项 | 描述 | | ||
| 1060 | +| -- | -- | | ||
| 1061 | +| [OH_HiDebug_ResourceType](capi-hidebug-type-h.md#oh_hidebug_resourcetype) type | 资源采集类型(OH_HiDebug_ResourceType)。 | | ||
| 1062 | +| [OH_HiDebug_ProfilerOptions](capi-hidebug-oh-hidebug-profileroptions.md)* opts | 指向已配置的OH_HiDebug_ProfilerOptions结构体的指针,不能为NULL。 | | ||
| 1063 | +| [OH_HiDebug_ProfilingCallback](capi-hidebug-type-h.md#oh_hidebug_profilingcallback) callback | 接收采集结果的回调函数。 | | ||
| 1064 | + | ||
| 1065 | +**返回:** | ||
| 1066 | + | ||
| 1067 | +| 类型 | 说明 | | ||
| 1068 | +| -- | -- | | ||
| 1069 | +| [HiDebug_ErrorCode](capi-hidebug-type-h.md#hidebug_errorcode) | 返回结果码:<br> HIDEBUG_RES_PROF_SUCCESS:启动资源采集成功。<br> HIDEBUG_RES_PROF_INVALID_ARG:opts或callback为空指针。<br> HIDEBUG_RES_PROF_INVALID_MAX_DURATION:最大持续采集时间参数无效。<br> HIDEBUG_RES_PROF_INVALID_FILTER_SIZE:过滤大小参数无效。<br> HIDEBUG_RES_PROF_INVALID_MAX_STACK_DEPTH:最大回栈深度参数无效。<br> HIDEBUG_RES_PROF_INVALID_STATISTICS_INTERVAL:统计间隔参数无效。<br> HIDEBUG_RES_PROF_INVALID_SAMPLE_INTERVAL:采样间隔参数无效。<br> HIDEBUG_RES_PROF_INVALID_MAX_ASYNC_NESTING_DEPTH:资源采集异步嵌套深度参数无效。<br> HIDEBUG_RES_PROF_INVALID_MAX_ASYNC_TASK_STACK_DEPTH:资源采集异步任务回栈深度参数无效。<br> HIDEBUG_RES_PROF_INVALID_RESOURCE_TYPE:资源采集类型参数无效。<br> HIDEBUG_RES_PROF_PERMISSION_DENIED:资源采集权限不足。<br> HIDEBUG_RES_PROF_ALREADY_STARTED:资源采集重复启动。<br> HIDEBUG_RES_PROF_PROCESS_OVERLIMIT:资源采集并行进程数超出限制,整机最多4个不同应用并行采集,应用内最多2个进程并行采集。<br> HIDEBUG_RES_PROF_CONFLICT:资源采集与命令行工具或系统采集任务冲突。<br> HIDEBUG_RES_PROF_DAILY_QUOTA_EXCEEDED:资源采集每日配额超出限制,整机每日最多4次,应用每日最多2次。<br> HIDEBUG_RES_PROF_CPU_OVERLOADED:整机系统CPU占用率超过70%。<br> HIDEBUG_RES_PROF_MEM_PRESSURE_CRITICAL:整机系统可用内存低于2GB。<br> HIDEBUG_RES_PROF_STORAGE_PRESSURE_CRITICAL:整机系统可用存储空间低于存储阈值,阈值为总存储容量的3%与15GB中的较大值。<br> HIDEBUG_RES_PROF_FAILURE:启动资源采集失败。 | | ||
| 1070 | + | ||
| 1071 | + | ||
| @@ -0,0 +1,23 @@ | |||
| 1 | +# OH_HiDebug_ProfilerOptions | ||
| 2 | + | ||
添加责任人相关内容 ![]() ![]() | |||
| 3 | +<!--Kit: Performance Analysis Kit--> | ||
| 4 | +<!--Subsystem: HiviewDFX--> | ||
| 5 | +<!--Owner: @leiguangyu--> | ||
| 6 | +<!--Designer: @mgce1--> | ||
| 7 | +<!--Tester: @gcw_KuLfPSbe--> | ||
| 8 | +<!--Adviser: @jinqiuheng--> | ||
| 9 | + | ||
| 10 | +```c | ||
| 11 | +typedef struct OH_HiDebug_ProfilerOptions OH_HiDebug_ProfilerOptions | ||
| 12 | +``` | ||
| 13 | + | ||
| 14 | +## 概述 | ||
| 15 | + | ||
| 16 | +资源采集配置结构体前向声明。 | ||
| 17 | + | ||
| 18 | +**起始版本:** 26.1.0 | ||
| 19 | + | ||
| 20 | +**相关模块:** [HiDebug](capi-hidebug.md) | ||
| 21 | + | ||
| 22 | +**所在头文件:** [hidebug.h](capi-hidebug-h.md) | ||
| 23 | + | ||
| @@ -136,14 +136,16 @@ enum HiDebug_ErrorCode | |||
| 136 | | HIDEBUG_RES_PROF_PERMISSION_DENIED = 11400420 | 资源采集权限不足,采集资源的目标进程仅支持调用接口进程本身。<br>**起始版本:** 24 | | 136 | | HIDEBUG_RES_PROF_PERMISSION_DENIED = 11400420 | 资源采集权限不足,采集资源的目标进程仅支持调用接口进程本身。<br>**起始版本:** 24 | |
| 137 | | HIDEBUG_RES_PROF_ALREADY_STARTED = 11400421 | 资源采集重复启动。<br>**起始版本:** 24 | | 137 | | HIDEBUG_RES_PROF_ALREADY_STARTED = 11400421 | 资源采集重复启动。<br>**起始版本:** 24 | |
| 138 | | HIDEBUG_RES_PROF_NOT_STARTED = 11400422 | 资源采集未启动,停止失败。<br>**起始版本:** 24 | | 138 | | HIDEBUG_RES_PROF_NOT_STARTED = 11400422 | 资源采集未启动,停止失败。<br>**起始版本:** 24 | |
| 139 | -| HIDEBUG_RES_PROF_PROCESS_OVERLIMIT = 11400423 | 资源采集进程数超出 4 个限制。<br>**起始版本:** 24 | | 139 | +| HIDEBUG_RES_PROF_PROCESS_OVERLIMIT = 11400423 | 资源采集并行进程数超出限制,整机最多4个不同应用并行采集,应用内最多2个进程并行采集。<br>**起始版本:** 24 | |
| 140 | | HIDEBUG_RES_PROF_CONFLICT = 11400424 | 资源采集与命令行工具或系统采集任务冲突。<br>**起始版本:** 24 | | 140 | | HIDEBUG_RES_PROF_CONFLICT = 11400424 | 资源采集与命令行工具或系统采集任务冲突。<br>**起始版本:** 24 | |
| 141 | | HIDEBUG_RES_PROF_AUTO_STOPPED_BY_DURATION = 11400425 | 资源采集到达指定最大持续时间限制自动停止。<br>**起始版本:** 24 | | 141 | | HIDEBUG_RES_PROF_AUTO_STOPPED_BY_DURATION = 11400425 | 资源采集到达指定最大持续时间限制自动停止。<br>**起始版本:** 24 | |
| 142 | -| HIDEBUG_RES_PROF_DAILY_QUOTA_EXCEEDED = 11400426 | 资源采集每日配额超出 10 次限制。<br>**起始版本:** 24 | | 142 | +| HIDEBUG_RES_PROF_DAILY_QUOTA_EXCEEDED = 11400426 | 资源采集每日配额超出限制,整机每日最多4次,应用每日最多2次。<br>**起始版本:** 24 | |
| 143 | -| HIDEBUG_RES_PROF_CPU_OVERLOADED = 11400427 | 系统 CPU 处于高负载状态,CPU 占用率超过 70%。<br>**起始版本:** 24 | | 143 | +| HIDEBUG_RES_PROF_CPU_OVERLOADED = 11400427 | 整机系统CPU占用率超过70%。<br>**起始版本:** 24 | |
| 144 | -| HIDEBUG_RES_PROF_MEM_PRESSURE_CRITICAL = 11400428 | 内存可用空间紧张,可用空间少于 15%。<br>**起始版本:** 24 | | 144 | +| HIDEBUG_RES_PROF_MEM_PRESSURE_CRITICAL = 11400428 | 整机系统可用内存低于2GB。<br>**起始版本:** 24 | |
| 145 | -| HIDEBUG_RES_PROF_STORAGE_PRESSURE_CRITICAL = 11400429 | 存储可用空间紧张,可用空间少于 15%。<br>**起始版本:** 24 | | 145 | +| HIDEBUG_RES_PROF_STORAGE_PRESSURE_CRITICAL = 11400429 | 整机系统可用存储空间低于存储阈值,阈值为总存储容量的3%与15GB中的较大值。<br>**起始版本:** 24 | |
| 146 | | HIDEBUG_RES_PROF_FAILURE = 11400430 | 资源采集启动/停止失败。<br>**起始版本:** 24 | | 146 | | HIDEBUG_RES_PROF_FAILURE = 11400430 | 资源采集启动/停止失败。<br>**起始版本:** 24 | |
| 147 | +| HIDEBUG_RES_PROF_INVALID_MAX_ASYNC_NESTING_DEPTH = 11400431 | 资源采集异步嵌套深度参数无效。<br>**起始版本:** 26.1.0 | | ||
| 148 | +| HIDEBUG_RES_PROF_INVALID_MAX_ASYNC_TASK_STACK_DEPTH = 11400432 | 资源采集异步任务回栈深度参数无效。<br>**起始版本:** 26.1.0 | | ||
| 147 | 149 | ||
| 148 | ### HiDebug_TraceFlag | 150 | ### HiDebug_TraceFlag |
| 149 | 151 | ||
| @@ -219,6 +221,9 @@ enum OH_HiDebug_ResourceType | |||
| 219 | | OH_RES_TYPE_NATIVE | Native 内存<br>**起始版本:** 24 | | 221 | | OH_RES_TYPE_NATIVE | Native 内存<br>**起始版本:** 24 | |
| 220 | | OH_RES_TYPE_GPU | GPU 内存<br>**起始版本:** 24 | | 222 | | OH_RES_TYPE_GPU | GPU 内存<br>**起始版本:** 24 | |
| 221 | | OH_RES_TYPE_GLOBAL_HANDLE | 全局句柄<br>**起始版本:** 24 | | 223 | | OH_RES_TYPE_GLOBAL_HANDLE | 全局句柄<br>**起始版本:** 24 | |
| 224 | +| OH_RES_TYPE_DMA | DMA内存<br>**起始版本:** 26.1.0 | | ||
| 225 | +| OH_RES_TYPE_ASHMEM | 匿名共享内存<br>**起始版本:** 26.1.0 | | ||
| 226 | +| OH_RES_TYPE_COMPOSITE_HEAP | 组合堆<br>**起始版本:** 26.1.0 | | ||
| 222 | 227 | ||
| 223 | ### OH_HiDebug_MemListenerType | 228 | ### OH_HiDebug_MemListenerType |
| 224 | 229 | ||


新增文章同步添加到readme中