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

stats: Use SymbolTable API for creating and representing stat names. #6161

Merged
merged 52 commits into from
Apr 26, 2019

Conversation

jmarantz
Copy link
Contributor

@jmarantz jmarantz commented Mar 4, 2019

Description: This PR takes a significant step toward resolving #3585 and #4196 by integrating the symbol table API natively into heap-based stats. There is no real symbol-table live in the code yet. The benefit of this PR is that it allows us to begin a series of PRs throughout the codebase to use the symbol-table API to lookup/create stats rather than raw strings.

In this PR we use a fake symbol table implementation, which reduces the functional risk, but it also doesn't yield 100% of the memory benefit yet.

It does yield significant benefit though -- because it changes the storage model for tags and tag-extracted names to store them all contiguously in a block of memory rather than as discrete std::string objects. This alone reduces memory usage about 25% based on HeapStatsThreadLocalStoreTest.MemoryWithoutTls and HeapStatsThreadLocalStoreTest.MemoryWithTls.

The next step is a series of fairly small PRs that will change various subsystems to use this interface rather than specifying stats by string literals. Once this is done, with the constituent symbols in most cases allocated at startup time rather than ad-hoc, the symbol-table implementation can be switched out from a fake version (that just uses raw strings underneath) into the real version, where there is sharing of symbols.

Risk Level: medium -- this is a pretty large refactor. There is some functional risk as well as performance risk. However this is intended to be an essentially non-functional refactor.
Testing: //test/...
Docs Changes: Updated stats.md to reflect the plan.
Release Notes: n/a

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@mattklein123 mattklein123 self-assigned this Mar 10, 2019
…mbol tables.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
…s impacting microbenchmarks.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
…lls. Helped but not too much.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
…ing each element.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
…temp creation.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
…, etc.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
jmarantz added a commit to jmarantz/envoy that referenced this pull request Mar 15, 2019
…oxy#6161.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
jmarantz added a commit to jmarantz/envoy that referenced this pull request Mar 15, 2019
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
jmarantz added a commit that referenced this pull request Mar 19, 2019
)

* Plumb through symbol tables everywhere. Pulled from #6161.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Flushing out some comments. The main thing to sort out is merge order between this and the hot restart change. My personal preference is to land the hot restart change first since it's pretty close but will let you and @fredlas sort it out.

The other thing I would like to figure out is how to avoid the manual memory management that callers need to do here. I think we can provide some type of smart pointer, RAII guard, etc. to handle this?

Thank you!

/wait

include/envoy/stats/tag_producer.h Show resolved Hide resolved
source/common/stats/heap_stat_data.h Show resolved Hide resolved
source/common/stats/metric_impl.cc Outdated Show resolved Hide resolved
source/common/stats/metric_impl.h Outdated Show resolved Hide resolved
source/common/stats/raw_stat_data.cc Show resolved Hide resolved
htuch pushed a commit that referenced this pull request Apr 24, 2019
…ons. (#6688)

Per @ambuc's comment on #6161 I think it would be better to keep a log of the memory consumed by stats, and also use exact comparisons. That way we can get historical perspective into the relative impact of adding new stats or families of stats.

Risk Level: low, but could cause more changes to this one test.
Testing: just this one test.
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

/wait-any

source/extensions/stat_sinks/hystrix/hystrix.cc Outdated Show resolved Hide resolved
…strix.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
…t most call-sites outside of stats to use.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: coverage (failed build)

🐱

Caused by: a #6161 (comment) was created by @jmarantz.

see: more, trace.

@jmarantz
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: coverage (failed build)

🐱

Caused by: a #6161 (comment) was created by @jmarantz.

see: more, trace.

@jmarantz
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: coverage (failed build)

🐱

Caused by: a #6161 (comment) was created by @jmarantz.

see: more, trace.

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

LGTM with one thing. Very cool stuff!

/wait

// can complete properly, even if the tag values are partially truncated.
std::string tag_extracted_name = parent_.getTagsForName(name, tags);
TagExtraction extraction(parent_, name);
// std::shared_ptr<StatType> stat = make_stat(parent_.alloc_, extraction.truncatedStatName(),
Copy link
Member

Choose a reason for hiding this comment

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

? delete?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ouch, yes. WDYT about a quick follow-up for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

never mind; deleted.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Sorry, follow up would have been fine. Very nice!

@jmarantz
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: release (failed build)

🐱

Caused by: a #6161 (comment) was created by @jmarantz.

see: more, trace.

@jmarantz jmarantz merged commit 304ec56 into envoyproxy:master Apr 26, 2019
@jmarantz jmarantz deleted the stats-symtab-interface branch April 26, 2019 14:52
jeffpiazza-google pushed a commit to jeffpiazza-google/envoy that referenced this pull request Apr 26, 2019
…nvoyproxy#6161)

* Use SymbolTable API for creating and representing stat names.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Jeff Piazza <jeffpiazza@google.com>
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.

4 participants