Skip to content

perf: Add rowVectorToIOBufBatch for batch serializing rowVector in RemoteFunction#15718

Closed
avinaashgupta wants to merge 1 commit intomainfrom
export-D88652511
Closed

perf: Add rowVectorToIOBufBatch for batch serializing rowVector in RemoteFunction#15718
avinaashgupta wants to merge 1 commit intomainfrom
export-D88652511

Conversation

@avinaashgupta
Copy link
Copy Markdown
Contributor

Summary:
Add a new rowVectorToIOBufBatch function that uses BatchVectorSerializer
instead of IterativeVectorSerializer for serializing RowVectors to IOBuf.

BatchVectorSerializer preserves encodings of input vectors, which is more
efficient for serializing a single RowVector (as is the case in remote
function calls).

This change updates the remote function client and server to use the new
batch serialization function while leaving the existing rowVectorToIOBuf
unchanged, ensuring no impact on other callers.

Differential Revision: D88652511

@netlify
Copy link
Copy Markdown

netlify bot commented Dec 8, 2025

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit cbb03e2
🔍 Latest deploy log https://app.netlify.com/projects/meta-velox/deploys/6938bc07da861c00086cf6ba

@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Dec 8, 2025

@avinaashgupta has exported this pull request. If you are a Meta employee, you can view the originating Diff in D88652511.

@meta-cla meta-cla 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 Dec 8, 2025
…moteFunction (#15718)

Summary:

Add a new `rowVectorToIOBufBatch` function that uses `BatchVectorSerializer`
instead of `IterativeVectorSerializer` for serializing RowVectors to IOBuf.

BatchVectorSerializer preserves encodings of input vectors, which is more
efficient for serializing a single RowVector (as is the case in remote
function calls).

This change updates the remote function client and server to use the new
batch serialization function while leaving the existing `rowVectorToIOBuf`
unchanged, ensuring no impact on other callers.

Reviewed By: zation99

Differential Revision: D88652511
Copy link
Copy Markdown
Contributor

@pedroerp pedroerp left a comment

Choose a reason for hiding this comment

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

Thank you

@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Dec 10, 2025

This pull request has been merged in ed2e32a.

@aditi-pandit
Copy link
Copy Markdown
Collaborator

aditi-pandit commented Dec 17, 2025

Hi @avinaashgupta :

Some of the remote functions tests viz https://github.com/prestodb/presto/blob/master/presto-native-execution/src/test/java/com/facebook/presto/nativeworker/TestPrestoContainerRemoteFunction.java#L43
started crashing with your change. Reverting this code made the tests pass again.

We are validating the tests again with #15712, but have you'll seen such crashes as well internally and can you give some more insight.

Created prestodb/presto#26818 @amitkdutta Please triage.

[2025-12-09T18:08:17.803Z] Reason: Server responded with status 500. Body: 'Empty response'. URL: http://presto-remote-function-server:1122/v1/functions/default/abs/remote.default.abs%3Binteger/1

[2025-12-09T18:08:17.803Z] Retriable: False

[2025-12-09T18:08:17.803Z] Context: Top-level Expression: remote.default.abs(expr_2)

[2025-12-09T18:08:17.803Z] Additional Context: Operator: FilterProject[144] 2

[2025-12-09T18:08:17.803Z] Function: invokeFunction

[2025-12-09T18:08:17.803Z] File: /prestissimo/presto_cpp/main/functions/remote/client/RestRemoteClient.cpp

[2025-12-09T18:08:17.803Z] Line: 99

[2025-12-09T18:08:17.803Z] Stack trace:

[2025-12-09T18:08:17.803Z] # 0  _ZN8facebook5velox7process10StackTraceC1Ei

[2025-12-09T18:08:17.803Z] # 1  _ZN8facebook5velox14VeloxExceptionC1EPKcmS3_St17basic_string_viewIcSt11char_traitsIcEES7_S7_S7_bNS1_4TypeES7_

[2025-12-09T18:08:17.803Z] # 2  _ZN8facebook5velox6detail14veloxCheckFailINS0_17VeloxRuntimeErrorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEvRKNS1_18VeloxCheckFailArgsET0_

[2025-12-09T18:08:17.803Z] # 3  _ZNK8facebook6presto9functions4rest16RestRemoteClient14invokeFunctionERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS_5velox9functions6remote10PageFormatESt10unique_ptrIN5folly5IOBufESt14default_deleteISI_EE

[2025-12-09T18:08:17.803Z] # 4  _ZNK8facebook6presto9functions4rest12_GLOBAL__N_118RestRemoteFunction20invokeRemoteFunctionERKNS_5velox9functions6remote21RemoteFunctionRequestE

[2025-12-09T18:08:17.803Z] # 5  _ZNK8facebook5velox9functions20RemoteVectorFunction11applyRemoteERKNS0_17SelectivityVectorERSt6vectorISt10shared_ptrINS0_10BaseVectorEESaIS9_EERKS7_IKNS0_4TypeEERNS0_4exec7EvalCtxERS9_

[2025-12-09T18:08:17.803Z] # 6  _ZNK8facebook5velox9functions20RemoteVectorFunction5applyERKNS0_17SelectivityVectorERSt6vectorISt10shared_ptrINS0_10BaseVectorEESaIS9_EERKS7_IKNS0_4TypeEERNS0_4exec7EvalCtxERS9_

[2025-12-09T18:08:17.803Z] # 7  _ZN8facebook5velox4exec4Expr13applyFunctionERKNS0_17SelectivityVectorERNS1_7EvalCtxERSt10shared_ptrINS0_10BaseVectorEE

[2025-12-09T18:08:17.803Z] # 8  _ZN8facebook5velox4exec4Expr24applyFunctionWithPeelingERKNS0_17SelectivityVectorERNS1_7EvalCtxERSt10shared_ptrINS0_10BaseVectorEE

[2025-12-09T18:08:17.803Z] # 9  _ZN8facebook5velox4exec4Expr11evalAllImplERKNS0_17SelectivityVectorERNS1_7EvalCtxERSt10shared_ptrINS0_10BaseVectorEE

[2025-12-09T18:08:17.803Z] # 10 _ZN8facebook5velox4exec4Expr13evalEncodingsERKNS0_17SelectivityVectorERNS1_7EvalCtxERSt10shared_ptrINS0_10BaseVectorEE

[2025-12-09T18:08:17.803Z] # 11 _ZN8facebook5velox4exec4Expr4evalERKNS0_17SelectivityVectorERNS1_7EvalCtxERSt10shared_ptrINS0_10BaseVectorEEPKNS1_7ExprSetE

[2025-12-09T18:08:17.803Z] # 12 _ZN8facebook5velox4exec7ExprSet4evalEiibRKNS0_17SelectivityVectorERNS1_7EvalCtxERSt6vectorISt10shared_ptrINS0_10BaseVectorEESaISB_EE

[2025-12-09T18:08:17.803Z] # 13 _ZN8facebook5velox4exec13FilterProject7projectERKNS0_17SelectivityVectorERNS1_7EvalCtxE

[2025-12-09T18:08:17.803Z] # 14 _ZN8facebook5velox4exec13FilterProject9getOutputEv

[2025-12-09T18:08:17.803Z] # 15 _ZZN8facebook5velox4exec6Driver11runInternalERSt10shared_ptrIS2_ERS3_INS1_13BlockingStateEERS3_INS0_9RowVectorEEENKUlvE3_clEv

[2025-12-09T18:08:17.803Z] # 16 _ZN8facebook5velox4exec6Driver11runInternalERSt10shared_ptrIS2_ERS3_INS1_13BlockingStateEERS3_INS0_9RowVectorEE

[2025-12-09T18:08:17.804Z] # 17 _ZN8facebook5velox4exec6Driver3runESt10shared_ptrIS2_E

[2025-12-09T18:08:17.804Z] # 18 _ZN5folly6detail8function5call_IZN8facebook5velox4exec6Driver7enqueueESt10shared_ptrIS6_EEUlvE_Lb1ELb0EvJEEET2_DpT3_RNS1_4DataE

[2025-12-09T18:08:17.804Z] # 19 _ZN5folly6detail8function14FunctionTraitsIFvvEEclEv

[2025-12-09T18:08:17.804Z] # 20 _ZN5folly18ThreadPoolExecutor7runTaskERKSt10shared_ptrINS0_6ThreadEEONS0_4TaskE

[2025-12-09T18:08:17.804Z] # 21 _ZN5folly21CPUThreadPoolExecutor9threadRunESt10shared_ptrINS_18ThreadPoolExecutor6ThreadEE

[2025-12-09T18:08:17.804Z] # 22 _ZSt13__invoke_implIvRMN5folly18ThreadPoolExecutorEFvSt10shared_ptrINS1_6ThreadEEERPS1_JRS4_EET_St21__invoke_memfun_derefOT0_OT1_DpOT2_

[2025-12-09T18:08:17.804Z] # 23 _ZSt8__invokeIRMN5folly18ThreadPoolExecutorEFvSt10shared_ptrINS1_6ThreadEEEJRPS1_RS4_EENSt15__invoke_resultIT_JDpT0_EE4typeEOSC_DpOSD_

[2025-12-09T18:08:17.804Z] # 24 _ZNSt5_BindIFMN5folly18ThreadPoolExecutorEFvSt10shared_ptrINS1_6ThreadEEEPS1_S4_EE6__callIvJEJLm0ELm1EEEET_OSt5tupleIJDpT0_EESt12_Index_tupleIJXspT1_EEE

[2025-12-09T18:08:17.804Z] # 25 _ZNSt5_BindIFMN5folly18ThreadPoolExecutorEFvSt10shared_ptrINS1_6ThreadEEEPS1_S4_EEclIJEvEET0_DpOT_

[2025-12-09T18:08:17.804Z] # 26 _ZN5folly6detail8function5call_ISt5_BindIFMNS_18ThreadPoolExecutorEFvSt10shared_ptrINS4_6ThreadEEEPS4_S7_EELb1ELb0EvJEEET2_DpT3_RNS1_4DataE

[2025-12-09T18:08:17.804Z] # 27 0x00000000000dbae4

[2025-12-09T18:08:17.804Z] # 28 start_thread

[2025-12-09T18:08:17.804Z] # 29 clone

[2025-12-09T18:08:17.804Z] 

[2025-12-09T18:08:17.804Z] Retriable: False

[2025-12-09T18:08:17.804Z] Context: Top-level Expression: remote.default.abs(expr_2)

[2025-12-09T18:08:17.804Z] Additional Context: Operator: FilterProject[144] 2

[2025-12-09T18:08:17.804Z] Function: invokeFunction

[2025-12-09T18:08:17.804Z] File: /prestissimo/presto_cpp/main/functions/remote/client/RestRemoteClient.cpp

[2025-12-09T18:08:17.804Z] Line: 108

[2025-12-09T18:08:17.804Z] Stack trace:

[2025-12-09T18:08:17.804Z] # 0  _ZN8facebook5velox7process10StackTraceC1Ei

[2025-12-09T18:08:17.804Z] # 1  _ZN8facebook5velox14VeloxExceptionC1EPKcmS3_St17basic_string_viewIcSt11char_traitsIcEES7_S7_S7_bNS1_4TypeES7_

[2025-12-09T18:08:17.804Z] # 2  _ZN8facebook5velox6detail14veloxCheckFailINS0_17VeloxRuntimeErrorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEvRKNS1_18VeloxCheckFailArgsET0_

[2025-12-09T18:08:17.804Z] # 3  _ZNK8facebook6presto9functions4rest16RestRemoteClient14invokeFunctionERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS_5velox9functions6remote10PageFormatESt10unique_ptrIN5folly5IOBufESt14default_deleteISI_EE.cold

[2025-12-09T18:08:17.804Z] # 4  _ZNK8facebook6presto9functions4rest12_GLOBAL__N_118RestRemoteFunction20invokeRemoteFunctionERKNS_5velox9functions6remote21RemoteFunctionRequestE

[2025-12-09T18:08:17.804Z] # 5  _ZNK8facebook5velox9functions20RemoteVectorFunction11applyRemoteERKNS0_17SelectivityVectorERSt6vectorISt10shared_ptrINS0_10BaseVectorEESaIS9_EERKS7_IKNS0_4TypeEERNS0_4exec7EvalCtxERS9_

[2025-12-09T18:08:17.804Z] # 6  _ZNK8facebook5velox9functions20RemoteVectorFunction5applyERKNS0_17SelectivityVectorERSt6vectorISt10shared_ptrINS0_10BaseVectorEESaIS9_EERKS7_IKNS0_4TypeEERNS0_4exec7EvalCtxERS9_

[2025-12-09T18:08:17.804Z] # 7  _ZN8facebook5velox4exec4Expr13applyFunctionERKNS0_17SelectivityVectorERNS1_7EvalCtxERSt10shared_ptrINS0_10BaseVectorEE

[2025-12-09T18:08:17.804Z] # 8  _ZN8facebook5velox4exec4Expr24applyFunctionWithPeelingERKNS0_17SelectivityVectorERNS1_7EvalCtxERSt10shared_ptrINS0_10BaseVectorEE

[2025-12-09T18:08:17.804Z] # 9  _ZN8facebook5velox4exec4Expr11evalAllImplERKNS0_17SelectivityVectorERNS1_7EvalCtxERSt10shared_ptrINS0_10BaseVectorEE

[2025-12-09T18:08:17.804Z] # 10 _ZN8facebook5velox4exec4Expr13evalEncodingsERKNS0_17SelectivityVectorERNS1_7EvalCtxERSt10shared_ptrINS0_10BaseVectorEE

[2025-12-09T18:08:17.804Z] # 11 _ZN8facebook5velox4exec4Expr4evalERKNS0_17SelectivityVectorERNS1_7EvalCtxERSt10shared_ptrINS0_10BaseVectorEEPKNS1_7ExprSetE

[2025-12-09T18:08:17.804Z] # 12 _ZN8facebook5velox4exec7ExprSet4evalEiibRKNS0_17SelectivityVectorERNS1_7EvalCtxERSt6vectorISt10shared_ptrINS0_10BaseVectorEESaISB_EE

[2025-12-09T18:08:17.804Z] # 13 _ZN8facebook5velox4exec13FilterProject7projectERKNS0_17SelectivityVectorERNS1_7EvalCtxE

[2025-12-09T18:08:17.804Z] # 14 _ZN8facebook5velox4exec13FilterProject9getOutputEv

[2025-12-09T18:08:17.805Z] # 15 _ZZN8facebook5velox4exec6Driver11runInternalERSt10shared_ptrIS2_ERS3_INS1_13BlockingStateEERS3_INS0_9RowVectorEEENKUlvE3_clEv

[2025-12-09T18:08:17.805Z] # 16 _ZN8facebook5velox4exec6Driver11runInternalERSt10shared_ptrIS2_ERS3_INS1_13BlockingStateEERS3_INS0_9RowVectorEE

[2025-12-09T18:08:17.805Z] # 17 _ZN8facebook5velox4exec6Driver3runESt10shared_ptrIS2_E

[2025-12-09T18:08:17.805Z] # 18 _ZN5folly6detail8function5call_IZN8facebook5velox4exec6Driver7enqueueESt10shared_ptrIS6_EEUlvE_Lb1ELb0EvJEEET2_DpT3_RNS1_4DataE

[2025-12-09T18:08:17.805Z] # 19 _ZN5folly6detail8function14FunctionTraitsIFvvEEclEv

[2025-12-09T18:08:17.805Z] # 20 _ZN5folly18ThreadPoolExecutor7runTaskERKSt10shared_ptrINS0_6ThreadEEONS0_4TaskE

[2025-12-09T18:08:17.805Z] # 21 _ZN5folly21CPUThreadPoolExecutor9threadRunESt10shared_ptrINS_18ThreadPoolExecutor6ThreadEE

[2025-12-09T18:08:17.805Z] # 22 _ZSt13__invoke_implIvRMN5folly18ThreadPoolExecutorEFvSt10shared_ptrINS1_6ThreadEEERPS1_JRS4_EET_St21__invoke_memfun_derefOT0_OT1_DpOT2_

[2025-12-09T18:08:17.805Z] # 23 _ZSt8__invokeIRMN5folly18ThreadPoolExecutorEFvSt10shared_ptrINS1_6ThreadEEEJRPS1_RS4_EENSt15__invoke_resultIT_JDpT0_EE4typeEOSC_DpOSD_

[2025-12-09T18:08:17.805Z] # 24 _ZNSt5_BindIFMN5folly18ThreadPoolExecutorEFvSt10shared_ptrINS1_6ThreadEEEPS1_S4_EE6__callIvJEJLm0ELm1EEEET_OSt5tupleIJDpT0_EESt12_Index_tupleIJXspT1_EEE

[2025-12-09T18:08:17.805Z] # 25 _ZNSt5_BindIFMN5folly18ThreadPoolExecutorEFvSt10shared_ptrINS1_6ThreadEEEPS1_S4_EEclIJEvEET0_DpOT_

[2025-12-09T18:08:17.805Z] # 26 _ZN5folly6detail8function5call_ISt5_BindIFMNS_18ThreadPoolExecutorEFvSt10shared_ptrINS4_6ThreadEEEPS4_S7_EELb1ELb0EvJEEET2_DpT3_RNS1_4DataE

[2025-12-09T18:08:17.805Z] # 27 0x00000000000dbae4

[2025-12-09T18:08:17.805Z] # 28 start_thread

[2025-12-09T18:08:17.805Z] # 29 clone

[2025-12-09T18:08:17.805Z]  Top-level Expression: remote.default.abs(expr_2) Operator: FilterProject[144] 2

[2025-12-09T18:08:1

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 meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants