lostluck opened a new issue, #25522:
URL: https://github.com/apache/beam/issues/25522

   ### What needs to happen?
   
   Replace all small []byte, or bytes.Buffer uses with a central `sync.Pool` 
allocated "buffer" package, like 
   
   
https://cs.opensource.google/go/x/exp/+/f062dba9:slog/internal/buffer/buffer.go;bpv=1;bpt=1
   
   or 
   
   https://github.com/golang/go/blob/master/src/log/log.go#L165
   
   https://pkg.go.dev/sync#Pool are weak reference pools meaning that buffers 
in the pool may be freed at during the next GC if appropriate.
   
   While some unsafe strategies were used as well, through the [ioutilx package 
read](https://github.com/apache/beam/blob/master/sdks/go/pkg/beam/core/util/ioutilx/read.go#L54)
 and 
[write](https://github.com/apache/beam/blob/master/sdks/go/pkg/beam/core/util/ioutilx/write.go#L27)
 calls to avoid allocations, this remains slightly risky, so uses there are a 
reasonable priority.
   
   But generally, [uses of 
bytes.Buffer](https://github.com/apache/beam/search?l=Go&q=bytes.Buffer) or 
arbitrary lengths but known lifetime uses of [make([]byte)]( 
https://github.com/apache/beam/search?l=Go&q=make%28%5B%5Dbyte)
   
   Some bytes.Buffer replacements would require this new Buffer to support the 
io.Reader interface as well.
   
   In particular, targeting the uses in the exec and harness packages would 
likely be the most fruitful.
   
   It would be worth having a moderate scale benchmark to validate the before 
and after performance of this change, with appropriate heap and CPU profiles.
   
   ### Issue Priority
   
   Priority: 3 (nice-to-have improvement)
   
   ### Issue Components
   
   - [ ] Component: Python SDK
   - [ ] Component: Java SDK
   - [X] Component: Go SDK
   - [ ] Component: Typescript SDK
   - [ ] Component: IO connector
   - [ ] Component: Beam examples
   - [ ] Component: Beam playground
   - [ ] Component: Beam katas
   - [ ] Component: Website
   - [ ] Component: Spark Runner
   - [ ] Component: Flink Runner
   - [ ] Component: Samza Runner
   - [ ] Component: Twister2 Runner
   - [ ] Component: Hazelcast Jet Runner
   - [ ] Component: Google Cloud Dataflow Runner


-- 
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