]> Cypherpunks repositories - gostls13.git/commitdiff
undo CL 45770044 / d795425bfa18
authorDmitriy Vyukov <dvyukov@google.com>
Thu, 23 Jan 2014 15:56:59 +0000 (19:56 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Thu, 23 Jan 2014 15:56:59 +0000 (19:56 +0400)
Breaks darwin and freebsd.

««« original CL description
runtime: increase page size to 8K
Tcmalloc uses 8K, 32K and 64K pages, and in custom setups 256K pages.
Only Chromium uses 4K pages today (in "slow but small" configuration).
The general tendency is to increase page size, because it reduces
metadata size and DTLB pressure.
This change reduces GC pause by ~10% and slightly improves other metrics.

json-1
allocated                 8037492      8038689      +0.01%
allocs                     105762       105573      -0.18%
cputime                 158400000    155800000      -1.64%
gc-pause-one              4412234      4135702      -6.27%
gc-pause-total            2647340      2398707      -9.39%
rss                      54923264     54525952      -0.72%
sys-gc                    3952624      3928048      -0.62%
sys-heap                 46399488     46006272      -0.85%
sys-other                 5597504      5290304      -5.49%
sys-stack                  393216       393216      +0.00%
sys-total                56342832     55617840      -1.29%
time                    158478890    156046916      -1.53%
virtual-mem             256548864    256593920      +0.02%

garbage-1
allocated                 2991113      2986259      -0.16%
allocs                      62844        62652      -0.31%
cputime                  16330000     15860000      -2.88%
gc-pause-one            789108229    725555211      -8.05%
gc-pause-total            3945541      3627776      -8.05%
rss                    1143660544   1132253184      -1.00%
sys-gc                   65609600     65806208      +0.30%
sys-heap               1032388608   1035599872      +0.31%
sys-other                37501632     22777664     -39.26%
sys-stack                 8650752      8781824      +1.52%
sys-total              1144150592   1132965568      -0.98%
time                     16364602     15891994      -2.89%
virtual-mem            1327296512   1313746944      -1.02%

R=golang-codereviews, dave, khr, rsc, khr
CC=golang-codereviews
https://golang.org/cl/45770044
»»»

R=golang-codereviews
CC=golang-codereviews
https://golang.org/cl/56060043

src/pkg/runtime/malloc.goc
src/pkg/runtime/malloc.h
src/pkg/runtime/mem.go
src/pkg/runtime/mgc0.c
src/pkg/runtime/netpoll.goc

index 9e4acc206e470609185b77ea40f8b15174d9810f..739c61e4f49b93e9cbf57d26e9e774cbdb2d085d 100644 (file)
@@ -19,7 +19,6 @@ package runtime
 // Mark mheap as 'no pointers', it does not contain interesting pointers but occupies ~45K.
 #pragma dataflag NOPTR
 MHeap runtime·mheap;
-MStats mstats;
 
 int32  runtime·checking;
 
@@ -321,10 +320,7 @@ runtime·purgecachedstats(MCache *c)
        }
 }
 
-// Size of the trailing by_size array differs between Go and C,
-// NumSizeClasses was changed, but we can not change Go struct because of backward compatibility.
-// sizeof_C_MStats is what C thinks about size of Go struct.
-uintptr runtime·sizeof_C_MStats = sizeof(MStats) - (NumSizeClasses - 61) * sizeof(mstats.by_size[0]);
+uintptr runtime·sizeof_C_MStats = sizeof(MStats);
 
 #define MaxArena32 (2U<<30)
 
index e07cebc0a0a5993978c0edce085a6595fd99f422..9f34b55461d69b86fd17681a37bce5d8aad46081 100644 (file)
@@ -90,7 +90,7 @@ typedef struct GCStats        GCStats;
 
 enum
 {
-       PageShift       = 13,
+       PageShift       = 12,
        PageSize        = 1<<PageShift,
        PageMask        = PageSize - 1,
 };
@@ -103,7 +103,7 @@ enum
        // size classes.  NumSizeClasses is that number.  It's needed here
        // because there are static arrays of this length; when msize runs its
        // size choosing algorithm it double-checks that NumSizeClasses agrees.
-       NumSizeClasses = 67,
+       NumSizeClasses = 61,
 
        // Tunable constants.
        MaxSmallSize = 32<<10,
@@ -255,7 +255,7 @@ struct MStats
        } by_size[NumSizeClasses];
 };
 
-#define mstats runtime·memStats
+#define mstats runtime·memStats       /* name shared with Go */
 extern MStats mstats;
 
 // Size classes.  Computed and initialized by InitSizes.
index fa308b5d963916825b75659f8e4364a26814c9de..dc735e4a629ad5c5badd0b88672e79e37d18942c 100644 (file)
@@ -60,8 +60,9 @@ type MemStats struct {
 
 var sizeof_C_MStats uintptr // filled in by malloc.goc
 
+var memStats MemStats
+
 func init() {
-       var memStats MemStats
        if sizeof_C_MStats != unsafe.Sizeof(memStats) {
                println(sizeof_C_MStats, unsafe.Sizeof(memStats))
                panic("MStats vs MemStatsType size mismatch")
index caab7b9ee6485f8a7e52e7f22bbaaf859ef8f916..2c82fb3ac437e143002bf32e34138ceab77b0ff8 100644 (file)
@@ -25,10 +25,6 @@ enum {
        wordsPerBitmapWord = sizeof(void*)*8/4,
        bitShift = sizeof(void*)*8/4,
 
-       WorkbufSize     = 16*1024,
-       RootBlockSize   = 4*1024,
-       FinBlockSize    = 4*1024,
-
        handoffThreshold = 4,
        IntermediateBufferCapacity = 64,
 
@@ -147,10 +143,11 @@ struct Obj
        uintptr ti;     // type info
 };
 
+// The size of Workbuf is N*PageSize.
 typedef struct Workbuf Workbuf;
 struct Workbuf
 {
-#define SIZE (WorkbufSize-sizeof(LFNode)-sizeof(uintptr))
+#define SIZE (2*PageSize-sizeof(LFNode)-sizeof(uintptr))
        LFNode  node; // must be first
        uintptr nobj;
        Obj     obj[SIZE/sizeof(Obj) - 1];
@@ -729,7 +726,7 @@ scanblock(Workbuf *wbuf, bool keepworking)
        ChanType *chantype;
        Obj *wp;
 
-       if(sizeof(Workbuf) % WorkbufSize != 0)
+       if(sizeof(Workbuf) % PageSize != 0)
                runtime·throw("scanblock: size of Workbuf is suboptimal");
 
        // Memory arena parameters.
@@ -1590,8 +1587,8 @@ runtime·queuefinalizer(byte *p, FuncVal *fn, uintptr nret, Type *fint, PtrType
        runtime·lock(&finlock);
        if(finq == nil || finq->cnt == finq->cap) {
                if(finc == nil) {
-                       finc = runtime·persistentalloc(FinBlockSize, 0, &mstats.gc_sys);
-                       finc->cap = (FinBlockSize - sizeof(FinBlock)) / sizeof(Finalizer) + 1;
+                       finc = runtime·persistentalloc(PageSize, 0, &mstats.gc_sys);
+                       finc->cap = (PageSize - sizeof(FinBlock)) / sizeof(Finalizer) + 1;
                        finc->alllink = allfin;
                        allfin = finc;
                }
@@ -2218,8 +2215,6 @@ gc(struct gc_args *args)
        runtime·MProf_GC();
 }
 
-extern uintptr runtime·sizeof_C_MStats;
-
 void
 runtime·ReadMemStats(MStats *stats)
 {
@@ -2231,9 +2226,7 @@ runtime·ReadMemStats(MStats *stats)
        m->gcing = 1;
        runtime·stoptheworld();
        updatememstats(nil);
-       // Size of the trailing by_size array differs between Go and C,
-       // NumSizeClasses was changed, but we can not change Go struct because of backward compatibility.
-       runtime·memcopy(runtime·sizeof_C_MStats, stats, &mstats);
+       *stats = mstats;
        m->gcing = 0;
        m->locks++;
        runtime·semrelease(&runtime·worldsema);
index 81471dca5bb55f07c372701095490772c4908edd..2830f882d806123a431813444ef213bf4ee3b45a 100644 (file)
@@ -34,11 +34,6 @@ package net
 #define READY ((G*)1)
 #define WAIT  ((G*)2)
 
-enum
-{
-       PollBlockSize   = 4*1024,
-};
-
 struct PollDesc
 {
        PollDesc* link; // in pollcache, protected by pollcache.Lock
@@ -427,7 +422,7 @@ allocPollDesc(void)
 
        runtime·lock(&pollcache);
        if(pollcache.first == nil) {
-               n = PollBlockSize/sizeof(*pd);
+               n = PageSize/sizeof(*pd);
                if(n == 0)
                        n = 1;
                // Must be in non-GC memory because can be referenced