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

[Phase 1][Ballerina standard libraries] Dead code elimination report for Ballerina library modules #7339

Open
11 of 51 tasks
ayeshLK opened this issue Nov 6, 2024 · 9 comments

Comments

@ayeshLK
Copy link
Member

ayeshLK commented Nov 6, 2024

Description

$subject

In the first phase we will be looking into dead-code-elimination for Ballerina standard library modules.

Below are the steps required to complete dead code elimination for a standard library module:

1. Update Dependency Versions:

Update the timestamps or latest versions of dependencies in gradle.properties (refer to the “Next” tab for the relevant versions).

2. Build the Module:

Use gradle to build the standard library module. This step will generate an intermediate package, which will be used for testing.

3. Run Dead Code Elimination Command:

In the ballerina directory of the module, execute:

 BAL_DISABLE_HARDCODED_OPTIMIZATIONS=true <path-to-intermediate-pack>/bin/bal test --eliminate-dead-code --dead-code-elimination-report

4. Review the Report:

If errors arise, examine target/dead_code_elimination_report.json to identify any removed types. Use @ExternalDependency to mark these types as needed.

5. Verify Type and Value Creator Usage:

Review TypeCreator, ValueCreator and ErrorCreator usage in the native code. Mark any relevant Ballerina types with @ExternalDependency if they aren’t marked already.

Module list

Version

No response

@TharmiganK
Copy link
Contributor

TharmiganK commented Nov 6, 2024

The url package has no usages of ValueCreator or TypeCreator APIs. But the tests with DCE are failing due to a lang issue: ballerina-platform/ballerina-lang#43552. There is one usage for the ErrorCreator to create url:Error and since it is mentioned in the external function calls, it is added by default.

@TharmiganK
Copy link
Contributor

The log package has no usages of TypeCreator. There are some usages of ValueCreator and ErrorCreator, but those are for tests (added via the test-utils package) and not part of the package.

@ayeshLK
Copy link
Member Author

ayeshLK commented Nov 6, 2024

This effort is currently on hold due to the following lang issue [1]

[1] - ballerina-platform/ballerina-lang#43554

@ayeshLK
Copy link
Member Author

ayeshLK commented Nov 13, 2024

We are re-starting this efforts and the latest Ballerina lang timestamp is 2201.11.0-20241111-172200-095db58f

@Nuvindu
Copy link
Contributor

Nuvindu commented Nov 13, 2024

Tested the ldap library with the U11 timestamp for DCE and confirmed no fixes are needed. And didn't generate the library timestamp either as it is not used as a dependency for other modules.

@ayeshLK
Copy link
Member Author

ayeshLK commented Nov 13, 2024

Tested following modules with shared U11 timestamp for DCE and confirmed that no fixes are needed. And didn't generate the library timestamp either as it is not used as a dependency for other modules.

  • java.arrays
  • math.vector

@Nuvindu
Copy link
Contributor

Nuvindu commented Nov 18, 2024

Tested the avro library with the U11 timestamp for DCE and confirmed that no fixes are needed.

@MaryamZi
Copy link
Member

We have introduced a fix for ballerina-platform/ballerina-lang#43579.

We are yet to fix ballerina-platform/ballerina-lang#43580, but we're not considering it as a blocker to migrate modules at the moment since it seems to happen only when a construct from the default module is used in the tests of a non-default module (which is an edge case).

@MaryamZi
Copy link
Member

We have introduced a fix for ballerina-platform/ballerina-lang#43579.

Timestamped pack with this (and Java 21 migration) - 2201.11.0-20241125-172000-b341719a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment