Skip to content

Conversation

@jdmarshall
Copy link
Contributor

@jdmarshall jdmarshall commented Jul 29, 2025

Use a similar strategy to LabelMap for stats coalescing for cluster.js

This has to wrestle with the problem of lack of fore-knowledge of the
canonical set of labels. We achieve this by assuming 6 labels to
begin with, first filling in the empties as we discover new ones, and
tnen expanding the columns by ⌈25%⌉ if they don't, and re-keying the
entire table (by concatenating extra ||'s onto the end)..

cluster ⇒ aggregate()

Summary (vs. baseline):
 ⇒ prom-client@latest            | ██████████─────────────── | 4.18 ops/sec | 11 samples (baseline)
 ⇒ prom-client@trunk             | ██████████▌────────────── | 4.26 ops/sec | 11 samples (1.02x faster)
 ⇒ prom-client@current           | █████████████████████████ | 10 ops/sec | 11 samples (2.40x faster)

@jdmarshall jdmarshall changed the title Cluster labels 2.5x improvement in Cluster aggregation performance Jul 29, 2025
@jdmarshall
Copy link
Contributor Author

jdmarshall commented Jul 29, 2025

This should fix #628

A lot of the gain here is that keyFrom is roughly 2x as fast as hashObject. But the shorter key also makes the Map a little faster, and the memory pressure a bit better.

@jdmarshall
Copy link
Contributor Author

Node 20 did not support Iterator.filter??

I'm surprised it's still in LTS. Working on it.

@jdmarshall jdmarshall changed the title 2.5x improvement in Cluster aggregation performance 2.4x improvement in Cluster aggregation performance Jul 29, 2025
@jdmarshall jdmarshall force-pushed the clusterLabels branch 2 times, most recently from b3916cd to c37ed35 Compare November 3, 2025 23:48
@SimenB
Copy link
Collaborator

SimenB commented Nov 27, 2025

@jdmarshall sorry, missed this. Mind resolving the conflict? Your new benchmark runner has also landed 🙂

This also fixes issue with prettier.
This reverts most of commit 9251668.

Except for some of the tests.
This has to wrestle with the problem of lack of fore-knowledge of the
canonical set of labels. We achieve this by assuming 6 labels to
begin with, first filling in the empties as we discover new ones, and
tnen expanding the columns by ⌈25%⌉ if they don't, and re-keying the
entire table (by concatenating extra ||'s onto the end)..

Before and after:

✓ cluster ➭ aggregate() is 6.088% faster.
✓ cluster ➭ aggregate() is 149.4% faster.
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.

2 participants