{"record":{"id":"9aaf2a6aa8cb36ec","repo":"risingwavelabs/risingwave","slug":"simd-optimization-for-n-arguments","errorCode":null,"errorMessage":"SIMD optimization for {n} arguments","messagePattern":"SIMD optimization for (.+?) arguments","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/expr/macro/src/gen.rs","lineNumber":590,"sourceCode":"                1 => quote! {\n                    let c = #ret_array_type::from_iter_bitmap(\n                        a0.raw_iter().map(|a| #fn_name(a)),\n                        a0.null_bitmap().clone()\n                    );\n                    Arc::new(c.into())\n                },\n                2 => quote! {\n                    // allow using `zip` for performance\n                    #[allow(clippy::disallowed_methods)]\n                    let c = #ret_array_type::from_iter_bitmap(\n                        a0.raw_iter()\n                            .zip(a1.raw_iter())\n                            .map(|(a, b)| #fn_name #generic(a, b)),\n                        a0.null_bitmap() & a1.null_bitmap(),\n                    );\n                    Arc::new(c.into())\n                },\n                n => todo!(\"SIMD optimization for {n} arguments\"),\n            }\n        } else {\n            // no optimization\n            let let_variadic = variadic.then(|| {\n                quote! {\n                    let variadic_row = variadic_input.row_at_unchecked_vis(i);\n                }\n            });\n            quote! {\n                let mut builder = #builder_type::with_type(input.capacity(), self.context.return_type.clone());\n\n                if input.is_vis_compacted() {\n                    for i in 0..input.capacity() {\n                        #(let #inputs = unsafe { #arrays.value_at_unchecked(i) };)*\n                        #let_variadic\n                        #append_output\n                    }\n                } else {","sourceCodeStart":572,"sourceCodeEnd":608,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/expr/macro/src/gen.rs#L572-L608","documentation":"The macro's vectorized (SIMD) fast path is implemented only for 1- and 2-argument functions; for any other arity it hits an explicit `todo!` panic noting SIMD optimization is unimplemented for N arguments.","triggerScenarios":"Marking a scalar function with vectorized/SIMD optimization (`is_viscalar`-style declaration) where the function takes more than 2 arguments, causing codegen to emit `todo!` for that arity.","commonSituations":"Writing a 3-argument arithmetic-like function (e.g. `clamp`, `nvl3`) and marking it SIMD-optimized; copy-pasting the optimization annotation from a 2-arg function.","solutions":["Remove the SIMD optimization annotation from functions with >2 arguments so the general path is used","Implement the `n =>` arm to fall back to the non-SIMD loop instead of todo!","Keep SIMD-optimized declarations limited to unary and binary functions"],"exampleFix":"// before\nn => todo!(\"SIMD optimization for {n} arguments\"),\n// after\nn => generate_general_vectorized_code(n), // fall back to per-row loop","handlingStrategy":"validation","validationCode":"fn simd_supported(num_args: usize) -> bool { matches!(num_args, 1 | 2) }","typeGuard":null,"tryCatchPattern":"if !simd_supported(fn_args) {\n    use_general_path(fn, args); // avoid the todo! path\n}","preventionTips":["Only mark 1- or 2-argument functions as SIMD optimized","Replace todo! with a fallback to the general vectorized path in codegen","Add a compile-time test enumerating SIMD-registered functions' arities"],"tags":["simd","proc-macro","unimplemented"],"backgroundTag":"method-not-implemented","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}