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

sql/catalog/hydratedtables: add a cache for hydrated table descriptors and adopt #53323

Merged
merged 6 commits into from
Aug 27, 2020

Conversation

ajwerner
Copy link
Contributor

See individual commits.

Fixes #51385.

Release note: None

@ajwerner ajwerner requested review from thoszhang, rohany and a team August 24, 2020 14:41
@ajwerner ajwerner requested a review from a team as a code owner August 24, 2020 14:41
@ajwerner ajwerner requested review from adityamaru and removed request for a team August 24, 2020 14:41
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@ajwerner ajwerner force-pushed the ajwerner/hydrated-desc-cache branch from 0481dab to 79edd01 Compare August 24, 2020 14:58
@ajwerner ajwerner force-pushed the ajwerner/hydrated-desc-cache branch 3 times, most recently from bc63cd6 to f2fea7c Compare August 24, 2020 16:04
@ajwerner ajwerner force-pushed the ajwerner/hydrated-desc-cache branch from f2fea7c to 6f2da78 Compare August 25, 2020 05:33
@ajwerner
Copy link
Contributor Author

Good new is I benchmarked this and found:

name             old ops/s   new ops/s   delta
KV95-throughput  14.4k ± 2%  16.5k ± 1%  +14.52%  (p=0.008 n=5+5)

name             old ms/s    new ms/s    delta
KV95-P50          13.3 ± 2%   11.5 ± 0%  -13.53%  (p=0.000 n=5+4)
KV95-Avg          3.44 ± 2%   3.10 ± 0%   -9.88%  (p=0.008 n=5+5)

Still working though the logictest changes

@rohany
Copy link
Contributor

rohany commented Aug 25, 2020

nice, glad to see this measurable impact

@ajwerner ajwerner force-pushed the ajwerner/hydrated-desc-cache branch 2 times, most recently from 75fc91f to cdc0963 Compare August 26, 2020 22:50
@ajwerner
Copy link
Contributor Author

Okay @rohany I did less drastic things than at one point we discussed. I think this now works PTAL.

Copy link
Contributor

@rohany rohany left a comment

Choose a reason for hiding this comment

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

Going to take another pass at this tonight, but left some preliminary comments

// This case should not meaningfully arise in practice.
td := tableDescUDT.ImmutableCopy().(*tabledesc.Immutable)
{
hydrated, canUse, err := c.GetHydratedTableDescriptor(ctx, td, resWithMut)
Copy link
Contributor

Choose a reason for hiding this comment

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

why can we use cache in this case and below? Isn't the type modified

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can use does not mean that we definitely stored it in the cache, just that we hydrated it underneath the call.

Adds an IsHydrated method to types and then uses it to determine whether a type
should be hydrated.

Release note: None
This is handy when trying to determine whether we can cache a descriptor.

Release justification: Part of a change to eliminate a major performance
degradation for a new feature.

Release note: None
@ajwerner ajwerner force-pushed the ajwerner/hydrated-desc-cache branch from cdc0963 to d41f79f Compare August 27, 2020 13:00
This cache ends up being important for dealing with user-defined types.

Release note: None

Release justification:
Release note: None
When we hydrate a table descriptor which has been modified during the
transaction we want to ensure that we propagate the information that
indicates that it has been modified.

Release justification: Part of a larger fix to a major performance
enhancement for user-defined types, a new feature in this release.

Release note: None
@ajwerner ajwerner force-pushed the ajwerner/hydrated-desc-cache branch from d41f79f to 2b6e7c9 Compare August 27, 2020 14:04
@ajwerner
Copy link
Contributor Author

TFTR!

bors r=rohany

@craig
Copy link
Contributor

craig bot commented Aug 27, 2020

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Aug 27, 2020

Build succeeded:

@craig craig bot merged commit 3fd6e3b into cockroachdb:master Aug 27, 2020
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.

sql: implement a cache of table descriptors with type metadata
3 participants