You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/04/30 01:44:43 UTC

[GitHub] [beam] damccorm commented on a diff in pull request #17475: [BEAM-11105] Add manual watermark estimation

damccorm commented on code in PR #17475:
URL: https://github.com/apache/beam/pull/17475#discussion_r862276118


##########
sdks/go/pkg/beam/core/runtime/exec/fn_arity.tmpl:
##########
@@ -30,7 +30,7 @@ import (
 func (n *invoker) initCall() {
 	switch fn := n.fn.Fn.(type) {
 {{range $out := upto 5}}
-{{range $in := upto 9}}
+{{range $in := upto 10}}

Review Comment:
   Yeah, that's a good call - there was not a clear benefit to doing this. I tried the following benchmarks:
   
   ```
   func BenchmarkInvokeWith9Args_Call9x4(b *testing.B) {
   	fn, _ := funcx.New(reflectx.MakeFunc9x4(func(a1 typex.EventTime, a2 bool, a3 string, a4 int, a5 bool, a6 int, a7 string, a8 bool, a9 int) (int, bool, string, error) {
   		return a4 + a6 + a9, a2 && a5 && a8, a3 + a7, nil
   	}))
   	args := []interface{}{mtime.ZeroTimestamp.Add(2 * time.Millisecond), true, "hello", 1, true, 3, "world", false, 4}
   	f := fn.Fn.(reflectx.Func9x4)
   	for n := 0; n < b.N; n++ {
   		f.Call9x4(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8])
   	}
   }
   
   func BenchmarkInvokeWith9Args_Call(b *testing.B) {
   	fn, _ := funcx.New(reflectx.MakeFunc(func(a1 typex.EventTime, a2 bool, a3 string, a4 int, a5 bool, a6 int, a7 string, a8 bool, a9 int) (int, bool, string, error) {
   		return a4 + a6 + a9, a2 && a5 && a8, a3 + a7, nil
   	}))
   	args := []interface{}{mtime.ZeroTimestamp.Add(2 * time.Millisecond), true, "hello", 1, true, 3, "world", false, 4}
   	f := fn.Fn
   	for n := 0; n < b.N; n++ {
   		f.Call(args)
   	}
   }
   ```
   
   with the result:
   
   ```
   BenchmarkInvokeWith9Args_Call9x4-16    	  722283	      1577 ns/op
   BenchmarkInvokeWith9Args_Call-16       	  805590	      1447 ns/op
   ```
   
   So the normal call is actually more performant. It is probably worth revisiting this more systematically for lower arities as well, but I think that should fall outside the scope of this PR. For the moment, I've lowered it back down to 9



-- 
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@beam.apache.org

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