npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

hmtrace-parser

v0.3.9

Published

Kernel trace format helpers (checkpoint_revoked, perf trace text blocks)

Readme

hmtrace-parser

内核 trace 相关辅助:为 hiperf_txt_parser 提供若干事件的 perf trace 文本格式块format: / print fmt:),以及对 checkpoint_revoked 事件中 reason 字段的解析与展开。

  • Node.js ≥ 18
  • ESM"type": "module"

安装

npm install hmtrace-parser

用法概览

入口 hmtrace-parser

与下列子路径导出内容相同,便于一次性导入:

import {
  // logger(cp_revoked、backtrack 共用)
  setHmtraceLogger,
  noopHmtraceLogger,
  // cp_revoked
  CheckpointRevokedType,
  CHECKPOINT_REVOKED_REASON_EXPANDERS,
  expandCheckpointRevokedReason,
  parseBinderCheckpointReason,
  parseFsCheckpointReason,
  // backtrack
  backtrackFS,
  // traces
  getTraceEventFormats,
  getTraceEventFormatProfiles,
  TRACE_EVENT_FORMATS,
} from "hmtrace-parser";

hmtrace-parser/logger.js

各模块共用一套日志接口与注入入口。

| 导出 | 说明 | |------|------| | HmtraceLogger | trace / debug / info 三档,均为 (msg: string) => void | | setHmtraceLogger | 注入实现;未调用时相关模块日志为 no-op | | getHmtraceLogger | 读取当前实现(一般无需直接使用) | | noopHmtraceLogger | 全 no-op,便于测试里复位 |

hmtrace-parser/cp_revoked.js

与内核 checkpoint_revokedtype / reason 约定对齐(数值需与内核枚举一致)。日志通过 setHmtraceLogger 注入,本模块使用其中的 trace / debug

| 导出 | 说明 | |------|------| | CheckpointRevokedType | 枚举:FSBINDERNETWORKDRIVER 等 | | parseFsCheckpointReason | FS 类 reasonk1:v1, k2:v2(首段 : 为键值分界,值可含逗号或冒号) | | parseBinderCheckpointReason | BINDER 类:(src_name),(src_thread_name),(dst_name),(code),(token) 五段;成功时返回上述键名对象 | | expandCheckpointRevokedReason | 根据 fieldDict.type 分发解析,成功则删除 reason 并合并展开字段;失败或无解析器则保留原字典 | | CHECKPOINT_REVOKED_REASON_EXPANDERS | 可按类型扩展/覆盖的注册表 |

hmtrace-parser/traces.js

内置多组 trace 事件格式TraceEventFormattext + 可选 transformFieldDict),供 hiperf_txt_parser 等消费。

| 导出 | 说明 | |------|------| | TRACE_EVENT_FORMATS | 默认 profile 使用的格式数组 | | getTraceEventFormats(profile?) | 按 profile 取格式;未知 profile 回退 default | | getTraceEventFormatProfiles() | 已登记的 profile 名列表 |

当前内置 profile(见 getTraceEventFormatProfiles()):

| profile | 说明 | |---------|------| | default / 6.0 | 同一套定义:hmb_forkall_repord_image_failurevfs_snapshot_dump_monitorbinder_transac_init_kstate_notifycheckpoint_revokedcheckpoint_revoked 为透传 fieldDict,不展开 reason)。 | | dev | 独立事件 ID 的上述前三类事件,不含 checkpoint_revoked。 | | latest | vfs_monitor(含 devid / fs / index 等,供 backtrack 配对)与 checkpoint_revoked;后者经 expandCheckpointRevokedReason 展开 reason。 | | latest_inner | vfs_snapshot_dump_monitor(含 devid)与 checkpoint_revoked(同样展开 reason);适用于带 path 的内核 dump 形态。 |

未知 profile 名会回退到 default

hmtrace-parser/backtrack.js

在已解码、且 traceFieldDict 已填充的 RecordSample 上做 backtrack 配对:一侧为 FS checkpoint_revokedinvalid opcheckpoint_id + type === "0"),另一侧为内核 vfs_monitor 形态的样本(backtrack opdevid + fs + index,且无 revoked 字段形态)。当 devidfsindex 三者均一致 时视为同一对;devid/fs 使用 hiperf_txt_parserwhenBothHavecreateCompositeCompareindex 为两侧非空且字符串相等。

| 导出 | 说明 | |------|------| | backtrackFS(perfData \| samples, options?) | 返回 BacktrackResult[recordSamples, map]recordSamples 默认含输入顺序下的「非 FS revoked + 至少匹配一条 invalid-op 的 backtrack op」;map 的键为 backtrack op 原引用,值为 invalid-op 列表(按输入中出现顺序)。 | | BacktrackFSOptions | 可选;keepNonFsRevokedtrue(默认)保留非 FS checkpoint_revokedfalserecordSamples 中过滤。 | | BacktrackResult | 上述元组类型别名。日志前缀为 [backtrack]info 中 classified 含 keep_non_fs_revokedbacktrack_invalid_op 等计数。 |

开发

npm install
npm run build   # 输出到 dist/
npm test

许可证

MIT