Skip to content

Call commitNull in SimpleFunctionAdapter on exceptions (take 2)#10418

Closed
kevinwilfong wants to merge 1 commit intofacebookincubator:mainfrom
kevinwilfong:export-D59473869
Closed

Call commitNull in SimpleFunctionAdapter on exceptions (take 2)#10418
kevinwilfong wants to merge 1 commit intofacebookincubator:mainfrom
kevinwilfong:export-D59473869

Conversation

@kevinwilfong
Copy link
Copy Markdown
Contributor

Summary:
The way the VectorWriters work today, if its writing a variable length type and it is not committed
(e.g. because an exception was thrown) when the next value is written it will start with the state of
the previous value rather than a clean slate. This can result in e.g. strings starting with the contents
that were written for the previous string.

SimpleFunctionAdapter tried to compensate for this by making a local copy of the top level
VectorWriter and only copying back into the original if processing the current row succeeds. This
does nothing for nested writers (it also wasn't implemented for Strings).

To fix this, I've added an optional lambda to applyToSelectedNoThrow that gets invoked when an
exception is caught. We can use this to call commitNull on the writer which should reset the state
of all writers (top level and nested). Note that if we're catching exceptions and not throwing anything
we must be in a try so committing null is safe and reasonable to do.

This shouldn't impact the performance of the path without exceptions (I ran the
ArrayWriterBenchmark to confirm this). I also do not need to make this change in the fast path as
the fast path is only invoked if the output type is primitive and fixed width, and in this there is no
state other than the value in the Vector so failing to commit does not cause issues.

This combined with #10376 addresses the issue
identified in #10162

Differential Revision: D59473869

@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 Jul 8, 2024
@netlify
Copy link
Copy Markdown

netlify bot commented Jul 8, 2024

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit e28f123
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/668c81ea7d8d4700087a2dfe

@facebook-github-bot
Copy link
Copy Markdown
Contributor

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

@facebook-github-bot
Copy link
Copy Markdown
Contributor

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

@facebook-github-bot
Copy link
Copy Markdown
Contributor

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

…bookincubator#10418)

Summary:
Pull Request resolved: facebookincubator#10418

The way the VectorWriters work today, if its writing a variable length type and it is not committed
(e.g. because an exception was thrown) when the next value is written it will start with the state of
the previous value rather than a clean slate.  This can result in e.g. strings starting with the contents
that were written for the previous string.

SimpleFunctionAdapter tried to compensate for this by making a local copy of the top level
VectorWriter and only copying back into the original if processing the current row succeeds.  This
does nothing for nested writers (it also wasn't implemented for Strings).

To fix this, I've added an optional lambda to applyToSelectedNoThrow that gets invoked when an
exception is caught.  We can use this to call commitNull on the writer which should reset the state
of all writers (top level and nested).  Note that if we're catching exceptions and not throwing anything
we must be in a try so committing null is safe and reasonable to do.

This shouldn't impact the performance of the path without exceptions (I ran the
ArrayWriterBenchmark to confirm this).  I also do not need to make this change in the fast path as
the fast path is only invoked if the output type is primitive and fixed width, and in this there is no
state other than the value in the Vector so failing to commit does not cause issues.

This combined with facebookincubator#10376 addresses the issue
identified in facebookincubator#10162

Reviewed By: weijiadeng-uber

Differential Revision: D59473869
@facebook-github-bot
Copy link
Copy Markdown
Contributor

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

@kevinwilfong kevinwilfong reopened this Jul 9, 2024
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been merged in 77589a9.

@conbench-facebook
Copy link
Copy Markdown

Conbench analyzed the 1 benchmark run on commit 77589a91.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

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.

3 participants