Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: ignore stack with negative sample #375

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

YiniXu9506
Copy link

@YiniXu9506 YiniXu9506 commented Nov 4, 2021

Sometimes we may get the Golang's memory profiling with negative weight samples, which may not deliver meaningful messages to users, eg.

image

so can we just ignore the the samples with negative weights?

@Lauszus
Copy link

Lauszus commented Sep 2, 2024

I have the same issue.

I worked around it by replacing all the negative weights with 0 before loading it:

import argparse
import json

parser = argparse.ArgumentParser()
parser.add_argument("input")
parser.add_argument("output")
args = parser.parse_args()

input_: str = args.input
output: str = args.output

with open(input_) as f:
    data = json.load(f)

for i, p in enumerate(data["profiles"]):
    for j, w in enumerate(p["weights"]):
        if w < 0:
            data["profiles"][i]["weights"][j] = 0

with open(output, "w") as f:
    json.dump(data, f)

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.

2 participants