You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "asubiotto (via GitHub)" <gi...@apache.org> on 2023/11/15 12:08:02 UTC

[PR] GH-38728: [Go] ipc: put lz4 decompression buffers back into sync.Pool [arrow]

asubiotto opened a new pull request, #38729:
URL: https://github.com/apache/arrow/pull/38729

   The lz4 decompressor was not calling Reset on the underlying writer in its Close method. This could cause buffers not to be released back to the pool and defeating the purpose of the sync.Pool in the lz4 package.
   
   Additionally, a call to Close was missing in readDictionary.
   
   Closes #38728 


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-38728: [Go] ipc: put lz4 decompression buffers back into sync.Pool [arrow]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade merged PR #38729:
URL: https://github.com/apache/arrow/pull/38729


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-38728: [Go] ipc: put lz4 decompression buffers back into sync.Pool [arrow]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on PR #38729:
URL: https://github.com/apache/arrow/pull/38729#issuecomment-1814758189

   @asubiotto Looks like you've got a nil de-reference issue in the current version, i'm guessing there's a situation where you are calling close even if we didn't actually perform compression / decompression? Haven't looked into it myself yet


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-38728: [Go] ipc: put lz4 decompression buffers back into sync.Pool [arrow]

Posted by "conbench-apache-arrow[bot] (via GitHub)" <gi...@apache.org>.
conbench-apache-arrow[bot] commented on PR #38729:
URL: https://github.com/apache/arrow/pull/38729#issuecomment-1828849001

   After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit b0e1f748f5f96d3a7f79edf2b959a01af347dfda.
   
   There were no benchmark performance regressions. 🎉
   
   The [full Conbench report](https://github.com/apache/arrow/runs/19076528430) has more details.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-38728: [Go] ipc: put lz4 decompression buffers back into sync.Pool [arrow]

Posted by "asubiotto (via GitHub)" <gi...@apache.org>.
asubiotto commented on PR #38729:
URL: https://github.com/apache/arrow/pull/38729#issuecomment-1824036526

   Apologies for the delay, I was on PTO. The issue was that I was double-closing the writer since I was unaware the `compress` function already closes the writer (`Close` is part of the interface via `io.WriterCloser`). I removed the last commit (writing only) since it was unnecessary. Should be good now.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-38728: [Go] ipc: put lz4 decompression buffers back into sync.Pool [arrow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #38729:
URL: https://github.com/apache/arrow/pull/38729#issuecomment-1812425824

   :warning: GitHub issue #38728 **has been automatically assigned in GitHub** to PR creator.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-38728: [Go] ipc: put lz4 decompression buffers back into sync.Pool [arrow]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on PR #38729:
URL: https://github.com/apache/arrow/pull/38729#issuecomment-1812762013

   I wonder if it's possible to add a unit test or benchmark or otherwise to check and prevent this issue from recurring? This looks good to me in general. If there's a good way to reasonably add a test or other check then let's do that, but if not then I'm happy with this. Let me know what you think @asubiotto 


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-38728: [Go] ipc: put lz4 decompression buffers back into sync.Pool [arrow]

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on PR #38729:
URL: https://github.com/apache/arrow/pull/38729#issuecomment-1812440224

   Just curious do we have some before-after benchmarks


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-38728: [Go] ipc: put lz4 decompression buffers back into sync.Pool [arrow]

Posted by "asubiotto (via GitHub)" <gi...@apache.org>.
asubiotto commented on PR #38729:
URL: https://github.com/apache/arrow/pull/38729#issuecomment-1814111866

   Added a commit with the benchmark and another commit to have writers release buffers. It's not noticeable in the benchmark because we're probably writing too little but it doesn't hurt:
   ```
   goos: darwin
   goarch: arm64
   pkg: github.com/apache/arrow/go/v15/arrow/ipc
                             │  benchmain   │             benchclose              │
                             │    sec/op    │   sec/op     vs base                │
   IPC/Writer/codec=plain-12   8.370µ ±  5%   8.264µ ± 2%   -1.25% (p=0.043 n=10)
   IPC/Reader/codec=plain-12   11.41µ ±  4%   11.13µ ± 4%   -2.43% (p=0.014 n=10)
   IPC/Writer/codec=zstd-12    1.089m ± 12%   1.096m ± 8%        ~ (p=0.912 n=10)
   IPC/Reader/codec=zstd-12    38.22µ ±  3%   36.45µ ± 6%        ~ (p=0.052 n=10)
   IPC/Writer/codec=lz4-12     16.09µ ±  2%   15.99µ ± 5%        ~ (p=0.436 n=10)
   IPC/Reader/codec=lz4-12     40.79µ ±  4%   13.06µ ± 4%  -67.98% (p=0.000 n=10)
   geomean                     37.10µ         30.26µ       -18.44%
   
                             │   benchmain   │               benchclose               │
                             │     B/op      │     B/op      vs base                  │
   IPC/Writer/codec=plain-12    8.394Ki ± 0%   8.394Ki ± 0%        ~ (p=1.000 n=10) ¹
   IPC/Reader/codec=plain-12    8.646Ki ± 0%   8.646Ki ± 0%        ~ (p=1.000 n=10) ¹
   IPC/Writer/codec=zstd-12     35.52Mi ± 0%   35.52Mi ± 0%        ~ (p=0.810 n=10)
   IPC/Reader/codec=zstd-12     25.63Ki ± 0%   25.63Ki ± 0%        ~ (p=0.063 n=10)
   IPC/Writer/codec=lz4-12      14.21Ki ± 1%   14.16Ki ± 0%   -0.35% (p=0.043 n=10)
   IPC/Reader/codec=lz4-12     266.53Ki ± 0%   10.55Ki ± 0%  -96.04% (p=0.000 n=10)
   geomean                      79.69Ki        46.50Ki       -41.66%
   ¹ all samples are equal
   
                             │ benchmain  │             benchclose              │
                             │ allocs/op  │ allocs/op   vs base                 │
   IPC/Writer/codec=plain-12   113.0 ± 0%   113.0 ± 0%       ~ (p=1.000 n=10) ¹
   IPC/Reader/codec=plain-12   126.0 ± 0%   126.0 ± 0%       ~ (p=1.000 n=10) ¹
   IPC/Writer/codec=zstd-12    271.0 ± 0%   271.0 ± 0%       ~ (p=1.000 n=10) ¹
   IPC/Reader/codec=zstd-12    219.0 ± 0%   219.0 ± 0%       ~ (p=1.000 n=10) ¹
   IPC/Writer/codec=lz4-12     167.0 ± 0%   167.0 ± 0%       ~ (p=1.000 n=10) ¹
   IPC/Reader/codec=lz4-12     154.0 ± 0%   149.0 ± 0%  -3.25% (p=0.000 n=10)
   geomean                     167.1        166.1       -0.55%
   ¹ all samples are equal
   ```


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-38728: [Go] ipc: put lz4 decompression buffers back into sync.Pool [arrow]

Posted by "asubiotto (via GitHub)" <gi...@apache.org>.
asubiotto commented on PR #38729:
URL: https://github.com/apache/arrow/pull/38729#issuecomment-1812486578

   It doesn't look like there are any existing benchmarks. I've profiled our production workload before/after this change and the sync.Pool `New` allocations do not show up anymore (here is the before profile I linked in the issue: https://pprof.me/d5122d09b9dae81844c3068f75e31b76/?profileType=profile%3Aalloc_space%3Abytes%3Aspace%3Abytes)


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-38728: [Go] ipc: put lz4 decompression buffers back into sync.Pool [arrow]

Posted by "asubiotto (via GitHub)" <gi...@apache.org>.
asubiotto commented on PR #38729:
URL: https://github.com/apache/arrow/pull/38729#issuecomment-1814051063

   I think it is possible but I'm not sure there is a simple and elegant way to do so. Some things I've considered:
   1) Attaching some sort of verifier to the decompressors behind a compile-time debug check (given this package uses that pattern already). When enabled, it would attach a finalizer to the decompressor object and verify it has been closed. However, this would probably require changing the `decompressor` interface and I'm not sure I like that.
   2) Add some sort of compressor provider interface that is swapped out during tests with a wrapper over the `decompressor` interface that is verified in a defer (sort of like a `CheckedAllocator`). I'm not a fan of adding more interfaces where they're not really needed and this solution would require tests to create/defer themselves (unless we put this in a global var that is verified in `TestMain`)
   
   Technically, this is not a correctness issue so I don't think a test is required here given the overhead. I'll maybe write up a benchmark though since it could be useful for other cases.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-38728: [Go] ipc: put lz4 decompression buffers back into sync.Pool [arrow]

Posted by "asubiotto (via GitHub)" <gi...@apache.org>.
asubiotto commented on PR #38729:
URL: https://github.com/apache/arrow/pull/38729#issuecomment-1814072183

   ```
   pkg: github.com/apache/arrow/go/v15/arrow/ipc
                       │  benchmain   │             benchclose              │
                       │    sec/op    │    sec/op     vs base               │
   Reader/codec=lz4-12   38.05µ ± 12%   12.97µ ± 19%  -65.92% (p=0.002 n=6)
   
                       │   benchmain   │             benchclose              │
                       │     B/op      │     B/op      vs base               │
   Reader/codec=lz4-12   266.58Ki ± 0%   10.49Ki ± 1%  -96.07% (p=0.002 n=6)
   
                       │ benchmain  │            benchclose            │
                       │ allocs/op  │ allocs/op   vs base              │
   Reader/codec=lz4-12   155.0 ± 0%   149.0 ± 0%  -3.87% (p=0.002 n=6)
   ```
   
   I think we might be suffering from the same issue in writers btw, will take a look.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-38728: [Go] ipc: put lz4 decompression buffers back into sync.Pool [arrow]

Posted by "asubiotto (via GitHub)" <gi...@apache.org>.
asubiotto commented on PR #38729:
URL: https://github.com/apache/arrow/pull/38729#issuecomment-1827471616

   I don't think the context itself is that big of an object and at least I haven't seen it be a limitation for my use case. The overhead here is mostly from the codec buffers. I would probably hold off unless we see a clear need.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-38728: [Go] ipc: put lz4 decompression buffers back into sync.Pool [arrow]

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on PR #38729:
URL: https://github.com/apache/arrow/pull/38729#issuecomment-1824211831

   I'm not so familiar with Arrow GoLang impl, just curious should we poolize the zstd decompress context ( or maybe it's already implemented ?)


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org