apache / apache/arrow-java

[Java] allocate new buffer code doesn't release extra allocated buffer properly

未關閉
#417 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
Type: bug
主要語言
Java
星號
94
分支
152
平均合併
3 天 16 小時
30 天內合併 PR
11

描述

[Class BaseValueVector](https://github.com/apache/arrow/blob/master/java/vector/src/main/java/org/apache/arrow/vector/BaseValueVector.java) 's method allocFixedDataAndValidityBufs on line#162 allocates a buffer in power of 2 size. After that, it has a code to release extra buffer. For that, it calculates the extra buffer from allocated size "bufferSize" but in my opinion, it should take original "valueCount" to find the extra buffer size. 

Here, I see a problem in line#162, where its taking "bufferSize" to find the extra allocated bytes. It should be "valueCount\*typeWidth + valueCount/8".

Here is an example for that. Let's take 1000 ints. Then,
valueCount = 1000 ints
typeWidth = 4 bytes
validitiyBufferSize = 125 bytes
valueBufferSize = 4000 bytes
combinedSize(valueBufferSize + validityBufferSize) = 4128 bytes (multiple of 8)
combinedSizeWith2ThePowerSize = 8192 bytes, this will be "bufferSize" at line#152.

With the above calculation, this code should release (combinedSizeWith2ThePowerSize - combinedSize) = 4064 bytes. But, this is not happening.

 

 

**Reporter**: [Hitesh Khamesra](https://issues.apache.org/jira/browse/ARROW-5057)
#### PRs and other links:
- [GitHub Pull Request apache/arrow#4079](https://github.com/apache/arrow/pull/4079)

**Note**: *This issue was originally created as [ARROW-5057](https://issues.apache.org/jira/browse/ARROW-5057). Please see the [migration documentation](https://github.com/apache/arrow/issues/14542) for further details.*

貢獻指南

開啟貢獻指南

研究方向

從 java/vector/src/main/java/org/apache/arrow/vector/BaseValueVector.java 的 allocFixedDataAndValidityBufs 開始,重點查看第 162 行附近的配置和額外緩衝區釋放。追蹤 1,000 個 int 範例的緩衝區大小計算,並確認已完成的變更是否釋放了預期的額外配置;注意,PR apache/arrow#4079 已經與此 issue 關聯。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
java
領域
data, performance
Issue 類型
缺陷
難度
2/5
預估耗時
1-3 小時
活躍度
停滯
描述清晰度
描述清楚
新手友好度
20/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。