-
Notifications
You must be signed in to change notification settings - Fork 17.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/link: restore windows stack commit size back to 4KB
CL 49331 increased windows stack commit size to 2MB by mistake. Revert that change. Fixes #22439 Change-Id: I919e549e87da326f4ba45890b4d32f6d7046186f Reviewed-on: https://go-review.googlesource.com/74490 TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Austin Clements <[email protected]>
- Loading branch information
1 parent
25159d3
commit 923299a
Showing
8 changed files
with
164 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 2017 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package windows | ||
|
||
type PROCESS_MEMORY_COUNTERS struct { | ||
CB uint32 | ||
PageFaultCount uint32 | ||
PeakWorkingSetSize uintptr | ||
WorkingSetSize uintptr | ||
QuotaPeakPagedPoolUsage uintptr | ||
QuotaPagedPoolUsage uintptr | ||
QuotaPeakNonPagedPoolUsage uintptr | ||
QuotaNonPagedPoolUsage uintptr | ||
PagefileUsage uintptr | ||
PeakPagefileUsage uintptr | ||
} | ||
|
||
//sys GetProcessMemoryInfo(handle syscall.Handle, memCounters *PROCESS_MEMORY_COUNTERS, cb uint32) (err error) = psapi.GetProcessMemoryInfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2015 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package main | ||
|
||
import "C" | ||
import ( | ||
"internal/syscall/windows" | ||
"runtime" | ||
"sync" | ||
"syscall" | ||
"unsafe" | ||
) | ||
|
||
func init() { | ||
register("StackMemory", StackMemory) | ||
} | ||
|
||
func getPagefileUsage() (uintptr, error) { | ||
p, err := syscall.GetCurrentProcess() | ||
if err != nil { | ||
return 0, err | ||
} | ||
var m windows.PROCESS_MEMORY_COUNTERS | ||
err = windows.GetProcessMemoryInfo(p, &m, uint32(unsafe.Sizeof(m))) | ||
if err != nil { | ||
return 0, err | ||
} | ||
return m.PagefileUsage, nil | ||
} | ||
|
||
func StackMemory() { | ||
mem1, err := getPagefileUsage() | ||
if err != nil { | ||
panic(err) | ||
} | ||
const threadCount = 100 | ||
var wg sync.WaitGroup | ||
for i := 0; i < threadCount; i++ { | ||
wg.Add(1) | ||
go func() { | ||
runtime.LockOSThread() | ||
wg.Done() | ||
select {} | ||
}() | ||
} | ||
wg.Wait() | ||
mem2, err := getPagefileUsage() | ||
if err != nil { | ||
panic(err) | ||
} | ||
print((mem2 - mem1) / threadCount) | ||
} |