Skip to content

[refactor][P3] bloomx.hash 每次 Add/Test 分配临时缓冲(查询热路径) #385

Closed

Description

@zy84338719

来源:2026-11-11 全矩阵深度代码审查(6 路并行扫描约 24 万行 Go)。判定已复核;行号基于 2026-11-11 的 main,动手前请核对现场。
归档索引:#372(本仓重构 backlog)

位置

pkg/bloomx/bloom.go:147-151(二轮审查发现,已人工复核)

证据

h1 = mix64(encoding.Fnv1a64(b))
// 拼盐走独立缓冲,避免 append 改写调用方切片的底层数组
buf := make([]byte, len(b)+1)
copy(buf, b)
buf[len(b)] = hashSalt
h2 = mix64(encoding.Fnv1a64(buf))

Test/TestBytes 是布隆过滤器的逐查询热路径,每次都为「拼盐算 h2」整段拷贝输入。

建议

FNV-1a 是流式哈希——先 Fnv1a64(b) 得 h1 后,对盐字节继续 mix((h ^ salt) * prime)即可免拷贝;顺带收益:h1 与 h2 共享一次遍历。

Activity

  1. moved this from Todo to In Progress in oekit Issue 大盘on Nov 12, 2026
  2. added a commit that references this issue on Nov 12, 2026
  3. moved this from In Progress to Done in oekit Issue 大盘on Nov 12, 2026
  4. zy84338719 commented on Nov 12, 2026

    @zy84338719
    ContributorAuthor

    已合入修复 ✅(无 SemVer 发布:本次改动不发版本)

    变更内容

    bloomx 盐字节在 FNV-1a 中间态续算(数学等价哈希不变),Add/Test 热路径零分配

    合入:PR #423(https://github.com/oekit/pkg/pull/423),merge commit 53135ccf,2026-11-12T17:13:18Z

    CI:link ✅ / Lint & Test / Test ✅ / Lint & Test / Lint ✅ / Zero Third-Party Deps ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactor重构机会(代码审查产出)

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions