Learning the runtime

287 views
Skip to first unread message

buch...@gmail.com

unread,
Mar 4, 2020, 12:15:28 AM3/4/20
to golang-nuts
Is there any way to learn the internals of the runtime package, besides just reading all the code? There are a lot of types in the package with cryptic names and no documentation, so if all I have is the code, it's going to be a steep learning curve.

Ian Lance Taylor

unread,
Mar 4, 2020, 4:23:35 PM3/4/20
to buch...@gmail.com, golang-nuts
On Tue, Mar 3, 2020 at 9:15 PM <buch...@gmail.com> wrote:
>
> Is there any way to learn the internals of the runtime package, besides just reading all the code? There are a lot of types in the package with cryptic names and no documentation, so if all I have is the code, it's going to be a steep learning curve.

Different parts of the runtime have different docs, although I'm not
aware of any place that gathers all those docs in a single place.

What part in particular are you interested in?

Ian

Keith Randall

unread,
Mar 4, 2020, 7:27:01 PM3/4/20
to golang-nuts
There are a bunch of talks from Gophercon and elsewhere that cover pieces of the runtime:

Maps: https://www.youtube.com/watch?v=Tl7mi9QmLns [shameless self plug]
Goroutines, defers, stacks: https://www.youtube.com/watch?v=mYqhBYdqCyg

buch...@gmail.com

unread,
Mar 4, 2020, 8:14:48 PM3/4/20
to golang-nuts
> What part in particular are you interested in?

I ended up in the runtime code because I'm interested in plugins, the linker, loader, and how the runtime manages types. In particular, I'm interested in https://github.com/golang/go/issues/28783. My comment here explains why: https://github.com/golang/go/issues/20461#issuecomment-593731566. So, I suppose I'm interested in how the runtime manages types, and how the garbage collector works.

I've started reading src/plugin, runtime/plugin.go, runtime/symtab.go, and runtime/iface.go. I have a loose understanding of what I see, but the details are still beyond me.

I'm also just interested in the challenge of learning the details of the runtime in general.

> There are a bunch of talks from Gophercon and elsewhere that cover pieces of the runtime:

Thanks! I'll check those out.

buch...@gmail.com

unread,
Mar 4, 2020, 11:26:28 PM3/4/20
to golang-nuts
Turns out, other parts of the runtime have decent docs – mgc.go is very well commented, for example. I may have started my research in the darkest corners (itab, ptab, ftab, oh my).

Ian Lance Taylor

unread,
Mar 5, 2020, 1:51:14 PM3/5/20
to buch...@gmail.com, golang-nuts
On Wed, Mar 4, 2020 at 8:26 PM <buch...@gmail.com> wrote:
>
> Turns out, other parts of the runtime have decent docs – mgc.go is very well commented, for example. I may have started my research in the darkest corners (itab, ptab, ftab, oh my).

Improvements to the comments are always welcome, and the best people
to write those improvements are people just learning the code.

Ian
Reply all
Reply to author
Forward
0 new messages