shuwenwei opened a new pull request, #18452:
URL: https://github.com/apache/iotdb/pull/18452

   ## Motivation
   
   On the write path, `AlignedTVList.getRamSize()` is called twice per 
`insertTablet` (pre-write snapshot + post-write reconciliation). 
`calculateContainerRamCost()` calls `RamUsageEstimator.shallowSizeOf(list)` for 
every `ArrayList` in the N-wide containers, which performs reflective layout 
computation on each call.
   
   An async-profiler flame graph confirmed that within 
`DataRegion.insertTablet`, the `getRamSize` chain accounts for a significant 
share of CPU time, and the self time is almost entirely in 
`RamUsageEstimator.shallowSizeOfInstance`.
   
   ## Change
   
   Replace the per-call `RamUsageEstimator.shallowSizeOf(list)` with the 
pre-computed constant `MemoryEstimationHelper.ARRAY_LIST_INSTANCE_SIZE` in 
`listRamCostWithReferences` and `listRamCostWithoutReferences`.
   
   All lists passed to these helpers (`dataTypes`, `timestamps`, `indices`, 
`values`, `bitMaps` and their inner lists) are `ArrayList` instances, so the 
constant is exactly equal to `shallowSizeOf` for them and the accounting result 
is unchanged.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to