Skip to content

Conversation

@r1viollet
Copy link
Collaborator

Description

Add a test case mixing Go and C allocations

@r1viollet r1viollet changed the title ddprof go test case ddprof Cgo test case Aug 1, 2023
{
"regular_expression": ".*runtime\\.asmcgocall\\.abi0;cAllocateMemory",
"percent": 20,
"error_margin": 40,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really care about the numbers (I can't predict the mmap strategy from Go), I just want them to be there.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you call this out more clearly in the README

Add a test case mixing Go and C allocations
Add documentation to comment on test purpose
@r1viollet r1viollet force-pushed the r1viollet/ddprof_go branch from 3c19c2e to df91785 Compare August 4, 2023 13:26
{
"regular_expression": ".*runtime\\.asmcgocall\\.abi0;cAllocateMemory",
"percent": 20,
"error_margin": 40,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you call this out more clearly in the README

&& rm -rf /var/lib/apt/lists/*

# Install native profiling
ARG CACHE_DATE=2023-03-01_09:58:27
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noob question: What does this date signify? Does it mean we're using a version from March?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a trick to force the second part of the docker to re-fetch new versions of the profiler.

Comment on lines +24 to +27
for (int i = 0; i < size_alloc; i++) {
sum += data[i];
}
printf("%d\n", sum);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏️ indentation

func burnCPU() {
// Simulate CPU-intensive work
for i := 0; i < 1000000000; i++ {
_ = i * i
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we guarantee this won't be optimized?


func allocateMemory() {
// Allocate some memory in Go
data := make([]int, 100)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we're doing 10K in C, and 100 in Go? For future, might be interesting to make this configurable to see how we do at profiling as the relative ratios change

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#9

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, only that I was sure not to catch these for now, so I did not care about having smaller allocations. The native profiler can not instrument the Go allocator (only the mmaps).
We can unify if you feel it is more logical.

@r1viollet r1viollet marked this pull request as draft June 20, 2024 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants