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

Record source information of HBO stats #22234

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

feilong-liu
Copy link
Contributor

@feilong-liu feilong-liu commented Mar 19, 2024

Description

This PR records more information about HBO stats, including what type of workers (currently c++ and Java) are these stats from, and the query ID which generates these stats.

Motivation and Context

Adding worker type because HBO tracks the size of operator output, however this size can be dependent on the data structure used and compaction algorithm when used. Hence it's expected that presto java and presto c++ can report different size. We need to log this information in HBO stats.

Adding query ID is for debugging purpose. This can help to identify the query which populates the stats quickly.

Impact

Improve on HBO stats to make it more precise and easier to debug.

Test Plan

End to end test locally to make sure these stats are available in logging.

Contributor checklist

  • Please make sure your submission complies with our development, formatting, commit message, and attribution guidelines.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== RELEASE NOTES ==

General Changes
* Add worker type and query ID information in HBO stats.

@feilong-liu feilong-liu requested review from shrinidhijoshi and a team as code owners March 19, 2024 00:11
@feilong-liu feilong-liu requested a review from presto-oss March 19, 2024 00:11
@feilong-liu feilong-liu marked this pull request as draft March 19, 2024 00:11
@tdcmeehan
Copy link
Contributor

Does it make sense to encode the environment and version? The environment could identify the deployment that wrote the stats (including the eval engine used), and the version could be used to identify any anomalies introduced in the metrics that may vary between version. Similar to how we embed the version in things like Parquet file metadata.

@feilong-liu feilong-liu force-pushed the hbo_cpp_label branch 2 times, most recently from 3c1aa54 to 6de650a Compare March 19, 2024 22:03
@feilong-liu
Copy link
Contributor Author

Does it make sense to encode the environment and version? The environment could identify the deployment that wrote the stats (including the eval engine used), and the version could be used to identify any anomalies introduced in the metrics that may vary between version. Similar to how we embed the version in things like Parquet file metadata.

Currently I plan to include the type of workers and the query ID of the queries which produce the history statistics. I do not see immediate need of adding environment and version, and they can be inferred from query ID with proper logging. We can add them later if needed, just I do not see immediate need for now.

@feilong-liu feilong-liu changed the title Record if HBO stats is from CPP or JAVA Record source information of HBO stats Mar 19, 2024
@feilong-liu feilong-liu force-pushed the hbo_cpp_label branch 3 times, most recently from 82abb6d to 01f9257 Compare March 21, 2024 17:57
{
requireNonNull(objectMapper, "objectMapper is null");
this.sessionPropertyManager = requireNonNull(sessionPropertyManager, "sessionPropertyManager is null");
this.historyBasedStatisticsCacheManager = new HistoryBasedStatisticsCacheManager();
ObjectMapper newObjectMapper = objectMapper.copy().configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
this.planCanonicalInfoProvider = new CachingPlanCanonicalInfoProvider(historyBasedStatisticsCacheManager, newObjectMapper, metadata);
this.config = requireNonNull(config, "config is null");
this.isNativeExecution = featuresConfig.isNativeExecutionEnabled();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check if it's native execution, and record the information when writing stats to HBO

if (predictedPlanStatistics.getConfidence() > 0) {
return delegateStats.combineStats(
predictedPlanStatistics,
new HistoryBasedSourceInfo(entry.getKey().getHash(), inputTableStatistics, Optional.of(historicalPlanStatisticsEntry.get().getHistoricalPlanStatisticsEntryInfo())));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add the source information to plan statistics returned from HBO.

Comment on lines 146 to 151
HistoricalPlanStatisticsEntryInfo historicalPlanStatisticsEntryInfo = new HistoricalPlanStatisticsEntryInfo(
isNativeExecution ? HistoricalPlanStatisticsEntryInfo.WorkerType.CPP : HistoricalPlanStatisticsEntryInfo.WorkerType.JAVA, queryInfo.getQueryId());

Copy link
Contributor Author

Choose a reason for hiding this comment

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

record the worker type and query ID when recording the HBO stats

Copy link
Member

Choose a reason for hiding this comment

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

Can we get this isNativeExecution property via session directly? queryInfo.getSession().toSession(sessionPropertyManager); That way you wound not need to inject featuresConfig

Copy link
Contributor

Choose a reason for hiding this comment

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

@jaystarshot Jay, we explicitly removed this property from the sessions because it doesn't make sense to allow this to be modified for individual queries. This is a cluster-wide property. I have a PR to actually delete it: #22183

CC: @tdcmeehan

@feilong-liu feilong-liu marked this pull request as ready for review March 21, 2024 18:31
@rschlussel
Copy link
Contributor

I like the idea of recording the version. That way if there's a problem with stats from some release or some big change in an operator that would make old stats not relevant, we could programatically exclude those stats from being used.

{
requireNonNull(objectMapper, "objectMapper is null");
this.sessionPropertyManager = requireNonNull(sessionPropertyManager, "sessionPropertyManager is null");
this.historyBasedStatisticsCacheManager = new HistoryBasedStatisticsCacheManager();
ObjectMapper newObjectMapper = objectMapper.copy().configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
this.planCanonicalInfoProvider = new CachingPlanCanonicalInfoProvider(historyBasedStatisticsCacheManager, newObjectMapper, metadata);
this.config = requireNonNull(config, "config is null");
this.isNativeExecution = featuresConfig.isNativeExecutionEnabled();
this.serverVersion = requireNonNull(nodeVersion, "nodeVersion is null").toString();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add information for server version

@feilong-liu
Copy link
Contributor Author

I like the idea of recording the version. That way if there's a problem with stats from some release or some big change in an operator that would make old stats not relevant, we could programatically exclude those stats from being used.

Add server version per suggestion.

Record the type of workers (CPP, JAVA) and query ID of the queries
which produce these stats.
@feilong-liu feilong-liu merged commit 8b8c9e4 into prestodb:master Mar 26, 2024
56 checks passed
@feilong-liu feilong-liu deleted the hbo_cpp_label branch March 26, 2024 19:42
@wanglinsong wanglinsong mentioned this pull request May 1, 2024
48 tasks
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.

6 participants