简体   繁体   English

收集堆使用情况的性能数据

[英]Collecting performance data on heap usage

I am working on a compiler module that adds extra instructions around every load/store in an application with an emphasis on heap objects. 我正在开发一个编译器模块,它为应用程序中的每个加载/存储添加额外的指令,重点是堆对象。 One of the performance factors is the size of the object being accessed; 其中一个性能因素是被访问对象的大小; different instructions are chosen at run time for different object sizes. 在运行时为不同的对象大小选择不同的指令。

I have chosen a few benchmarks from SPEC to grade the performance impact of my changes. 我从SPEC中选择了一些基准来评估我的更改对性能的影响。 Currently, I am limited to just looking at overheads measured by perf. 目前,我仅限于查看由perf测量的间接费用。 This leads to a substantial amount of guessing about why certain benchmarks are more severely impacted than others. 这导致大量猜测为什么某些基准比其他基准受到更严重的影响。 Supporting each hypothesis with more data seems like a good step to take. 用更多数据支持每个假设似乎是一个很好的步骤。 From each benchmark, for each object allocated on the heap, it would be useful to know: 从每个基准测试,对于在堆上分配的每个对象,知道以下内容将是有用的:

  • The size of each heap allocation or reallocation 每个堆分配或重新分配的大小
  • The number of times each allocation is accessed throughout the run of the application. 在整个应用程序运行期间访问每个分配的次数。

I have been successful in #1. 我在#1中取得了成功。 It was easy enough to inject a few printf() calls into glibc as I am already tinkering in glibc. 很容易将一些printf()调用注入到glibc中,因为我已经在修改glibc了。 I do not know how to get #2; 我不知道如何获得#2; access counts seem much better suited to a framework or wrapper tool and I don't know which one would work best. 访问计数似乎更适合框架或包装工具,我不知道哪一个最适合。

Can you provide a recommendation on how to collect this information? 您能否就如何收集这些信息提出建议?

If you're doing the instrumentation in assembly (which I think you are?), you can, in the data segment, just stick in a label with a value: 如果你正在组装中进行检测(我认为你是?),你可以在数据段中粘贴一个带有值的标签:

        .data
# probably some other stuff goes here
        .align 4
count:
        .long   0

and increment it like so: 并按如下方式递增:

        movl    count, %eax
        addl    $1, %eax
        movl    %eax, count

choosing an appropriate register. 选择合适的登记册。 Though I suppose if you're doing it at the head of a function call, %eax would get clobbered anyway. 虽然我想如果你是在函数调用的头部进行的,那么%eax无论如何都会被破坏。

Valgrind has a tool 'DHAT" - dynamic heap analysis tool - that can collect this data. The output is not exactly in the format I want, but it is close enough for research work. The access counts are summarized as "average [reads|writes] per byte per allocation"; the exact access count isn't reported nor recoverable from other report data. Maybe some open source development in my future? Valgrind有一个工具'DHAT' - 动态堆分析工具 - 可以收集这些数据。输出不完全符合我想要的格式,但它足够接近研究工作。访问计数总结为“平均值[读取]写入]每个分配每个字节“;不会报告确切的访问计数,也不会从其他报告数据中恢复。也许我的未来会有一些开源开发?

http://valgrind.org/docs/manual/dh-manual.html http://valgrind.org/docs/manual/dh-manual.html

valgrind --tool=exp-dhat --show-top-n=100000 --trace-children=yes --log-file="log.file" ./benchmark

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM