Skip to content

chore: ignore stack with negative sample#375

Open
YiniXu9506 wants to merge 1 commit into
jlfwong:mainfrom
YiniXu9506:IgnoreNegtiveStack
Open

chore: ignore stack with negative sample#375
YiniXu9506 wants to merge 1 commit into
jlfwong:mainfrom
YiniXu9506:IgnoreNegtiveStack

Conversation

@YiniXu9506

@YiniXu9506 YiniXu9506 commented Nov 4, 2021

Copy link
Copy Markdown

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

Lauszus commented Sep 2, 2024

Copy link
Copy Markdown

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