Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perf/misc ds improvements #692

Merged
merged 36 commits into from
Jan 12, 2025
Merged

Perf/misc ds improvements #692

merged 36 commits into from
Jan 12, 2025

Conversation

lanarimarco
Copy link
Collaborator

@lanarimarco lanarimarco commented Jan 12, 2025

Description

Heavy improvements for this kind of DSs:

     D                 DS
     D SMEP                         200    DIM(10000)
     D  SMEP_G_P                     02  0 OVERLAY(SMEP:01)
     D  SMEP_G_A                     02  0 OVERLAY(SMEP:*NEXT)
     D  SMEP_P01                     07  0 OVERLAY(SMEP:*NEXT)
     D  SMEP_P02                     07  0 OVERLAY(SMEP:*NEXT)
     D  SMEP_TVA                     20    OVERLAY(SMEP:*NEXT)
     D  SMEP_VAL                    100    OVERLAY(SMEP:*NEXT)

This was achieved through the implementation of the new DataStructValueBuilder interface, responsible for all operations that can change the state of DSs.
Currently, the logic for choosing the best implementation of DataStructValueBuilder is based on the DataStructureType and is provided by the new callback JarikoCallback.createDataStructValueBuilder.
The use case demonstrating the effectiveness of this approach can be viewed here (see the final assert of executeDSPERF02CompareIndexedStringBuilderVsStringBuilder function) where we prove that performance improvement can be up to 10 times.

During this work, we also noted that the decodeFromDS function, which is involved when transforming a String into a BigDecimal, performed a lot of logic not always necessary.

Before this implementation:

fun decodeFromDS(value: String, digits: Int, scale: Int): BigDecimal {
    <convert value into number if value contains not numeric chars>
    return try {
        value.toBigDecimal()
    } catch (e: Exception) {
        number.toBigDecimal()
    }
}

After this implementation:

fun decodeFromDS(value: String, digits: Int, scale: Int): BigDecimal {
    return try {
        value.toBigDecimal()
    } catch (e: Exception) {
        <convert value into number if value contains not numeric chars>
        number.toBigDecimal()
    }
}

Related to # (issue)

Checklist:

  • If this feature involves RPGLE fixes or improvements, they are well-described in the summary.
  • There are tests for this feature.
  • RPGLE code used for tests is easily understandable and includes comments that clarify the purpose of this feature.
  • The code follows Kotlin conventions (run ./gradlew ktlintCheck).
  • The code passes all tests (run ./gradlew check).
  • Relevant documentation is included in the docs directory.

…ingValue a function that allows to create DataStructStringValue
The function blank(dataStructureType: DataStructureType) allows to create an instance of DataStructValue that uses the right instance of DataStructValueBuilder based on the provided DataStructureType.
 This measure is no longer necessary due to the addition of tests that assert whether DataStructValueBuilder creates an instance of StringBuilderWrapper instead of IndexedStringBuilder
…ful, now it receives both value and DataStructureType

All logic of this method has been moved to `JarikoCallback.createDataStructValueBuilder`, this way is totally customizable

Add helfpul methods:

- DataStructureType.containsOnlyArrays()
- DataStructureType.totalFields():
…g is not numeric, must be executed as an exception and not always

replace a lot of kotlin deprecated functions
…he string is not numeric, must be executed as an exception and not always"

This reverts commit 4b53be0.
…g is not numeric, must be executed as an exception and not always
@lanarimarco lanarimarco merged commit 4917510 into develop Jan 12, 2025
1 check passed
@lanarimarco lanarimarco deleted the perf/misc_ds_improvements branch January 12, 2025 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant