[
https://issues.apache.org/jira/browse/BEAM-14347?focusedWorklogId=769960&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-769960
]
ASF GitHub Bot logged work on BEAM-14347:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 12/May/22 23:36
Start Date: 12/May/22 23:36
Worklog Time Spent: 10m
Work Description: lostluck commented on code in PR #17650:
URL: https://github.com/apache/beam/pull/17650#discussion_r871890927
##########
sdks/go/pkg/beam/register/register_test.go:
##########
@@ -818,25 +865,37 @@ func BenchmarkMethodCalls(b *testing.B) {
registration func()
}{
// No optimization performed at all
- {"MakeFunc_Unoptimized", func() { aFunc =
reflectx.MakeFunc(f.ProcessElement) }, func() { /*No op*/ }},
// Used in graph deserialization
- {"MakeFunc.Call_Unoptimized", func() { aFnCall =
aFunc.Call(funcIn)[0].(int) }, func() { /*No op*/ }},
// Used to call the function repeatedly
- {"MakeFunc.Call1x1_Unoptimized", func() { aFnCall =
aFunc1x1.Call1x1(CustomType{val: 4}).(int) }, func() { aFunc1x1 =
reflectx.ToFunc1x1(aFunc) }}, // Used to call the function repeatedly
- {"NewFn_Unoptimized", func() { aFn, _ = graph.NewFn(f) },
func() { /*No op*/ }},
// Used in graph construction (less valuable)
- {"EncodeMultiEdge_Unoptimized", func() { aME, _ =
graphx.EncodeMultiEdge(&me) }, func() { /*No op*/ }},
// Used in graph serialization at execution time
+ {"MakeFunc_Unoptimized", func() { aFunc =
reflectx.MakeFunc(f.ProcessElement) }, func() { /*No op*/ }},
//
Used in graph deserialization
+ {"MakeFunc.Call_Unoptimized", func() { aFnCall =
aFunc.Call(funcIn)[0].(int) }, func() { /*No op*/ }},
// Used to
call the function repeatedly
+ {"MakeFunc.Call1x1_Unoptimized", func() { aFnCall =
aFunc1x1.Call1x1(CustomType{val: 4}).(int) }, func() { aFunc1x1 =
reflectx.ToFunc1x1(aFunc) }},
// Used to call the function repeatedly
+ {"NewFn_Unoptimized", func() { aFn, _ = graph.NewFn(f) },
func() { /*No op*/ }},
// Used in graph
construction (less valuable)
+ {"EncodeMultiEdge_Unoptimized", func() { aME, _ =
graphx.EncodeMultiEdge(&me) }, func() { /*No op*/ }},
// Used in
graph serialization at execution time
+ {"MakeFunc_FunctionalDoFn_Unoptimized", func() { aFunc =
reflectx.MakeFunc(addCustomType2) }, func() { /*No op*/ }},
// Used in graph
deserialization
+ {"MakeFunc_FunctionalDoFn.Call_Unoptimized", func() { aFnCall2
= aFunc.Call(funcIn2)[0].(CustomType2) }, func() { /*No op*/ }},
// Used to call the
function repeatedly
+ {"MakeFunc_FunctionalDoFn.Call1x1_Unoptimized", func() {
aFnCall2 = aFunc2x1.Call2x1(CustomType2{val2: 4}, CustomType2{val2:
3}).(CustomType2) }, func() { aFunc2x1 = reflectx.ToFunc2x1(aFunc) }}, // Used
to call the function repeatedly
// Perform some generic registration to optimize execution
- {"MakeFunc_GenericRegistration", func() { aFunc =
reflectx.MakeFunc(f.ProcessElement) }, func() { DoFn1x1[CustomType, int](f) }},
// Used in graph
deserialization
- {"MakeFunc.Call_GenericRegistration", func() { aFnCall =
aFunc.Call(funcIn)[0].(int) }, func() { DoFn1x1[CustomType, int](f) }},
// Used to call the function
repeatedly
- {"MakeFunc.Call1x1_GenericRegistration", func() { aFnCall =
aFunc1x1.Call1x1(CustomType{val: 3}).(int) }, func() { DoFn1x1[CustomType,
int](f); aFunc1x1 = reflectx.ToFunc1x1(aFunc) }}, // Used to call the function
repeatedly
- {"NewFn_GenericRegistration", func() { aFn, _ = graph.NewFn(f)
}, func() { DoFn1x1[CustomType, int](f) }},
// Used in graph construction (less
valuable)
- {"EncodeMultiEdge_GenericRegistration", func() { aME, _ =
graphx.EncodeMultiEdge(&me) }, func() { DoFn1x1[CustomType, int](f) }},
// Used in graph serialization
at execution time
+ {"MakeFunc_GenericRegistration", func() { aFunc =
reflectx.MakeFunc(f.ProcessElement) }, func() { DoFn1x1[CustomType, int](f) }},
// Used in graph
deserialization
+ {"MakeFunc.Call_GenericRegistration", func() { aFnCall =
aFunc.Call(funcIn)[0].(int) }, func() { DoFn1x1[CustomType, int](f) }},
// Used to call the
function repeatedly
+ {"MakeFunc.Call1x1_GenericRegistration", func() { aFnCall =
aFunc1x1.Call1x1(CustomType{val: 3}).(int) }, func() { DoFn1x1[CustomType,
int](f); aFunc1x1 = reflectx.ToFunc1x1(aFunc) }}, // Used to call the
function repeatedly
+ {"NewFn_GenericRegistration", func() { aFn, _ = graph.NewFn(f)
}, func() { DoFn1x1[CustomType, int](f) }},
// Used in graph construction
(less valuable)
+ {"EncodeMultiEdge_GenericRegistration", func() { aME, _ =
graphx.EncodeMultiEdge(&me) }, func() { DoFn1x1[CustomType, int](f) }},
// Used in graph
serialization at execution time
+ {"MakeFunc_FunctionalDoFn_GenericRegistration", func() { aFunc
= reflectx.MakeFunc(addCustomType2) }, func() { Function2x1[CustomType2,
CustomType2, CustomType2](addCustomType2) }}, // Used in graph
deserialization
+ {"MakeFunc_FunctionalDoFn.Call_GenericRegistration", func() {
aFnCall2 = aFunc.Call(funcIn2)[0].(CustomType2) }, func() {
Function2x1[CustomType2, CustomType2, CustomType2](addCustomType2) }}, // Used
to call the function repeatedly
+ {"MakeFunc_FunctionalDoFn.Call1x1_GenericRegistration", func()
{ aFnCall2 = aFunc2x1.Call2x1(CustomType2{val2: 4}, CustomType2{val2:
3}).(CustomType2) }, func() {
+ Function2x1[CustomType2, CustomType2,
CustomType2](addCustomType2)
+ aFunc2x1 = reflectx.ToFunc2x1(aFunc)
+ }}, // Used to call the function repeatedly
// Perform some registration via copies of the code generator's
shims
- {"MakeFunc_GeneratedShims", func() { aFunc =
reflectx.MakeFunc(f.ProcessElement) }, func() { GeneratedOptimizationCalls()
}}, // Used in graph
deserialization
- {"MakeFunc.Call_GeneratedShims", func() { aFnCall =
aFunc.Call(funcIn)[0].(int) }, func() { GeneratedOptimizationCalls() }},
// Used to call the function
repeatedly
- {"MakeFunc.Call1x1_GeneratedShims", func() { aFnCall =
aFunc1x1.Call1x1(CustomType{val: 5}).(int) }, func() {
GeneratedOptimizationCalls(); aFunc1x1 = reflectx.ToFunc1x1(aFunc) }}, // Used
to call the function repeatedly
- {"NewFn_GeneratedShims", func() { aFn, _ = graph.NewFn(f) },
func() { GeneratedOptimizationCalls() }},
// Used in graph construction (less
valuable)
- {"EncodeMultiEdge_GeneratedShims", func() { aME, err =
graphx.EncodeMultiEdge(&me) }, func() { GeneratedOptimizationCalls() }},
// Used in graph serialization at
execution time
+ {"MakeFunc_GeneratedShims", func() { aFunc =
reflectx.MakeFunc(f.ProcessElement) }, func() { GeneratedOptimizationCalls()
}},
// Used in graph deserialization
+ {"MakeFunc.Call_GeneratedShims", func() { aFnCall =
aFunc.Call(funcIn)[0].(int) }, func() { GeneratedOptimizationCalls() }},
// Used to call the function repeatedly
+ {"MakeFunc.Call1x1_GeneratedShims", func() { aFnCall =
aFunc1x1.Call1x1(CustomType{val: 5}).(int) }, func() {
GeneratedOptimizationCalls(); aFunc1x1 = reflectx.ToFunc1x1(aFunc) }},
// Used to call the function repeatedly
+ {"NewFn_GeneratedShims", func() { aFn, _ = graph.NewFn(f) },
func() { GeneratedOptimizationCalls() }},
// Used in graph construction (less valuable)
+ {"EncodeMultiEdge_GeneratedShims", func() { aME, err =
graphx.EncodeMultiEdge(&me) }, func() { GeneratedOptimizationCalls() }},
// Used in graph serialization at execution time
+ {"MakeFunc_FunctionalDoFn_Unoptimized", func() { aFunc =
reflectx.MakeFunc(addCustomType2) }, func() { GeneratedOptimizationCalls() }},
// Used in graph deserialization
+ {"MakeFunc_FunctionalDoFn.Call_Unoptimized", func() { aFnCall2
= aFunc.Call(funcIn2)[0].(CustomType2) }, func() { GeneratedOptimizationCalls()
}},
// Used to call the function repeatedly
+ {"MakeFunc_FunctionalDoFn.Call1x1_Unoptimized", func() {
aFnCall2 = aFunc2x1.Call2x1(CustomType2{val2: 4}, CustomType2{val2:
3}).(CustomType2) }, func() { GeneratedOptimizationCalls(); aFunc2x1 =
reflectx.ToFunc2x1(aFunc) }}, // Used to call the function repeatedly
Review Comment:
And this should be the "generated" not optimized. (also 2x1)
Issue Time Tracking
-------------------
Worklog Id: (was: 769960)
Time Spent: 22h 10m (was: 22h)
> [Go SDK] Allow users to optimize DoFns with a single generic registration
> function
> ----------------------------------------------------------------------------------
>
> Key: BEAM-14347
> URL: https://issues.apache.org/jira/browse/BEAM-14347
> Project: Beam
> Issue Type: New Feature
> Components: sdk-go
> Reporter: Danny McCormick
> Assignee: Danny McCormick
> Priority: P2
> Time Spent: 22h 10m
> Remaining Estimate: 0h
>
> Right now, to optimize DoFn execution, users have to use the code generator.
> This updates to allow them to use generics instead.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)