sjvanrossum commented on PR #34165:
URL: https://github.com/apache/beam/pull/34165#issuecomment-2713224412
@kennknowles I've updated the experiment setup in the benchmark. I've
reduced concurrent readers to 1, because as far as I know only the
`ProcessElement` thread reads and writes the accumulator and a `GetSize` thread
occassionally reads the accumulator concurrently in the SDF implementation and
it's either similar or entirely single-threaded for the unbounded source
implementation. I've also split these tests out into concurrents reads and
writes and isolated reads and writes, because those concurrent reads only
happen every so often and occasionally overlap with writes (observed in #32921
rarely triggering `ConcurrentModificationException`). With multiple concurrent
readers I had observed 10-20% improvement with padding, but the improvements
are barely noticeable now if at all (on my workstation).
```
Benchmark
Mode Cnt Score Error Units
KafkaIOUtilsBenchmark.ReadAndWriteAtomic
avgt 15 12.948 ± 1.999 ns/op
KafkaIOUtilsBenchmark.ReadAndWriteAtomic:atomicReadWhileWriting
avgt 15 4.798 ± 0.200 ns/op
KafkaIOUtilsBenchmark.ReadAndWriteAtomic:atomicWriteWhileReading
avgt 15 21.098 ± 3.811 ns/op
KafkaIOUtilsBenchmark.ReadAndWritePaddedAtomic
avgt 15 13.676 ± 1.509 ns/op
KafkaIOUtilsBenchmark.ReadAndWritePaddedAtomic:paddedAtomicReadWhileWriting
avgt 15 4.598 ± 0.064 ns/op
KafkaIOUtilsBenchmark.ReadAndWritePaddedAtomic:paddedAtomicWriteWhileReading
avgt 15 22.755 ± 3.075 ns/op
KafkaIOUtilsBenchmark.ReadAndWritePlain
avgt 15 15.909 ± 1.780 ns/op
KafkaIOUtilsBenchmark.ReadAndWritePlain:plainReadWhileWriting
avgt 15 4.058 ± 0.160 ns/op
KafkaIOUtilsBenchmark.ReadAndWritePlain:plainWriteWhileReading
avgt 15 27.760 ± 3.589 ns/op
KafkaIOUtilsBenchmark.ReadAndWriteSynchronizedPlain
avgt 15 95.190 ± 1.845 ns/op
KafkaIOUtilsBenchmark.ReadAndWriteSynchronizedPlain:synchronizedPlainReadWhileWriting
avgt 15 98.039 ± 3.973 ns/op
KafkaIOUtilsBenchmark.ReadAndWriteSynchronizedPlain:synchronizedPlainWriteWhileReading
avgt 15 92.341 ± 2.358 ns/op
KafkaIOUtilsBenchmark.ReadAndWriteVolatile
avgt 15 26.432 ± 4.415 ns/op
KafkaIOUtilsBenchmark.ReadAndWriteVolatile:volatileReadWhileWriting
avgt 15 3.879 ± 0.056 ns/op
KafkaIOUtilsBenchmark.ReadAndWriteVolatile:volatileWriteWhileReading
avgt 15 48.984 ± 8.849 ns/op
KafkaIOUtilsBenchmark.ReadAtomic
avgt 15 2.185 ± 0.007 ns/op
KafkaIOUtilsBenchmark.ReadPaddedAtomic
avgt 15 2.193 ± 0.010 ns/op
KafkaIOUtilsBenchmark.ReadPlain
avgt 15 2.206 ± 0.011 ns/op
KafkaIOUtilsBenchmark.ReadSynchronizedPlain
avgt 15 7.975 ± 0.571 ns/op
KafkaIOUtilsBenchmark.ReadVolatile
avgt 15 2.199 ± 0.011 ns/op
KafkaIOUtilsBenchmark.WriteAtomic
avgt 15 8.183 ± 0.003 ns/op
KafkaIOUtilsBenchmark.WritePaddedAtomic
avgt 15 8.183 ± 0.003 ns/op
KafkaIOUtilsBenchmark.WritePlain
avgt 15 9.592 ± 0.746 ns/op
KafkaIOUtilsBenchmark.WriteSynchronizedPlain
avgt 15 11.145 ± 1.714 ns/op
KafkaIOUtilsBenchmark.WriteVolatile
avgt 15 11.967 ± 0.003 ns/op
```
I agree that it's not worth the hassle to maintain unless there's a
significant upside so I've removed the layout padding from `MovingAvg` based on
the results above.
--
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]