Skip to content

lib/logstorage: add count_uniq_hll stats function - #1797

Open
will-jg wants to merge 7 commits into
VictoriaMetrics:masterfrom
will-jg:feat/count-uniq-hll
Open

will-jg wants to merge 7 commits into
VictoriaMetrics:masterfrom
will-jg:feat/count-uniq-hll

Conversation

@will-jg

@will-jg will-jg commented Sep 17, 2026

Copy link
Copy Markdown

Summary

  • Add LogsQL count_uniq_hll(field1, ..., fieldN) for fixed-memory HyperLogLog UV estimation (p=14, axiomhq/hyperloglog v0.3.0), addressing high-cardinality OOM with count_uniq / count_uniq_hash.
  • Versioned wire format for cluster merge (remote/local/proxy): nodes exchange sketches, not unique-value sets; vlselect and vlstorage must both be upgraded to use this function.
  • Docs/CHANGELOG updates; empty values skipped; numeric strings like 1/01 share the same hash domain.

Closes #1414

Test plan

  • go test -mod=vendor ./lib/logstorage/ -run 'CountUniqHLL|TestHLL'
  • Fuzz FuzzHLLUnmarshalState (short)
  • Benchmarks BenchmarkHLL*
  • CI on this PR
  • Manual cluster smoke: overlapping UV across two vlstorage nodes; result must not equal sum of per-node estimates

Add HyperLogLog-based approximate unique count for high-cardinality UV
queries without O(cardinality) memory. Uses axiomhq/hyperloglog p=14 with
a versioned wire format for cluster merge. Relates to VictoriaMetrics#1414.
Cover typed column hash consistency, remote/local/proxy merge paths,
merge algebra, wire golden round-trips, fuzzed unmarshal, accuracy
distribution, state budget/heap checks, and basic benchmarks.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 29 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread lib/logstorage/hll.go
Comment thread lib/logstorage/hll.go
Comment thread lib/logstorage/stats_count_uniq_hll.go Outdated
Comment thread lib/logstorage/hll.go Outdated
will-jg and others added 2 commits September 18, 2026 10:30
Merge on importState so repeated remote states for the same group are
unioned instead of replaced. Normalize -0 to unsigned zero, strip
leading zeros before parsing, and apply the same numeric canonical
encoding on multi-field tuples.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread lib/logstorage/hll.go Outdated
will-jg and others added 3 commits September 18, 2026 11:15
Validate Axiom payload precision against p=14 and return an error
instead of Panicf when merging untrusted imported wire state.
Resolve conflicts in go.mod/go.sum, vendor/modules.txt, and CHANGELOG
while keeping count_uniq_hll and its HyperLogLog dependencies.
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.

Add count_uniq_hll stats function to LogsQL for memory-efficient UV estimation

1 participant