英文:
Increasing StackMin for Go 1.2
问题
基本上,我遇到了与这里描述的问题相同的问题:
https://groups.google.com/forum/#!topic/golang-nuts/TYai0DVoYwg
有没有一种方法可以在不重新编译Go的情况下增加我的Go程序的StackMin?
英文:
Basically I have the same problem with Go 1.2 as described here:
https://groups.google.com/forum/#!topic/golang-nuts/TYai0DVoYwg
Is there a way of increasing StackMin for my Go program without recompiling Go?
答案1
得分: 5
StackMin是编译进运行时的,所以你无法在不重新编译Go的情况下更改它。你可以在这里找到常量:http://golang.org/src/pkg/runtime/stack.h#L72
如果你无法重新编译Go,你可以尝试通过人为增加程序使用的堆栈空间的方法来解决热分裂问题(即在热分裂函数调用之前在你的代码中插入var foo [2<<10]byte
)- 但这可能是试错的,可能需要根据你的程序的变化进行重新调整。
正如Dmitry提到的,Go 1.3计划使用连续的堆栈(而不是堆栈段的链表),在需要时进行重新分配和复制。https://docs.google.com/document/d/1wAaf1rYoM4S4gtnPh0zOlGzWtrZFQ5suE8qr2sD8uWQ/pub
英文:
StackMin is compiled into the runtime, so you can't change it without recompiling Go. You can find the constants here: http://golang.org/src/pkg/runtime/stack.h#L72
If you're unable to recompile Go, you can try to work around the hot split problem by artificially increasing the amount of stack space used by your program (i.e. insert var foo [2<<10]byte
into your code before the hot-split function calls) - but this could be hit-or-miss, and may need to be re-tuned as your program changes.
As Dmitry mentioned, Go 1.3 is planned to have contiguous stacks (not a linked list of stack segments) which get reallocated and copied to as needed. https://docs.google.com/document/d/1wAaf1rYoM4S4gtnPh0zOlGzWtrZFQ5suE8qr2sD8uWQ/pub
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论