Bug 1944790 Comment 1 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

This is the script to extract peak usage

```
    import sys
    import json
    ​
    data = json.loads(open(sys.argv[-1]).read())
    ​
    ​
    def getPeakMem(process):
        max = 0
        current = 0
        pid = 0
        processName = ""
    ​
        for thread in process["threads"]:
            if thread["name"] == "GeckoMain":
                pid = thread["pid"]
                processName = thread.get("processName", "unknown")
                break
    ​
        for counter in process["counters"]:
            if counter["name"] == "malloc":
                for sample in process["counters"][0]["samples"]["data"]:
                    current += sample[1]
                    if current > max:
                        max = current
    ​
                print(
                    f"[{pid}][{processName}] Peak memory allocation {max / (1024 * 1024)}"
                )
    ​
    ​
    getPeakMem(data)
    ​
    for process in data["processes"]:
        getPeakMem(process)
```

example on a perf test :

```
➜  python3 peak.py profile.json
[51064][Parent Process] Peak memory allocation 298.32491302490234
[51065][unknown] Peak memory allocation 35.444618225097656
[51070][Utility Process] Peak memory allocation 35.41194152832031
[51067][unknown] Peak memory allocation 35.460235595703125
[51084][Web Content] Peak memory allocation 37.041725158691406
[51073][Inference] Peak memory allocation 479.8895950317383
[51083][Web Content] Peak memory allocation 37.04314422607422
[51074][Web Content] Peak memory allocation 37.16900634765625
[51072][Web Content] Peak memory allocation 39.958473205566406
[51066][WebExtensions] Peak memory allocation 52.40960693359375
[51068][Web Content] Peak memory allocation 40.31774139404297
[51071][Privileged Content] Peak memory allocation 56.09490203857422
```
This is the script to extract peak usage

```
    import sys
    import json
    ​
    data = json.loads(open(sys.argv[-1]).read())
    ​
    ​
    def getPeakMem(process):
        max = 0
        current = 0
        pid = 0
        processName = ""
    ​
        for thread in process["threads"]:
            if thread["name"] == "GeckoMain":
                pid = thread["pid"]
                processName = thread.get("processName", "unknown")
                break
    ​
        for counter in process["counters"]:
            if counter["name"] == "malloc":
                for sample in counter["samples"]["data"]:
                    current += sample[1]
                    if current > max:
                        max = current
    ​
                print(
                    f"[{pid}][{processName}] Peak memory allocation {max / (1024 * 1024)}"
                )
    ​
    ​
    getPeakMem(data)
    ​
    for process in data["processes"]:
        getPeakMem(process)
```

example on a perf test :

```
➜  python3 peak.py profile.json
[51064][Parent Process] Peak memory allocation 298.32491302490234
[51065][unknown] Peak memory allocation 35.444618225097656
[51070][Utility Process] Peak memory allocation 35.41194152832031
[51067][unknown] Peak memory allocation 35.460235595703125
[51084][Web Content] Peak memory allocation 37.041725158691406
[51073][Inference] Peak memory allocation 479.8895950317383
[51083][Web Content] Peak memory allocation 37.04314422607422
[51074][Web Content] Peak memory allocation 37.16900634765625
[51072][Web Content] Peak memory allocation 39.958473205566406
[51066][WebExtensions] Peak memory allocation 52.40960693359375
[51068][Web Content] Peak memory allocation 40.31774139404297
[51071][Privileged Content] Peak memory allocation 56.09490203857422
```

Back to Bug 1944790 Comment 1