Skip to content

Conversation

@daisyzhou
Copy link
Contributor

@daisyzhou daisyzhou commented Jul 30, 2025

Much like in FastCounter, make FastGauge use one ETS table per scheduler. It's much faster (12-35x faster) than the single-table FastGauge implementation in a concurrent environment.

Compared with vanilla Statix.gauge it's up to 145x faster in a concurrent envinroment

@daisyzhou daisyzhou marked this pull request as ready for review July 30, 2025 21:48
@daisyzhou daisyzhou requested a review from ollien July 30, 2025 21:48
Copy link
Contributor

@ollien ollien left a comment

Choose a reason for hiding this comment

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

LGTM, just a style suggestion

Comment on lines 60 to 76
table_name
|> :ets.tab2list()
|> Enum.reduce(
acc,
fn {table_key, {value, timestamp}}, acc ->
:ets.delete_object(table_name, {table_key, {value, timestamp}})

# Only keep most recent timestamp
Map.update(acc, table_key, {value, timestamp}, fn {existing_value, existing_timestamp} ->
if existing_timestamp > timestamp do
{existing_value, existing_timestamp}
else
{value, timestamp}
end
end)
end
)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you could break this into its own function like aggregate_table_values, and then replace this pipeline with

table_results = aggregate_table_values(table_name)
Map.merge(acc, table_results)

@daisyzhou daisyzhou merged commit 6083acf into master Jul 31, 2025
0 of 5 checks passed
@daisyzhou daisyzhou deleted the fastergauge branch July 31, 2025 18:27
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.

3 participants