You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "thorfour (via GitHub)" <gi...@apache.org> on 2023/07/13 16:32:31 UTC
[GitHub] [arrow] thorfour opened a new issue, #36671: [Go] Optimize memotable GetOrInsert
thorfour opened a new issue, #36671:
URL: https://github.com/apache/arrow/issues/36671
### Describe the enhancement requested
The memotable `GetOrInsert` function was implement with the `interface{}` to make it generic between builders.
https://github.com/apache/arrow/blob/7690409568e8a4b51946f292b109075629ed1ee7/go/internal/hashing/xxh3_memo_table.go#L55
However this empty interface conversion can come with a cost. We've noticed that when building large binary dictionary arrays that a large portion of CPU and memory allocations are spent converting the byte slice into `interface{}`
CPU:

Allocs:

I copy/pastad a new memo table that only operates on `[]byte` to prove this theory; below is the profile with those changes.
CPU:

Allocs:

I see two straightforward ways to potentially address this. Use a `[]byte` specific memo table for `BinaryDictionaryBuilder` since it's going to be the only builder that suffers from this type of allocation. Or to replace the memotables with generics
```go
type MemoTable[T any] interface {
...
GetOrInsert(val T) (idx int, existed bool, err error)
...
}
```
### Component(s)
Go
--
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: issues-unsubscribe@arrow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] zeroshade closed issue #36671: [Go] Optimize memotable GetOrInsert
Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade closed issue #36671: [Go] Optimize memotable GetOrInsert
URL: https://github.com/apache/arrow/issues/36671
--
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: issues-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] zeroshade commented on issue #36671: [Go] Optimize memotable GetOrInsert
Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on issue #36671:
URL: https://github.com/apache/arrow/issues/36671#issuecomment-1635070178
I'd love to see the addition of a proper generic implementation of the memo table.
It might be about time that we drop support for go1.17 and just update it to use the generics. Would you be willing to put up a PR for this?
--
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
[GitHub] [arrow] thorfour commented on issue #36671: [Go] Optimize memotable GetOrInsert
Posted by "thorfour (via GitHub)" <gi...@apache.org>.
thorfour commented on issue #36671:
URL: https://github.com/apache/arrow/issues/36671#issuecomment-1645804841
@zeroshade I overcomplicated that first PR. I've closed it in favor of #36811 which I thinks keeps the changes to a minimum while still accomplishing the goal of optimizing the `BinaryDictionaryBuilder`
--
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
[GitHub] [arrow] thorfour commented on issue #36671: [Go] Optimize memotable GetOrInsert
Posted by "thorfour (via GitHub)" <gi...@apache.org>.
thorfour commented on issue #36671:
URL: https://github.com/apache/arrow/issues/36671#issuecomment-1640928301
@zeroshade I spun my wheels for a few days on a generic implementation that didn't change any code logic. However I was unable to come up with one that worked. I got really close in [this branch](https://github.com/thorfour/arrow/tree/go-generic-memotable) but ultimately couldn't get it to work with the util function `GetDictArrayData` that casts the memo table to it's underlying type (apparently doesn't work well with typed generics).
I think it still should be doable but it's going to require a larger rewrite and/or potentially a redesigned memotable that uses the same underling logic for all types.
For now I opened a draft PR with my original implementation which just changes the `BinaryMemoTable` to use a byte specific implementation instead of `interface{}`. Curious to get your thoughts on the best approach forward here.
--
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
[GitHub] [arrow] thorfour commented on issue #36671: [Go] Optimize memotable GetOrInsert
Posted by "thorfour (via GitHub)" <gi...@apache.org>.
thorfour commented on issue #36671:
URL: https://github.com/apache/arrow/issues/36671#issuecomment-1635084311
>
I'd love to take a crack at it!
--
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