[ 
https://issues.apache.org/jira/browse/BEAM-4852?focusedWorklogId=129536&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-129536
 ]

ASF GitHub Bot logged work on BEAM-4852:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 31/Jul/18 23:40
            Start Date: 31/Jul/18 23:40
    Worklog Time Spent: 10m 
      Work Description: herohde closed pull request #6052: [BEAM-4852] Only 
read symbol table when required.
URL: https://github.com/apache/beam/pull/6052
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/sdks/go/pkg/beam/core/runtime/symbols.go 
b/sdks/go/pkg/beam/core/runtime/symbols.go
index 238823696a8..c4f68163393 100644
--- a/sdks/go/pkg/beam/core/runtime/symbols.go
+++ b/sdks/go/pkg/beam/core/runtime/symbols.go
@@ -26,23 +26,41 @@ import (
 )
 
 var (
+       // Resolver is the accessible symbol resolver the runtime uses to find 
functions.
        Resolver SymbolResolver
        cache    = make(map[string]interface{})
        mu       sync.Mutex
 )
 
 func init() {
+       // defer initialization of the default resolver. This way
+       // the symbol table isn't read in unless strictly necessary.
+       Resolver = &deferedResolver{initFn: initResolver}
+}
+
+type deferedResolver struct {
+       initFn func() SymbolResolver
+       r      SymbolResolver
+       init   sync.Once
+}
+
+func (d *deferedResolver) Sym2Addr(name string) (uintptr, error) {
+       d.init.Do(func() {
+               d.r = d.initFn()
+       })
+       return d.r.Sym2Addr(name)
+}
+
+func initResolver() SymbolResolver {
        // First try the Linux location, since it's the most reliable.
        if r, err := symtab.New("/proc/self/exe"); err == nil {
-               Resolver = r
-               return
+               return r
        }
        // For other OS's this works in most cases we need.
        if r, err := symtab.New(os.Args[0]); err == nil {
-               Resolver = r
-               return
+               return r
        }
-       Resolver = failResolver(false)
+       return failResolver(false)
 }
 
 // SymbolResolver resolves a symbol to an unsafe address.


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 129536)
    Time Spent: 1h 20m  (was: 1h 10m)

> [Go SDK] Beam should not retain the symbol table after function resolution
> --------------------------------------------------------------------------
>
>                 Key: BEAM-4852
>                 URL: https://issues.apache.org/jira/browse/BEAM-4852
>             Project: Beam
>          Issue Type: Improvement
>          Components: sdk-go
>            Reporter: Robert Burke
>            Assignee: Robert Burke
>            Priority: Major
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> In some instances, Beam Go requires introspecting the symbol table for the 
> binary to resolve functions. However it may be possible to cache these 
> results for all applicable functions, and then allow the table to be garbage 
> collected.
> The table represents a large heap cost that is retained for the lifetime of a 
> job.
> A secondary goal would be to avoid incurring the cost entirely when there's 
> nothing to look up for a job. Eg for unit tests, or ancillary uses of the 
> beam SDK (eg. migrating from some other system to beam shouldn't incur the 
> cost when the old system is being used, just because beam is linked in and 
> triggered by a runtime switch).



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

Reply via email to