Skip to content

sql/distsqlplan: avoid excessive data copying#28942

Merged
craig[bot] merged 2 commits intocockroachdb:masterfrom
knz:20180822-minor-improv
Aug 23, 2018
Merged

sql/distsqlplan: avoid excessive data copying#28942
craig[bot] merged 2 commits intocockroachdb:masterfrom
knz:20180822-minor-improv

Conversation

@knz
Copy link
Copy Markdown
Contributor

@knz knz commented Aug 22, 2018

First commit from #28937.
Needed for #28690.

The ColumnType struct is not trivially small. Also calling a
by-pointer method on a copy may cause it to escape on the heap. Avoid
making copies until necessary.

Release note: None

@knz knz requested review from a team, asubiotto and solongordon August 22, 2018 08:17
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

knz added 2 commits August 22, 2018 10:28
The functions to retrieve the sizes of value encodings have not been
used in a long time. Remove them.

Release note: None
The `ColumnType` struct is not trivially small. Also calling a
by-pointer method on a copy may cause it to escape on the heap. Avoid
making copies until necessary.

Release note: None
@knz knz force-pushed the 20180822-minor-improv branch from f7b99e1 to dbd7623 Compare August 22, 2018 08:29
Copy link
Copy Markdown
Member

@BramGruneir BramGruneir left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 4 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/sql/distsqlplan/physical_plan.go, line 891 at r2 (raw file):

			merged[i] = *leftType
		} else {
			return nil, errors.Errorf("conflicting ColumnTypes: %v and %v", leftType, rightType)

shouldn't these also be referenced?

Also, is %v correct here?
And if ColumnType doesn't have a String() yet, it should. I think I hit upon the annoyance of this while debugging recently.

Copy link
Copy Markdown
Contributor Author

@knz knz 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


pkg/sql/distsqlplan/physical_plan.go, line 891 at r2 (raw file):

Previously, BramGruneir (Bram Gruneir) wrote…

shouldn't these also be referenced?

Also, is %v correct here?
And if ColumnType doesn't have a String() yet, it should. I think I hit upon the annoyance of this while debugging recently.

It has already, it's implemented on the pointer type, so this fine.

Copy link
Copy Markdown
Member

@BramGruneir BramGruneir left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 1 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)

@knz
Copy link
Copy Markdown
Contributor Author

knz commented Aug 23, 2018

thank you!

bors r+

craig bot pushed a commit that referenced this pull request Aug 23, 2018
28942: sql/distsqlplan: avoid excessive data copying r=knz a=knz

First commit from  #28937.
Needed for #28690.

The `ColumnType` struct is not trivially small. Also calling a
by-pointer method on a copy may cause it to escape on the heap. Avoid
making copies until necessary.

Release note: None

Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Aug 23, 2018

Build succeeded

@craig craig bot merged commit dbd7623 into cockroachdb:master Aug 23, 2018
@knz knz deleted the 20180822-minor-improv branch August 23, 2018 07:25
craig bot pushed a commit that referenced this pull request Aug 23, 2018
28943: sqlbase: add the missing comments and group functions by purpose r=knz a=knz

First commits from #28942 and priors.
Forked from #28690.

The file `table.go` was getting unwieldy and was containing functions
from different area of concern. This was making maintenance
particularly burdensome.

This patch splits the functionality in the following files:

- `index_encoding.go`: index key prefixes, differences between primary
  and secondary encodings, how to organize columns in an index.

- `column_type_encoding.go`: encoding of SQL values into bytes
  towards KV.

- `column_type_properties.go`: conversions between various
  representations of types in the SQL layer; derivation of properties
  from SQL types.

- `datum_alloc.go`: the `DatumAlloc` helper.

Release note: None


Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
craig bot pushed a commit that referenced this pull request Aug 23, 2018
29006: backport-2.1: fix the handling of SQL types r=knz a=knz

Backport 1/1 commits from #28937.
Backport 1/1 commits from #28942.
Backport 17/17 commits from #28943.
Backport 1/1 commits from #28944.
Backport 1/1 commits from #28945.
Backport 1/1 commits from #28949.
Backport 2/2 commits from #28950.
Backport 1/1 commits from #28951 (#28959).
Backport 1/1 commits from #28952 (#28959).
Backport 1/1 commits from #28955 (#28959).
Backport 1/1 commits from #28959.
Backport 1/1 commits from #28959.
Backport 1/1 commits from #28690.

cc @cockroachdb/release 

Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
craig bot pushed a commit that referenced this pull request Aug 24, 2018
29006: backport-2.1: fix the handling of SQL types r=knz a=knz

Backport 1/1 commits from #28937.
Backport 1/1 commits from #28942.
Backport 17/17 commits from #28943.
Backport 1/1 commits from #28944.
Backport 1/1 commits from #28945.
Backport 1/1 commits from #28949.
Backport 2/2 commits from #28950.
Backport 1/1 commits from #28951 (#28959).
Backport 1/1 commits from #28952 (#28959).
Backport 1/1 commits from #28955 (#28959).
Backport 1/1 commits from #28959.
Backport 1/1 commits from #28959.
Backport 1/1 commits from #28690.

cc @cockroachdb/release 

Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.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.

3 participants