-
Notifications
You must be signed in to change notification settings - Fork 756
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
[Improvement]: Introduce an index for package meta information #43322
Comments
This feature intends to offload the package resolution logic from the Ballerina Central to the language resolution engine. Currently supporting custom package registries is hard due to the complexity of the package registry server implementation. However, once this is completed, the client (i.e. the local Ballerina instance) will do the dependency resolution, so the server doesn't need to be intelligent. That way any custom server implementations will not have to worry about dependency resolution. We are getting inspiration from the Rust implementation of their package registry indexing. The document below is the design document for the feature. |
The current progress on the design that we have agreed upon contains,
However, we are in the process of evaluating what's the best possible approach to implementing the index. The main approaches are,
|
We had an offline chat about this and decided to proceed with a Git-based approach. I believe This approach should work fine for Ballerina for the next few years. We could move to a sparse indexing solution if and when it becomes a bottleneck. |
A POC implementation for the indexing is now carried out. The approach used is git-based. As a part of the POC, we need to generate a index for the current existing packages. For this, a new admin endpoint needs to be added to the central package API. For this, https://github.com/wso2-enterprise/ballerina-registry/pull/2835 has been sent to the Furthermore, I'm parallelly working on introducing the package resolution logic that uses the index implementation from the project API side. |
After last week meeting on indexing, we decided to look into an index-optimized dependency resolution.
However, with the introduction of the index, we don't have a dependency graph with us. Instead, we have only the direct dependencies of a package. Furthermore, we have all the package index information available locally. Therefore, a newer design that doesn't require the dependency graph to be sent from the Central is appropriate. The current design that is being worked on is iterating the dependencies as we find them using a DFS of a BFS and resolving the dependency conflicts as we create and traverse the graph. An alternate approach is using an SAT[1], similar to what's specified in [2] and [3]. This is an algorithm used to solve a Boolean satisfiability problem. Once we convert the dependencies and the other constraints to boolean expressions, the SAT solver will do the rest. This has been done in other programming languages successfully. [1] https://en.wikipedia.org/wiki/SAT_solver |
The Central PR for bulk index creation has been merged. However, the process couldn't be deployed in the Central dev environment due to the lack of file creation permissions. I am currently working on using temp directories to avoid this. |
An implementation of the package resolution is implemented here - https://github.com/gayaldassanayake/package-resolver/. The implementation was done in Ballerina. I am currently working on moving it to Java and integrating it with the compilation process. This implementation contains the simplest scenario where the locking mode is SOFT. The following are the constraints that need to be considered/ implemented next.
The newly proposed locking modes can be found in here. |
An initial draft implementation of the resolution has been implemented. Following have been so far implemented.
This branch will be updated with new commits as the next set of features get add on to the implementation. https://github.com/gayaldassanayake/ballerina-lang/tree/index-based-resolution |
With eb01b48, the following has been implemented.
The code up to this point reside in the PR #43717 The next steps are,
|
The module-level import handling has been added to the draft PR. As the next step, I am trying to standardize the set of Java APIs. This will
|
Description
Introduce a local index for package meta information which will be used for the resolution decisions done on the client side.
Describe your problem(s)
No response
Describe your solution(s)
No response
Related area
-> Other Area
Related issue(s) (optional)
No response
Suggested label(s) (optional)
No response
Suggested assignee(s) (optional)
No response
The text was updated successfully, but these errors were encountered: