Skip to content

optional: add Duration#56951

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
asubiotto:tmvl
Nov 30, 2020
Merged

optional: add Duration#56951
craig[bot] merged 1 commit intocockroachdb:masterfrom
asubiotto:tmvl

Conversation

@asubiotto
Copy link
Copy Markdown
Contributor

This commit adds a TimeValue protobuf that is used to represent time.Duration
statistics in the ComponentStats proto. Similar to the IntValue struct, this
protobuf allows differentiating between set and unset values.

These stats were previously stored as time.Durations but EXPLAIN ANALYZE logic
test flakiness on recent PRs have shown that it is valid for a time.Duration to
be set to 0 in some cases (when recording less than a ns of time). The
ComponentStats formatting code assumes a time of 0 is unset, so this would
cause some time labels to be elided from the diagram non-deterministically.

Release note: None

@asubiotto asubiotto requested review from a team and RaduBerinde November 20, 2020 14:30
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

Nice! I was initially thinking that we'd make sure any kind of timer returns at least 1ns. But that is more error prone, and this is more consistent with the int stats.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @asubiotto and @RaduBerinde)


pkg/sql/execinfrapb/component_stats.go, line 143 at r1 (raw file):

	timeVal := func(v *TimeValue) {
		if v.HasValue() {
			v.Set(1)

[nit] time.Nanosecond instead of 1


pkg/sql/execinfrapb/component_stats.proto, line 116 at r1 (raw file):

// The underlying value is the logical value plus 1, so that zero remains the
// special case of having no value.
message TimeValue {

This is a better design than IntValue: we can't inadvertently set or compare to literal constants, or print with '%d'. It causes an extra byte in the encoded data but that's unlikely to matter.
I will switch IntValue to this design too, and move them both to a separate util/optional package (because I would already use them in other places).


pkg/sql/execinfrapb/component_stats.proto, line 120 at r1 (raw file):

  // RawValue is the TimeValue's underlying value.
  // DO NOT ACCESS THIS DIRECTLY. Use HasValue and Value instead.
  optional google.protobuf.Duration raw_value = 1 [(gogoproto.nullable) = false,

[nit] could be value_plus_one so it's more clear and less likely that someone will use it without realizing that

Copy link
Copy Markdown
Contributor Author

@asubiotto asubiotto left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @RaduBerinde)


pkg/sql/execinfrapb/component_stats.proto, line 116 at r1 (raw file):

Previously, RaduBerinde wrote…

This is a better design than IntValue: we can't inadvertently set or compare to literal constants, or print with '%d'. It causes an extra byte in the encoded data but that's unlikely to matter.
I will switch IntValue to this design too, and move them both to a separate util/optional package (because I would already use them in other places).

👍 I'll wait for your optional PR to go in before moving it and merging this PR.


pkg/sql/execinfrapb/component_stats.proto, line 120 at r1 (raw file):

Previously, RaduBerinde wrote…

[nit] could be value_plus_one so it's more clear and less likely that someone will use it without realizing that

Good idea.

@asubiotto asubiotto changed the title execinfrapb: add TimeValue optional: add Duration Nov 24, 2020
Copy link
Copy Markdown
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @RaduBerinde)

This commit adds a optional.Duration protobuf that is used to represent
time.Duration statistics in the ComponentStats proto. Similar to the
optional.Uint struct, this protobuf allows differentiating between set and
unset values.

These stats were previously stored as time.Durations but EXPLAIN ANALYZE logic
test flakiness on recent PRs have shown that it is valid for a time.Duration to
be set to 0 in some cases (when recording less than a ns of time). The
ComponentStats formatting code assumes a time of 0 is unset, so this would
cause some time labels to be elided from the diagram non-deterministically.

Release note: None
@asubiotto
Copy link
Copy Markdown
Contributor Author

TFTR

bors r=RaduBerinde

craig bot pushed a commit that referenced this pull request Nov 30, 2020
56951: optional: add Duration r=RaduBerinde a=asubiotto

This commit adds a TimeValue protobuf that is used to represent time.Duration
statistics in the ComponentStats proto. Similar to the IntValue struct, this
protobuf allows differentiating between set and unset values.

These stats were previously stored as time.Durations but EXPLAIN ANALYZE logic
test flakiness on recent PRs have shown that it is valid for a time.Duration to
be set to 0 in some cases (when recording less than a ns of time). The
ComponentStats formatting code assumes a time of 0 is unset, so this would
cause some time labels to be elided from the diagram non-deterministically.

Release note: None

Co-authored-by: Alfonso Subiotto Marques <alfonso@cockroachlabs.com>
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Nov 30, 2020

Build failed:

@asubiotto
Copy link
Copy Markdown
Contributor Author

Looks like an unrelated TestTrace failure/timeout.

bors r=RaduBerinde

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Nov 30, 2020

Build succeeded:

@craig craig bot merged commit d9f7bcb into cockroachdb:master Nov 30, 2020
@asubiotto asubiotto deleted the tmvl branch December 1, 2020 09:58
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.

3 participants