Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Later
-
Impala 2.5.0
-
None
-
None
Description
In the backend, we only use exceptions when interfacing with third party libraries that throw exceptions (e.g. boost), which we wrap with try-catch. Outside of that, we don't expect, nor handle, exceptions unwinding impala code.
So, we could isolate calls to those thirdparty libraries to .cc files, and then compile the rest of Impala with -fno-exceptions. The advantages to doing so are:
- Better code. All the stack unwinding code goes away and potentially more optimizations are possible.
- We'll get compiler errors if try-catch is written in places where it won't work anyway (IR code since we disable generating exception handling code). This probably could have caught
IMPALA-2184at compile time.
A good starting point is probably to turn on -fno-exceptions for IR since we already don't generate exception handling code. This may require refactoring use of boost headers, however, since statically exceptions may be possible on these paths.
An alternative would be to use 'noexcept', but this would require annotating every function.
Example:
#include <stdio.h> struct Foo { Foo() { printf("Foo()"); } ~Foo() { printf("~Foo()"); } }; void NoExcept() noexcept; void Except(); void CallNoExcept() { Foo foo; NoExcept(); } void CallExcept() { Foo foo; Except(); } int main() { CallExcept(); }
CallNoExcept(): .LFB18: .cfi_startproc .cfi_personality 0x3,__gxx_personality_v0 .cfi_lsda 0x3,.LLSDA18 subq $8, %rsp .cfi_def_cfa_offset 16 movl $.LC0, %edi xorl %eax, %eax .LEHB0: call printf .LEHE0: call NoExcept() movl $.LC1, %edi xorl %eax, %eax addq $8, %rsp .cfi_def_cfa_offset 8 jmp printf .cfi_endproc ... CallExcept(): .LFB19: .cfi_startproc .cfi_personality 0x3,__gxx_personality_v0 .cfi_lsda 0x3,.LLSDA19 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 movl $.LC0, %edi xorl %eax, %eax .LEHB1: call printf .LEHE1: .LEHB2: call Except() .LEHE2: popq %rbx .cfi_remember_state .cfi_def_cfa_offset 8 movl $.LC1, %edi xorl %eax, %eax jmp printf .L5: .cfi_restore_state movq %rax, %rbx movl $.LC1, %edi xorl %eax, %eax call printf movq %rbx, %rdi .LEHB3: call _Unwind_Resume .LEHE3: .cfi_endproc
CallNoExcept(): .LFB18: .cfi_startproc subq $8, %rsp .cfi_def_cfa_offset 16 movl $.LC0, %edi xorl %eax, %eax call printf call NoExcept() movl $.LC1, %edi xorl %eax, %eax addq $8, %rsp .cfi_def_cfa_offset 8 jmp printf .cfi_endproc ... CallExcept(): .LFB19: .cfi_startproc subq $8, %rsp .cfi_def_cfa_offset 16 movl $.LC0, %edi xorl %eax, %eax call printf call Except() movl $.LC1, %edi xorl %eax, %eax addq $8, %rsp .cfi_def_cfa_offset 8 jmp printf .cfi_endproc
Attachments
Issue Links
- is related to
-
IMPALA-2120 Track mem of std structures in query execution
- Open
-
IMPALA-3476 Use new with nothrow where appropriate
- Open
- relates to
-
IMPALA-1948 Fix automatic storage Status and codegen
- Open
-
IMPALA-1112 Remove unnecessary boost/std/misc functions from the cross compiled module.
- Resolved