mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-09-15 07:19:20 -04:00
CI build, for e2e-test and nightly now build with: -Dorderfile/lightpanda.ld This file informs the build on how to organize the code in the binary, grouping hot code together so that we have to load less of the binary into memory. lightpanda.ld will drift: we'll refactor our code, add new features, update dependencies, update Zig, ... So it has to be re-generated. But we can do that automatically in the CI (say, before the nightly build). That's for a follow up PR. This does not currently cover V8. V8 is being build with `-no-unique-section-names`, so we don't get names that we can correctly organize. The real win comes from doing this in V8, since a lot of V8 is cold. This PR can land as-is, a zig-v8-fork PR will remove that flag, and then we can have a follow up PR with an lightpanda.ld that includes the v8 symbols. This is opt-in (via the -Dorderfile flag) because it adds ~20 seconds of linking time.
28 lines
941 B
Python
Executable File
28 lines
941 B
Python
Executable File
#!/usr/bin/env python3
|
|
# Dump resident (present) pages per file-backed mapping of a live process.
|
|
import sys, json, struct, os
|
|
pid = int(sys.argv[1]); out = sys.argv[2]
|
|
maps = []
|
|
for line in open(f"/proc/{pid}/maps"):
|
|
p = line.split()
|
|
if len(p) < 6: continue
|
|
lo, hi = (int(x, 16) for x in p[0].split('-'))
|
|
maps.append(dict(lo=lo, hi=hi, perms=p[1], off=int(p[2], 16), path=p[5]))
|
|
res = []
|
|
with open(f"/proc/{pid}/pagemap", "rb") as pm:
|
|
for m in maps:
|
|
n = (m["hi"] - m["lo"]) // 4096
|
|
pm.seek(m["lo"] // 4096 * 8)
|
|
if m["lo"] >= 1 << 47: continue
|
|
data = pm.read(n * 8)
|
|
present = [i for i in range(n) if struct.unpack_from("<Q", data, i * 8)[0] >> 63 & 1]
|
|
m["present"] = present
|
|
m["n"] = n
|
|
res.append(m)
|
|
json.dump(res, open(out, "w"))
|
|
tot = 0
|
|
for m in res:
|
|
if m["present"]:
|
|
tot += len(m["present"])
|
|
print(f"resident pages total {tot} = {tot*4} KB")
|