Fork chain selection mechanism is one of the most important feature of blockchain stability. During my code review of java-tron, I discovered that KhaosDatabase is used to store all non-solidified blocks. In local testing analysing KhaosDatabase capacity under non-solidification conditions (running a FullNode on MainNet with solidification logic commented out at updateSolidBlock ), I observed each block consumes ~1.2MB memory on average. Here is one KhaosBlock hump dump result:
At this consumption rate, KhaosDatabase alone would require at least 5.6GB(test observed) memory per maintenance period. Combined with SnapShot and other overhead, this could quickly lead to OOM under our recommended 9GB JVM configuration. It means in abnormal cases, the TRON network only have few hours to found the issue and fix it, or FullNodes have to be restarted to recover because of OOM.
Detailed memory analysis of KhaosDatabase variables reveals TransactionRetCapsule (shown in the image) accounts for at least 1/3 of memory usage. Code review shows this variable is only used to pass data to TransactionRetStore.
Want to ask community whether it is feasible to remove TransactionRetCapsule storage from KhaosDatabase. This optimisation could save ≥33% memory, making nodes more robust during abnormal conditions and improving recovery capability.
Fork chain selection mechanism is one of the most important feature of blockchain stability. During my code review of java-tron, I discovered that
KhaosDatabaseis used to store all non-solidified blocks. In local testing analysingKhaosDatabasecapacity under non-solidification conditions (running a FullNode on MainNet with solidification logic commented out at updateSolidBlock ), I observed each block consumes ~1.2MB memory on average. Here is oneKhaosBlockhump dump result:At this consumption rate,
KhaosDatabasealone would require at least 5.6GB(test observed) memory per maintenance period. Combined with SnapShot and other overhead, this could quickly lead to OOM under our recommended 9GB JVM configuration. It means in abnormal cases, the TRON network only have few hours to found the issue and fix it, or FullNodes have to be restarted to recover because of OOM.Detailed memory analysis of
KhaosDatabasevariables revealsTransactionRetCapsule(shown in the image) accounts for at least 1/3 of memory usage. Code review shows this variable is only used to pass data to TransactionRetStore.Want to ask community whether it is feasible to remove
TransactionRetCapsulestorage fromKhaosDatabase. This optimisation could save ≥33% memory, making nodes more robust during abnormal conditions and improving recovery capability.