Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Interesting performance issue with String functions

Former Member
0 Likes
788

Hi All,

I was working on a performance issues on a 7.02 system and discovered that a very small change in the code made a dramatic difference to the performance. I have created a very simple program to illustrate this. The program is attached.

Number of records

Version one

Version two

% Change

100

239

161

33%

1,000

7626

1590

79%

10,000

945,304

16,783

98%

100,000

169,005,062

860,739

99%

I have sent the program to two of the SAP ABAP Mentors, Graham Robinson and Thomas Jung. Graham has run the program on a 7.31 system and had similar results. Thomas is fortunate to a 7.40 system and his results show the opposite result but the difference were very small.

I am interested to hear if anybody has an explanation as to why there is such a dramatic difference in performance.

Regards

Brent Talbot

1 ACCEPTED SOLUTION
Read only

0 Likes
690

In 7.40, the ABAP runtime goes to greater effort to determine that there is no right-hand-side occurrence of the target variable and hence it can be appended directly. (If there was a rhs occurrence, direct append would be invalid.) In 7.20, this recognition only works for the simple form in version 2, and version 1 has quadratic run time, as speculated by Volker.

3 REPLIES 3
Read only

Former Member
0 Likes
690

The version 1 code is:

  LOOP AT lt_data REFERENCE INTO lr_data.

    lv_html_data =

      lv_html_data &&

      |<OPTION from="unalloc" VALUE="{ lr_data->anumber }" birthid="">{ lr_data->anumber }|.

  ENDLOOP.

The Version 2 code which runs significantly faster is

LOOP AT lt_data REFERENCE INTO lr_data.

    lv_html_data2 =

      |<OPTION from="unalloc" VALUE="{ lr_data->anumber }" birthid="">{ lr_data->anumber }|.

    lv_html_data3 = lv_html_data3 && lv_html_data2.

  ENDLOOP.

Read only

0 Likes
690

Hmm,

I think in version one to make the "&&" operator work, you need to build an intermediate expression result for the part to the right of "&&". It has to be stored somwhere, so that "&&" can be processed afterwards, and as soon as the expression is calculated, this interimspace has to be deallocated to avoid a memory leak. Sounds pretty expensive to me, esp. on unicode systems.

In Version 2, the compiler probably recognizes, that the storage will be in lv_html_data2 (left of =), so no need for dynamic allocation and de-allocation of the interim result for concatenation. The target lv_html_data2 stays static.

The memorymanagement for the target, which gets longer in each loop is the same in both cases.

But it is just guessing, I have no trace for proof.

As far as the compared systems are involved, any unicode / non-unicode derivations?

Volker

Read only

0 Likes
691

In 7.40, the ABAP runtime goes to greater effort to determine that there is no right-hand-side occurrence of the target variable and hence it can be appended directly. (If there was a rhs occurrence, direct append would be invalid.) In 7.20, this recognition only works for the simple form in version 2, and version 1 has quadratic run time, as speculated by Volker.