‎2014 Jan 30 3:33 PM
I'm working on an extremely performance sensitive project and we're trying to get everything we can out of it. One of the options we are discussing is using multithreading to improve performance. I want to be clear that I do mean multithreading and not multiprocessing, because shared memory space between the threads will be necessary. Is there any mechanism that SAP/ABAP provides in support of this?
‎2014 Jan 30 3:41 PM
‎2014 Jan 31 5:31 AM
Not really something I'd advocate in the ABAP space, if you go the multiprocess approach, I'd have a quick word with your technical team. You don't want to be that guy responsible for locking out all the processes accidentally.
Multiprocessing happens natively in a HANA, when you do a code push down from ABAP, if you have it.
Just out of interest, what sort have checks have you made that led you to the conclusion that multiprocessing might give you some gains? Did you check out how your code is running in something like Runtime Analysis (SE38) or System Analysis & Trace (SAT transaction). You can record various traces on your program and get very detailed analysis of any bottlenecks.
‎2014 Jan 31 5:37 AM
I forgot I wrote this test program to trial running code asynchronously. It might help, but again not something I'd be keen to use unless absolutely necessary
*&---------------------------------------------------------------------*
*& Report ZKP_ASYNC_FUNC_TEST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zkp_async_func_test.
*----------------------------------------------------------------------*
* CLASS cl_async_func_controller DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_async_func_controller DEFINITION.
PUBLIC SECTION.
CLASS-METHODS: execute_program,
response IMPORTING p_task TYPE clike.
CLASS-DATA: g_result TYPE char10.
ENDCLASS. "cl_async_func_controller DEFINITION
*----------------------------------------------------------------------*
* CLASS cl_async_func_controller IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_async_func_controller IMPLEMENTATION.
METHOD execute_program.
break bcuser.
* Can use this to kick off a load of selects in parallel that are not dependent
* and then wait on the results
CALL FUNCTION 'ZFUNC_ASYNC1'
STARTING NEW TASK 'TASK1'
CALLING response ON END OF TASK.
* Without this wait statement the program just completes
* need to set an appropriate time out. Not too short and not too long
WAIT UNTIL g_result IS NOT INITIAL UP TO 20 SECONDS.
ENDMETHOD. "execute_program
METHOD response.
DATA: l_result TYPE char10.
break bcuser.
RECEIVE RESULTS FROM FUNCTION 'ZFUNC_ASYNC1'
IMPORTING ex_result = l_result.
g_result = l_result.
WRITE: l_result.
ENDMETHOD. "response
ENDCLASS. "cl_async_func_controller IMPLEMENTATION
START-OF-SELECTION.
cl_async_func_controller=>execute_program( ).