[ 
https://issues.apache.org/jira/browse/BEAM-4765?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16720682#comment-16720682
 ] 

Robert Burke commented on BEAM-4765:
------------------------------------

[https://github.com/apache/beam/pull/7161] Opted to generate closurized 
wrappers for methods instead of going with explicit receiver passing at the 
call sites. Closing this.

> Use explicit receivers for method invocations. 
> -----------------------------------------------
>
>                 Key: BEAM-4765
>                 URL: https://issues.apache.org/jira/browse/BEAM-4765
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-go
>            Reporter: Robert Burke
>            Assignee: Robert Burke
>            Priority: Major
>             Fix For: Not applicable
>
>
> Presently we use the "receiverless" variant to reflectively  get methods on 
> structs in graph/fn.go, but it's possible to get a version with an explicit 
> receiver as well. Unfortunately due to reflect method invocation overhead, 
> calls to functions sourced this way have significant overhead.
>  
> This task represents a TODO in graph/fn.go
>  
> I wrote a benchmark (to be submitted) that explores the approaches:
> BenchmarkStructMethodCalls/ReflectCallNoReceiver-12         5000000       377 
> ns/op      56 B/op       3 allocs/op
> BenchmarkStructMethodCalls/ReflectCallWithReceiver-12       5000000       297 
> ns/op      48 B/op       2 allocs/op
> BenchmarkStructMethodCalls/DirectWithReceiver-12             300000000        
>  3.58 ns/op       0 B/op       0 allocs/op
> BenchmarkStructMethodCalls/TypeAssertedWithReceiver-12       300000000        
>  3.58 ns/op       0 B/op       0 allocs/op
> BenchmarkStructMethodCalls/ReflectXCallWithReceiver-12       5000000       
> 345 ns/op     112 B/op       5 allocs/op
> BenchmarkStructMethodCalls/ShimedCallWithReceiver-12         20000000        
> 69.3 ns/op      40 B/op       3 allocs/op
> BenchmarkStructMethodCalls/ShimedCall1x1-12                 100000000        
> 20.7 ns/op       8 B/op       1 allocs/op
>  
> Note: Some of these represent the compiler assisting the explicit calls, due 
> to the micro benchmarking: DirectWithReceiver, and TypeAssertedWithReceiver 
> in particular. 
>  
> ShimedCallWithReceiver represents the "typical" invocation path with a 
> reflectx.Func.Call([]interface{})  invocation, while ShimedCall1x1 is the 
> arity specialized version.
> Note: This be a breaking change to anyone using the reflectx & graph packages 
> on structural DoFn outside of the project. However, we don't presently make a 
> stability guarantee on these internal package details, so that's probably OK.
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to