This is an archive of the discontinued LLVM Phabricator instance.

[trace][intel pt] Add a memory usage test
AbandonedPublic

Authored by wallace on Apr 18 2022, 11:11 PM.

Details

Reviewers
jj10306
zrthxn
Summary

The existing tests that check for the memory usage of the decoded trace are using small binaries, and in this case the memory usage is dominated by the static size of the structures. In order to check the dynamic cost of the trace, I'm creating a new test that runs a program that is compiled at test time and then the total number of instructions and memory usage is asserted.

This serves as an example of a test that doesn't require to check in a prebuilt binary, which is costly for git.

Diff Detail

Event Timeline

wallace created this revision.Apr 18 2022, 11:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 18 2022, 11:11 PM
wallace requested review of this revision.Apr 18 2022, 11:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 18 2022, 11:11 PM

What is the intention of this test? To catch changes that may increase the memory by a lot? I'm concerned this could be very flaky given that it's dependent on external factors (compiler output, context switches, etc).
Now that we have this test, is there any value in having the check for the memory information output in the trace dump test or can that be removed?

To catch changes that may increase the memory by a lot?

exactly. We might introduce changes in the decoder that might produce erroneous data and increase the memory usage or number of instructions by too much. For example, all our current tests work with small number of instructions, so they are easy to assert. But when dealing with milllions of instructions, it's hard to assert what will happen unless we look for statistics. In this specific case, because we only care about x86, the number of instructions shouldn't change because we compile without optimizations, so I doubt it'll be flaky. In terms of context switches, each context switch only adds a minimal amount of bytes. In fact, each context switch only contributes one entry in the events map.

But besides all that, which doesn't sound very convincing, what I want to start having is tests with binaries that are compiled at the moment without the need of prebuilt binaries. People complain too much every time someone tries to commit a prebuilt binary because of two reasons: it's very heavy for the source control system, and it might fail on some machines with a different setup for some system libraries. When the test binary is compiled at the moment, then the compiler will ensure that it can run on the current machine.

So this is more like a learning step for me while being useful to test some other things.

wallace abandoned this revision.Apr 19 2022, 8:46 AM

I think I can do better than this