Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed-up metric maintenance for component method calls. #440

Merged
merged 1 commit into from
Jul 5, 2023

Conversation

ghemawat
Copy link
Collaborator

name           old time/op  new time/op  delta
Call/Local-12   119ns ± 2%    96ns ± 1%  -19.32%  (p=0.008 n=5+5)

Removed the use of expvar in Metrics implementation. We are mostly doing this so that we can drop the promise that Service Weaver metrics are reflected in expvars. That frees us to speed things up by using a better representation.

Introduced an atomicFloat64 value so we can atomically add a float64. (This functionality was previously provided by expvar.)

Atomic storage for all metrics (though used just for counters) is now split into a float64 and a uint64. Integer increments are applied to the uint64 so we can avoid a more expensive compare-and-swap. The stored values are added together on a read. Doubles counter metric increment speed (from ~9.2ns to ~4.1ns).

Add a fast-path for histogram updates for small values by avoiding binary search.

Add a fast-path for histogram updates of zero by avoiding an atomic add.

```
name           old time/op  new time/op  delta
Call/Local-12   119ns ± 2%    96ns ± 1%  -19.32%  (p=0.008 n=5+5)
```

Removed the use of expvar in Metrics implementation. We are mostly
doing this so that we can drop the promise that Service Weaver metrics
are reflected in expvars. That frees us to speed things up by using a
better representation.

Introduced an atomicFloat64 value so we can atomically add a float64.
(This functionality was previously provided by expvar.)

Atomic storage for all metrics (though used just for counters) is now
split into a float64 and a uint64. Integer increments are applied to
the uint64 so we can avoid a more expensive compare-and-swap. The
stored values are added together on a read. Doubles counter metric
increment speed (from ~9.2ns to ~4.1ns).

Add a fast-path for histogram updates for small values by avoiding
binary search.

Add a fast-path for histogram updates of zero by avoiding an atomic
add.
@mwhittaker mwhittaker self-requested a review July 5, 2023 16:23
Copy link
Member

@mwhittaker mwhittaker left a comment

Choose a reason for hiding this comment

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

Amazing! Thanks, Sanjay!

@ghemawat ghemawat merged commit 0126493 into ServiceWeaver:main Jul 5, 2023
@ghemawat ghemawat deleted the noexpvar branch July 5, 2023 17:31
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