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

validate: use immutable descriptors only #95830

Merged

Conversation

postamar
Copy link
Contributor

The descriptor validation logic will accept any implementation of catalog.Descriptor be it mutable or immutable, it doesn't care. However, using mutable implementations can have a significant performance impact especially in the case of tables, where every column or index or constraint lookup will lead to the cache being regenerated for the whole descriptor.

This commit fixes this by having validate.Validate replace any mutable descriptor instances it encounters with immutable copies. This doesn't change anything except performance.

Fixes #95827.

Release note: None

The descriptor validation logic will accept any implementation of
catalog.Descriptor be it mutable or immutable, it doesn't care. However,
using mutable implementations can have a significant performance impact
especially in the case of tables, where every column or index or
constraint lookup will lead to the cache being regenerated for the whole
descriptor.

This commit fixes this by having validate.Validate replace any mutable
descriptor instances it encounters with immutable copies. This doesn't
change anything except performance.

Fixes cockroachdb#95827.

Release note: None
@blathers-crl
Copy link

blathers-crl bot commented Jan 25, 2023

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@postamar postamar marked this pull request as ready for review January 25, 2023 16:29
@postamar postamar requested a review from a team January 25, 2023 16:29
Copy link
Contributor

@ajwerner ajwerner 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 @postamar)


pkg/sql/catalog/internal/validate/validate.go line 416 at r1 (raw file):

		return nil, nil
	}
	resps, err := vd.DereferenceDescriptors(ctx, version, reqs)

Out of curiosity, when does dereferenceDescriptors return mutables?

@postamar
Copy link
Contributor Author

Out of curiosity, when does dereferenceDescriptors return mutables?

It doesn't now, I don't think. It's just some defensive coding.

@postamar
Copy link
Contributor Author

Thanks for the review!

bors r+

@craig
Copy link
Contributor

craig bot commented Jan 25, 2023

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Jan 25, 2023

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Jan 26, 2023

Build succeeded:

@craig craig bot merged commit 4858095 into cockroachdb:master Jan 26, 2023
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.

validate: use immutable descriptors only
3 participants