Comments (4)
So far I have observed fallowing problems related to memory with respect to BIR serialization logic
- Every rec atom we create is not actually defined in the BIR. We create various atoms as part of the various type checks (such a
Cloneable
type). When we serialize the package we don't serialize these atoms but we still level "holes" in the atoms indices (since they are determined by the number of rec atoms defined at that point).As a workaround for this I introduced the ability to "compact" the rec atom indices before serialization by removing nulls. Unfortunately this reduce memory consumption of packages separated by one level only. (One possible improvement would be to do an analysis on the package before serialization and compact the indices before serialization). I managed to fix out of memory issues in level 6 and 7 this way.This was fixed by "re-indexing" the rec atoms as well write the BIR. Basically for each given rec atom index we will calculate a new index by the order in which we see it when serializing the BIR. This should ensure the BIR there are no holes in RecAtoms (assuming we serialize only one package). - Lets call BDDs with a single atom and left true, middle and and right false simple BDDs. Most BDDs are of this simple variety (These represent BDDs that are of single atomic type). However for each of these we spend the memory for 3 fields that hold pointers to left, right and middle (actual values are singletons in this case). Instead introduced a different subclass that only has the atom and waste no memory to store fields to left, right and middle
- All mapping and list atoms store their "members" as cells (in order tot properly represent mutability) which consumes considerable amount of memory.
- Different maps have fields with the same name, type and mutability combinations in most of the out of memory examples. Currently we create separate field objects for each (fixing 3 should reduce the overhead of this however)
from ballerina-lang.
#43095 Implements 1 and 2. I experimented with a solution to fix 3 (for mapping only) but of that to work either we need to update the type checking logic in MappingOps
to work with them. Trying to create temperary cell atoms that are not part of environment failed. However given now we can remove Atoms from Env when we start to run out of memory this shouldn't be a major problem.
At point where we run out of memory we are holding a considerable number of byte arrays with the content of BIR files. Ideally we should have dropped those byte arrays by that point given those BIRs have been successfully unmarshalled. Given we don't have an efficient serialization format to represent SemTypes having lot of semtypes in the serialized file is exacerbating this issue. Therefore I have decided to temporarily disable semtype serialization for most cases (except for Fininte types)
from ballerina-lang.
Fixed with #43095
from ballerina-lang.
This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.
- Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
- Reason/Regression - The issue has introduced a regression.
- Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
- Reason/Complex - Issue occurred due to complex scenario.
- Reason/Invalid - Issue is invalid.
- Reason/Other - None of the above cases.
from ballerina-lang.
Related Issues (20)
- [Bug]: When opening Ballerina projects with large ballerina files the VS Code plugin crashes HOT 1
- [Task]: Implement function semtype in runtime
- [Improvement]: Implement dead code elimination
- [Bug]: Invalid output in `toString` function for nested array
- [Improvement]: Allow having two different major versions of a package in the dependency graph
- [Bug]: Constant annotation value is exposing internal BLangConstantValue for array values
- [Task]: Implement object semtype in runtime
- [Task]: Disallow using `check` in function parameter defaults
- [Task]: Support ballerina lang to build with Java 21
- [Bug]: Fill record field code action and completion item giving partial result for nested records
- Method annotations not available on object type descriptors HOT 1
- Designing static rules for language static code analyzer
- Add docs for CSV module HOT 1
- [Improvement]: Optimize the compile time memory usage HOT 1
- [Improvement]: Directly resolve semtypes from AST, instead via BTypes
- [Bug]: Package metadata passed to the vscode extension does not contain organization details
- [New Feature]: Add `date/time` type to language
- [Bug]: Distinct objects are shouldn't be assignable to each other
- [Bug]: The `Run` code lens does not work for services HOT 4
- [Bug]: Isolated and transaction qualifiers must be a part of the function type
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ballerina-lang.