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

[FLINK-34134] Add tracing for restored state size and locations #24119

Conversation

StefanRRichter
Copy link
Contributor

What is the purpose of the change

Introduces tracing for state sizes and locations in task recovery. This is particularly interesting for a mixed recovery with some local and some remote state.

Brief change log

  • Add new stats collection default method to state object interface.
  • Implement StateObject type-specific overrides.
  • Perform stats collecting and reporting during restore.
  • Documentation.

Verifying this change

  • Added tests for stats collecting implementations.
  • Enhanced StreamTaskStateInitializerImplTest with checking tracing results.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (no)
  • The serializers: (no)
  • The runtime per-record code paths (performance sensitive): (no )
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes)
  • The S3 file system connector: (no)

Documentation

  • Does this pull request introduce a new feature? (yes)
  • If yes, how is the feature documented? ( docs / JavaDocs)

@flinkbot
Copy link
Collaborator

flinkbot commented Jan 17, 2024

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

Copy link
Contributor

@pnowojski pnowojski left a comment

Choose a reason for hiding this comment

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

Thanks for this extension @StefanRRichter. I don't see any major comments.


@Override
public String toString() {
return "StateObjectSizeStatsCollector{" + "stats=" + stats + '}';
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this print to a human readable map representation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

Comment on lines +148 to +157
private Stream<StateObjectCollection<? extends StateObject>> streamOperatorAndKeyedStates() {
return Stream.of(managedOperatorState, rawOperatorState, managedKeyedState, rawKeyedState)
.filter(Objects::nonNull);
}

private Stream<StateObjectCollection<? extends AbstractChannelStateHandle<?>>>
streamChannelStates() {
return Stream.<StateObjectCollection<? extends AbstractChannelStateHandle<?>>>of(
inputChannelState, resultSubpartitionState)
.filter(Objects::nonNull);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need two methods, can not we have just a single one returning both op and channel state?

edit: I see collectUniqueDelegates. Note, collectUniqueDelegates could be refactored to also support but ignore non channel state, and then we wouldn't need to differentiate between two types of handles? But I'm not sure which option is better so 🤷

Comment on lines +248 to +253
.forEach(channelHandle -> channelHandle.collectSizeStats(statsCollector));

// Report collected stats to metrics
statsCollector
.getStats()
.forEach(
Copy link
Contributor

Choose a reason for hiding this comment

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

If you are going all in with streams, why don't you merge those two?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One is still collecting remaining stats from channels, the second is reporting. I like to keep them separate.

Comment on lines 56 to 58
// This handle is just temporary and will the directory size will never be used for
// metrics, so we just fill it in as 0.
new DirectoryStateHandle(downloadDestination, 0L),
Copy link
Contributor

Choose a reason for hiding this comment

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

For completeness, why don't you pass here stateHandle.getStateSize()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to double check if that would do the right thing, I didn't care much because none of that is every reported, but yeah...if it works it's nicer.

@@ -159,6 +159,14 @@ Flink reports a single span trace for the whole checkpoint and job initializatio
<td>(Max/Sum)DownloadStateDurationMs<br><br>(optional - currently only supported by RocksDB Incremental)</td>
<td>The aggregated (max and sum) across all subtasks duration of downloading state files from the DFS.</td>
</tr>
<tr>
<td>(Max/Sum)RestoreStateSizeBytes.[location]<br><br>(optional - only reported if metrics.trace-restore-state-size is true)</td>
Copy link
Contributor

Choose a reason for hiding this comment

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

RestoredStateSizeBytes ? (ditto in the actual metric name)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fine with me.

Copy link
Contributor

@pnowojski pnowojski left a comment

Choose a reason for hiding this comment

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

LGTM assuming green azure!

@StefanRRichter StefanRRichter merged commit bdf3132 into apache:master Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants