Skip to content

SimpleCollecor.labels() initialization performance#307

Merged
brian-brazil merged 1 commit intoprometheus:masterfrom
mcoolive:master
Nov 30, 2017
Merged

SimpleCollecor.labels() initialization performance#307
brian-brazil merged 1 commit intoprometheus:masterfrom
mcoolive:master

Conversation

@mcoolive
Copy link
Copy Markdown

@mcoolive mcoolive commented Nov 6, 2017

  • Now, we do 3 lookups in the children Map when we create a new tupple of
    labels. From my understanding, it's to manage concurrent initializations.

It can be improved. I suggest to check the result of 'putIfAbsent' to avoid the third
lookup.

Because we do not want to create a new Child for each call to #labels, I
don't find a solution with only 1 lookup. BUT with Java 8, we can consider
the use of 'computeIfAbsent' with a lambda.

- Now, we do 3 lookups in the children Map when we create a new tupple of
labels. From my understanding, it's to manage concurrent initializations.

It can be improved. I suggest to check the result of 'putIfAbsent' to avoid the third
lookup.

Because we do not want to create a new Child for each call to #labels, I
don't find a solution with only 1 lookup. BUT with Java 8, we can consider
the use of 'computeIfAbsent' with a lambda.
@mcoolive
Copy link
Copy Markdown
Author

An opinion would be welcome.

@brian-brazil brian-brazil merged commit 6b10e1f into prometheus:master Nov 30, 2017
@brian-brazil
Copy link
Copy Markdown
Contributor

Thanks!

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