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

add opaque type support to vector fuzzer #11189

Closed
wants to merge 1 commit into from

Conversation

kunigami
Copy link
Contributor

@kunigami kunigami commented Oct 7, 2024

Summary:
In preparation for supporting Opaque types in Presto page serialization, I'd like to add support to fuzz testing to them.

The idea is that each custom type will have to provide its own randomizing function, since it's otherwise impossible for the framework to do so.

Differential Revision: D63998462

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 7, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D63998462

Copy link

netlify bot commented Oct 7, 2024

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 0e2d1a2
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/672050eae7f2e6000878def5

@kunigami kunigami requested review from kagamiori and pedroerp October 7, 2024 19:51
kunigami pushed a commit to kunigami/velox that referenced this pull request Oct 8, 2024
Summary:

In preparation for supporting Opaque types in Presto page serialization, I'd like to add support to fuzz testing to them.

The idea is that each custom type will have to provide its own randomizing function, since it's otherwise impossible for the framework to do so.

Differential Revision: D63998462
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D63998462

kunigami pushed a commit to kunigami/velox that referenced this pull request Oct 14, 2024
Summary:

In preparation for supporting Opaque types in Presto page serialization, I'd like to add support to fuzz testing to them.

The idea is that each custom type will have to provide its own randomizing function, since it's otherwise impossible for the framework to do so.

Differential Revision: D63998462
kunigami pushed a commit to kunigami/velox that referenced this pull request Oct 15, 2024
Summary:

In preparation for supporting Opaque types in Presto page serialization, I'd like to add support to fuzz testing to them.

The idea is that each custom type will have to provide its own randomizing function, since it's otherwise impossible for the framework to do so.

Differential Revision: D63998462
kunigami pushed a commit to kunigami/velox that referenced this pull request Oct 15, 2024
Summary:

In preparation for supporting Opaque types in Presto page serialization, I'd like to add support to fuzz testing to them.

The idea is that each custom type will have to provide its own randomizing function, since it's otherwise impossible for the framework to do so.

Differential Revision: D63998462
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D63998462

kunigami pushed a commit to kunigami/velox that referenced this pull request Oct 15, 2024
Summary:

In preparation for supporting Opaque types in Presto page serialization, I'd like to add support to fuzz testing to them.

The idea is that each custom type will have to provide its own randomizing function, since it's otherwise impossible for the framework to do so.

Differential Revision: D63998462
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D63998462

Copy link
Contributor

@bikramSingh91 bikramSingh91 left a comment

Choose a reason for hiding this comment

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

looks good, just a few small comments

VectorPtr VectorFuzzer::fuzzFlatOpaque(
const TypePtr& type,
vector_size_t size) {
auto vector = BaseVector::create(type, size, pool_);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: add a VELOX_CHECK to ensure the type is indeed opaque


auto& opaqueType = type->asOpaque();
auto flatVector = vector->as<TFlat>();
auto& opaqueTypeGenerator = opaqueTypeGenerators_[opaqueType.typeIndex()];
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: should we check first if a generator exists and return an error if it doesnt?

Comment on lines 646 to 657
for (size_t i = 0; i < vector->size(); ++i) {
flatVector->set(i, opaqueTypeGenerator(rng_));
}

for (size_t i = 0; i < vector->size(); ++i) {
if (coinToss(opts_.nullRatio)) {
flatVector->setNull(i, true);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

should we merge these and skip generation if a row is set to null?

@@ -374,6 +386,11 @@ class VectorFuzzer {
// function. C++ does not guarantee the order in which arguments are
// evaluated, which can lead to inconsistent results across platforms.
FuzzerGenerator rng_;

std::unordered_map<
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can you add a comment about what it contains and how its populated?

private:
// Generates a flat vector for primitive types.
VectorPtr fuzzFlatPrimitive(const TypePtr& type, vector_size_t size);

// Generates a flat vector for opaque types.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: after you add the checks I mentioned earlier, can you also update the comment to mention that it can throw for those cases

kunigami pushed a commit to kunigami/velox that referenced this pull request Oct 16, 2024
Summary:

In preparation for supporting Opaque types in Presto page serialization, I'd like to add support to fuzz testing to them.

The idea is that each custom type will have to provide its own randomizing function, since it's otherwise impossible for the framework to do so.

Differential Revision: D63998462
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D63998462

VectorFuzzer::Options opts;
opts.nullRatio = 0.5;
VectorFuzzer fuzzer(opts, pool());
fuzzer.registerOpaqueTypeGenerator<Foo>([](FuzzerGenerator& rng) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you register two OpaqueTypeGenerators for Foo and Bar to ensure the correct one can be retrieved?

VectorFuzzer::Options opts;
opts.nullRatio = 0.5;
VectorFuzzer fuzzer(opts, pool());
fuzzer.registerOpaqueTypeGenerator<Foo>([](FuzzerGenerator& rng) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto.

kunigami pushed a commit to kunigami/velox that referenced this pull request Oct 29, 2024
Summary:

In preparation for supporting Opaque types in Presto page serialization, I'd like to add support to fuzz testing to them.

The idea is that each custom type will have to provide its own randomizing function, since it's otherwise impossible for the framework to do so.

Differential Revision: D63998462
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D63998462

kunigami pushed a commit to kunigami/velox that referenced this pull request Oct 29, 2024
Summary:

In preparation for supporting Opaque types in Presto page serialization, I'd like to add support to fuzz testing to them.

The idea is that each custom type will have to provide its own randomizing function, since it's otherwise impossible for the framework to do so.

Differential Revision: D63998462
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D63998462

Copy link
Contributor

@kagamiori kagamiori left a comment

Choose a reason for hiding this comment

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

LGTM except one comment. Thank you for extending VectorFuzzer with the support of opaque types!

Comment on lines 232 to 234
ASSERT_TRUE(
vector->encoding() == VectorEncoding::Simple::DICTIONARY ||
vector->encoding() == VectorEncoding::Simple::FLAT);
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a chance of fuzzer.fuzz() generating a constant vector too.

Summary:

In preparation for supporting Opaque types in Presto page serialization, I'd like to add support to fuzz testing to them.

The idea is that each custom type will have to provide its own randomizing function, since it's otherwise impossible for the framework to do so.

Reviewed By: kagamiori

Differential Revision: D63998462
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D63998462

kunigami pushed a commit to kunigami/velox that referenced this pull request Oct 29, 2024
Summary:

In preparation for supporting Opaque types in Presto page serialization, I'd like to add support to fuzz testing to them.

The idea is that each custom type will have to provide its own randomizing function, since it's otherwise impossible for the framework to do so.

Reviewed By: kagamiori

Differential Revision: D63998462
kunigami pushed a commit to kunigami/velox that referenced this pull request Oct 29, 2024
Summary:

In preparation for supporting Opaque types in Presto page serialization, I'd like to add support to fuzz testing to them.

The idea is that each custom type will have to provide its own randomizing function, since it's otherwise impossible for the framework to do so.

Reviewed By: kagamiori

Differential Revision: D63998462
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 48f6b8d.

Copy link

Conbench analyzed the 1 benchmark run on commit 48f6b8dd.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

athmaja-n pushed a commit to athmaja-n/velox that referenced this pull request Jan 10, 2025
Summary:
Pull Request resolved: facebookincubator#11189

In preparation for supporting Opaque types in Presto page serialization, I'd like to add support to fuzz testing to them.

The idea is that each custom type will have to provide its own randomizing function, since it's otherwise impossible for the framework to do so.

Reviewed By: kagamiori

Differential Revision: D63998462

fbshipit-source-id: c3f18ae6d660cf105f7b13a9fce842f8ceeec0c8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants