Skip to content

Feature/annotation parser improvments#1312

Open
lwasylow wants to merge 34 commits intodevelopfrom
feature/annotation_parser_improvments
Open

Feature/annotation parser improvments#1312
lwasylow wants to merge 34 commits intodevelopfrom
feature/annotation_parser_improvments

Conversation

@lwasylow
Copy link
Member

This is attempt to speed up the annotation parsing for large volume of packages.
It replaces costly lob being open up and closed up with a line scanner and set of short circuits conditions.

On the 1000 auto generated set of sample unit tests packages executing both ut_annotation_parser.parse_object_annotations old vs new we seeing large improvments.

Packages    : 1000
Procs/pkg   : 20
Contexts/pkg: 4
Iterations  : 1
=================================================

-- Phase 1: Performance --
package              | baseline_ms | new_ms | ratio | status
----------------------------------------------------------------------
TST_GEN_PKG_0001     |      14.285 |  1.689 |  .118 | PASS (88.2% faster)
TST_GEN_PKG_0100     |       7.382 |  2.318 |  .314 | PASS (68.6% faster)
TST_GEN_PKG_0200     |       7.538 |   1.64 |  .218 | PASS (78.2% faster)
TST_GEN_PKG_0300     |       7.504 |  1.713 |  .228 | PASS (77.2% faster)
TST_GEN_PKG_0400     |       8.112 |  2.659 |  .328 | PASS (67.2% faster)
TST_GEN_PKG_0500     |       7.696 |  1.666 |  .216 | PASS (78.4% faster)
TST_GEN_PKG_0600     |       7.832 |   2.65 |  .338 | PASS (66.2% faster)
TST_GEN_PKG_0700     |       7.371 |  1.653 |  .224 | PASS (77.6% faster)
TST_GEN_PKG_0800     |       6.988 |  1.585 |  .227 | PASS (77.3% faster)
TST_GEN_PKG_0900     |       7.267 |  1.636 |  .225 | PASS (77.5% faster)
TST_GEN_PKG_1000     |       7.981 |  1.773 |  .222 | PASS (77.8% faster)
----------------------------------------------------------------------
Baseline total ms : 7762.393
New total ms      : 1783.356
Overall ratio     : .23
Improvement       : 77%
Performance check : PASS — new code is at least 20% faster

-- Phase 2: Cache presence --
Expected in cache : 1000
Found in cache    : 1000

-- Phase 3: Annotation count correctness --
Packages checked  : 1000
Count mismatches  : 0

@github-actions
Copy link
Contributor

github-actions bot commented Mar 15, 2026

Test Results

    1 files    102 suites   2m 39s ⏱️
1 109 tests 1 105 ✅ 4 💤 0 ❌
1 113 runs  1 105 ✅ 8 💤 0 ❌

Results for commit aa3bfe7.

♻️ This comment has been updated with latest results.

@codecov
Copy link

codecov bot commented Mar 15, 2026

Codecov Report

❌ Patch coverage is 95.62842% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.02%. Comparing base (c243e4e) to head (aa3bfe7).
⚠️ Report is 13 commits behind head on develop.

Files with missing lines Patch % Lines
source/core/ut_utils.pkb 93.63% 7 Missing ⚠️
source/core/annotations/ut_annotation_parser.pkb 98.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1312      +/-   ##
===========================================
- Coverage    95.04%   95.02%   -0.03%     
===========================================
  Files          111      111              
  Lines         5369     5444      +75     
  Branches        33       30       -3     
===========================================
+ Hits          5103     5173      +70     
- Misses         266      271       +5     
Flag Coverage Δ
19se 95.06% <95.58%> (-0.03%) ⬇️
21XE 95.21% <95.58%> (-0.03%) ⬇️
23-free 94.96% <95.62%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jgebal
Copy link
Member

jgebal commented Mar 15, 2026

Can you also include the code you have used for large-scale testing of scanning?
Perhaps you could put it inside the examples/

Is the change related only to how the comment removal is done for lines scanning?

@jgebal
Copy link
Member

jgebal commented Mar 15, 2026

Please assure that the coverage on new functionality is higher.
Many code blocks are not covered.
https://app.codecov.io/gh/utPLSQL/utPLSQL/pull/1312?src=pr&el=tree

@lwasylow
Copy link
Member Author

Can you also include the code you have used for large-scale testing of scanning? Perhaps you could put it inside the examples/

Is the change related only to how the comment removal is done for lines scanning?

No the change is related to replace_multiline_comments and switching parse_object_annotations to use a lines rather than clob and its associated procedures.

    l_source := ut_utils.replace_multiline_comments(l_source);
    l_comments := extract_and_replace_comments(l_source);
    add_procedure_annotations(l_annotations, l_source, l_comments);

Added the file to example.

@lwasylow
Copy link
Member Author

Please assure that the coverage on new functionality is higher. Many code blocks are not covered. https://app.codecov.io/gh/utPLSQL/utPLSQL/pull/1312?src=pr&el=tree

I will update tests.
There are also some sonnar scanners coming up so will update these too to resolve them where valid/sensible.

Copy link
Member

@jgebal jgebal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement.

Some fixes are required and old code needs to be removed.

I wonder where did the need for this improvement came from?

Do you actually see this as a problem in day-to-day use of utPLSQL?

@lwasylow
Copy link
Member Author

Nice improvement.

Some fixes are required and old code needs to be removed.

I wonder where did the need for this improvement came from?

Do you actually see this as a problem in day-to-day use of utPLSQL?

No issues.
Honestly I wanted to go back to do some fun coding other than work stuff and looked for the areas of improvement and I knew from experience that parsing was one of things that took time other than suit building. Felt like a easy win to get back into groove you know :)

Next on table is to add the finally the boolean matcher from 23c :)

- Removed unused test procedures from test_annotation_parser package.
- Updated replace_multiline_comments procedure in test_ut_utils to use dbms_preprocessor.source_lines_t for actual and expected results.
- Added lines_to_str and make_source functions in main_helper to facilitate conversion between source lines and string formats.
@lwasylow
Copy link
Member Author

I'm still working on it.
Getting odd error on my local docker:
on cursor:

java.sql.SQLException: ORA-01000: maximum open cursors for session exceeded
ORA-06512: at "UT3.UT_RUNNER", line 151
ORA-06512: at "UT3.UT_EXECUTABLE", line 155
ORA-06512: at "SYS.DBMS_SQL", line 1838
ORA-06512: at "UT3.UT_EXECUTABLE", line 142
ORA-06512: at "UT3.UT_EXECUTABLE", line 44
ORA-06512: at "UT3.UT_EXECUTABLE_TEST", line 178
ORA-06512: at "UT3.UT_EXECUTABLE_TEST", line 38
ORA-06512: at "UT3.UT_TEST", line 80
ORA-06512: at "UT3.UT_SUITE_ITEM", line 50
ORA-06512: at "UT3.UT_SUITE", line 66
ORA-06512: at "UT3.UT_SUITE_ITEM", line 50
ORA-06512: at "UT3.UT_SUITE", line 66
ORA-06512: at "UT3.UT_SUITE_ITEM", line 50
ORA-06512: at "UT3.UT_SUITE", line 66
ORA-06512: at "UT3.UT_SUITE_ITEM", line 50
ORA-06512: at "UT3.UT_SUITE", line 66
ORA-06512: at "UT3.UT_RUN", line 59
ORA-06512: at "UT3.UT_SUITE_ITEM", line 50
ORA-06512: at "UT3.UT_RUNNER", line 144
ORA-06512: at line 1

Weird it run ok in docker in the CICD pipeline ....

@lwasylow
Copy link
Member Author

I'm still working on it. Getting odd error on my local docker: on cursor:

java.sql.SQLException: ORA-01000: maximum open cursors for session exceeded
ORA-06512: at "UT3.UT_RUNNER", line 151
ORA-06512: at "UT3.UT_EXECUTABLE", line 155
ORA-06512: at "SYS.DBMS_SQL", line 1838
ORA-06512: at "UT3.UT_EXECUTABLE", line 142
ORA-06512: at "UT3.UT_EXECUTABLE", line 44
ORA-06512: at "UT3.UT_EXECUTABLE_TEST", line 178
ORA-06512: at "UT3.UT_EXECUTABLE_TEST", line 38
ORA-06512: at "UT3.UT_TEST", line 80
ORA-06512: at "UT3.UT_SUITE_ITEM", line 50
ORA-06512: at "UT3.UT_SUITE", line 66
ORA-06512: at "UT3.UT_SUITE_ITEM", line 50
ORA-06512: at "UT3.UT_SUITE", line 66
ORA-06512: at "UT3.UT_SUITE_ITEM", line 50
ORA-06512: at "UT3.UT_SUITE", line 66
ORA-06512: at "UT3.UT_SUITE_ITEM", line 50
ORA-06512: at "UT3.UT_SUITE", line 66
ORA-06512: at "UT3.UT_RUN", line 59
ORA-06512: at "UT3.UT_SUITE_ITEM", line 50
ORA-06512: at "UT3.UT_RUNNER", line 144
ORA-06512: at line 1

Weird it run ok in docker in the CICD pipeline ....

Must been something with my image...
Downloaded one we are using and worked fine.
Oh well few hours wasted tracking cursor leak ....

I will fix rest of the things later. Managed to remove dead code will have to now refactor some of the new one.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
D Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

2 participants