Saturday, March 27, 2021

Re: Go programs only using one CPU core

On Sat, Mar 27, 2021 at 06:44:52PM +1100, john slee wrote:

> Hi,
>
> > On 2021-03-26, Richard Ulmer <maillists.rulmer@mailbox.org> wrote:
> > > The `go` directive starts a new goroutine, which I would expect to be
> > > put into it's own process here. However, using htop(1) I can see, that
> > > only one of my two cores gets load. Running the same program on Linux,
> > > two cores are utilized.
>
> That's not how the Go runtime works, I think?
>
> You shouldn't expect to see a 1:1 mapping of goroutines:OS processes.
>
> Quoting Russ Cox on the golang-nuts list:
>
> "This is a popular split but hardly the only definition
> of those terms. One reason we use the name goroutine
> is to avoid preconceptions about what those terms mean.
> For many people threads also connotes management by
> the operating system, while goroutines are managed first
> by the Go runtime"
>
> More here:
>
> https://medium.com/the-polyglot-programmer/what-are-goroutines-and-how-do-they-actually-work-f2a734f6f991
>
> Are you actually seeing a problem (an actual problem, not "I can only see
> one line for my app in "top") specific to OpenBSD?
>
> John

The actual problem is that htop is buggy on OpenBSD. It is much better
to use the native tools, they are more activly maintained.

-Otto

No comments:

Post a Comment