• Keith Randall's avatar
    runtime: faster version of findfunc · 63116de5
    Keith Randall authored
    Use a lookup table to find the function which contains a pc.  It is
    faster than the old binary search.  findfunc is used primarily for
    stack copying and garbage collection.
    
    benchmark              old ns/op     new ns/op     delta
    BenchmarkStackCopy     294746596     255400980     -13.35%
    
    (findfunc is one of several tasks done by stack copy, the findfunc
    time itself is about 2.5x faster.)
    
    The lookup table is built at link time.  The table grows the binary
    size by about 0.5% of the text segment.
    
    We impose a lower limit of 16 bytes on any function, which should not
    have much of an impact.  (The real constraint required is <=256
    functions in every 4096 bytes, but 16 bytes/function is easier to
    implement.)
    
    Change-Id: Ic315b7a2c83e1f7203cd2a50e5d21a822e18fdca
    Reviewed-on: https://go-review.googlesource.com/2097Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
    63116de5
pobj.c 6.91 KB