[go-nuts] Re: I found a very strange code that would cause deadlocks and blocking,why???

2019-03-01 Thread Louki Sumirniy
It clearly shows a 'chan receive' item in that trace, which is from the <-variable part. That is the blocker. STW pauses are rarely more than a few seconds long, and you would have to have allocated massive amounts of memory, then stopped using it, to cause one. Finding good examples of workin

[go-nuts] golang.org/x/text/language does not match sr-Latn (Serbian in a Latin script) with hr (Croatian) as it documents that it should

2019-03-01 Thread iain . duncan5
The article for the golang.org/x/text/language here: https://blog.golang.org/matchlang states that "For a user preference of "hr" (Croatian), the best match is "sr-Latn" (Serbian with Latin script), because, once they are written in the same script, Serbian and Croatian are mutually intelligibl

[go-nuts] cancelCtx: why does not return c.done directly?

2019-03-01 Thread dongshujin . beans
The following code is a snippet of the context pkg. cancelCtx.Done(): func (c *cancelCtx) Done() <-chan struct{} { c.mu.Lock() if c.done == nil { c.done = make(chan struct{}) } d := c.done c.mu.Unlock() return d } why does not return *c.done* directly like this? func (

Re: [go-nuts] cancelCtx: why does not return c.done directly?

2019-03-01 Thread Robert Engels
Because the compiler/processor might reorder things, so the value must be obtained while holding the lock. This is actually a weakness due to the memory model of Go not being fully specified IMO. If that were changed this code could probably be written as you suggest. > On Mar 1, 2019, at 1:

[go-nuts] Re: golang.org/x/text/language does not match sr-Latn (Serbian in a Latin script) with hr (Croatian) as it documents that it should

2019-03-01 Thread iain . duncan5
I did a bit more digging and found this: https://go-review.googlesource.com/c/text/+/55331/ Which states: "language: remove manual hr -> sr mapping was removed in CLDR for geo-political reasons" Which answers why it doesn't work so I think it is just the example that needs removing/updating.

[go-nuts] Re: golang.org/x/text/language does not match sr-Latn (Serbian in a Latin script) with hr (Croatian) as it documents that it should

2019-03-01 Thread iain . duncan5
And mirrored in CLDR: http://cldr.unicode.org/index/downloads/cldr-31 On Friday, 1 March 2019 13:50:44 UTC, Iain Duncan wrote: > > The article for the golang.org/x/text/language here: > > https://blog.golang.org/matchlang > > states that "For a user preference of "hr" (Croatian), the best match i

[go-nuts] cancelCtx: why does not return c.done directly?

2019-03-01 Thread Tamás Gulácsi
You have to hold the lock to read/write c.done. Defer would do, but slow things dow. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googl

[go-nuts] does assembly pay the cgo transition cost / does runtime.LockOSThread() make CGO calls faster?

2019-03-01 Thread Jason E. Aten
If I include a chunk of assembly .s code in my Go code, does my program pay the CGO transition cost of locking and changing to a C stack? I'm pretty sure the answer is no. But my knowledge of the Go internals is low enough that I thought I would like confirm that before I go pulling in .s code.

[go-nuts] Re: does assembly pay the cgo transition cost / does runtime.LockOSThread() make CGO calls faster?

2019-03-01 Thread Tamás Gulácsi
2019. március 1., péntek 17:13:28 UTC+1 időpontban Jason E. Aten a következőt írta: > > If I include a chunk of assembly .s code in my Go code, does my program > pay the CGO transition cost of locking and changing to a C stack? > > I'm pretty sure the answer is no. But my knowledge of the Go inte

Re: [go-nuts] cancelCtx: why does not return c.done directly?

2019-03-01 Thread Marvin Renich
* dongshujin.be...@gmail.com [190301 08:50]: > The following code is a snippet of the context pkg. > cancelCtx.Done(): > > func (c *cancelCtx) Done() <-chan struct{} { >c.mu.Lock() >if c.done == nil { > c.done = make(chan struct{}) >} >d := c.done >c.mu.Unlock() >re

Re: [go-nuts] cancelCtx: why does not return c.done directly?

2019-03-01 Thread Robert Engels
I am pretty sure it is the memory model unless there is other code in the stdlib that sets the dove back to nil - which wouldn’t make sense since the channel should be unique to the context instance and that would allow multiple done channels to be created. > On Mar 1, 2019, at 1:35 PM, Marvin

Re: [go-nuts] cancelCtx: why does not return c.done directly?

2019-03-01 Thread Marvin Renich
* Robert Engels [190301 15:07]: > I am pretty sure it is the memory model unless there is other code in > the stdlib that sets the dove back to nil - which wouldn’t make sense > since the channel should be unique to the context instance and that > would allow multiple done channels to be created.

Re: [go-nuts] does assembly pay the cgo transition cost / does runtime.LockOSThread() make CGO calls faster?

2019-03-01 Thread Ian Lance Taylor
On Fri, Mar 1, 2019 at 8:13 AM Jason E. Aten wrote: > > If I include a chunk of assembly .s code in my Go code, does my program pay > the CGO transition cost of locking and changing to a C stack? No. The assembly function is simply called just as a Go function is called. > I'm pretty sure the

Re: [go-nuts] does assembly pay the cgo transition cost / does runtime.LockOSThread() make CGO calls faster?

2019-03-01 Thread Jason E. Aten
Thank you Ian! This is so helpful. On Friday, March 1, 2019 at 4:13:49 PM UTC-6, Ian Lance Taylor wrote: > > Go assembly code is compiled by the Go assembler, cmd/asm. The author > of the assembly code is required to specify how much stack space the > assembly function requires, in the TEXT ps

Re: [go-nuts] cancelCtx: why does not return c.done directly?

2019-03-01 Thread Robert Engels
I didn’t mean the current code was incorrect, I meant the reason it isn’t done as the op proposes is because of weakness in the memory model - since the store of the done might not be visible to a read not done under lock, otherwise the ops proposed code would work and there would be no reason f

Re: [go-nuts] does assembly pay the cgo transition cost / does runtime.LockOSThread() make CGO calls faster?

2019-03-01 Thread Ian Lance Taylor
On Fri, Mar 1, 2019 at 2:37 PM Jason E. Aten wrote: > > On Friday, March 1, 2019 at 4:13:49 PM UTC-6, Ian Lance Taylor wrote: >> >> Go assembly code is compiled by the Go assembler, cmd/asm. The author >> of the assembly code is required to specify how much stack space the >> assembly function re

Re: [go-nuts] does assembly pay the cgo transition cost / does runtime.LockOSThread() make CGO calls faster?

2019-03-01 Thread Andrei Tudor Călin
Perhaps https://github.com/minio/c2goasm might be of interest. I don't see anything in there about Fortran specifically, but I don't think it would be a huge leap. On Fri, Mar 1, 2019 at 5:13 PM Jason E. Aten wrote: > If I include a chunk of assembly .s code in my Go code, does my program > pay

Re: [go-nuts] does assembly pay the cgo transition cost / does runtime.LockOSThread() make CGO calls faster?

2019-03-01 Thread Jason E. Aten
On Friday, March 1, 2019 at 5:14:08 PM UTC-6, Andrei Tudor Călin wrote: > > Perhaps https://github.com/minio/c2goasm might be of interest. > > I don't see anything in there about Fortran specifically, but I don't > think it would be a huge leap. > Nice! Thank you, Andrei. That looks very helpful.

Re: [go-nuts] does assembly pay the cgo transition cost / does runtime.LockOSThread() make CGO calls faster?

2019-03-01 Thread Jason E. Aten
On Friday, March 1, 2019 at 5:16:35 PM UTC-6, Jason E. Aten wrote: > > On Friday, March 1, 2019 at 5:14:08 PM UTC-6, Andrei Tudor Călin wrote: >> >> Perhaps https://github.com/minio/c2goasm might be of interest. >> >> I don't see anything in there about Fortran specifically, but I don't >> think

Re: [go-nuts] does assembly pay the cgo transition cost / does runtime.LockOSThread() make CGO calls faster?

2019-03-01 Thread Dan Kortschak
Assembly incurs a function call cost (non-inlineable AFAIU), but Cgo incurs a function call cost with additional work for C stack and call conventions translation as said by Tamás. On Fri, 2019-03-01 at 08:13 -0800, Jason E. Aten wrote: > If I include a chunk of assembly .s code in my Go code,

Re: [go-nuts] Re: golang.org/x/text/language does not match sr-Latn (Serbian in a Latin script) with hr (Croatian) as it documents that it should

2019-03-01 Thread Nigel Tao
CC'ing mpvl@, the blog post author. On Sat, Mar 2, 2019 at 1:16 AM wrote: > > I did a bit more digging and found this: > > https://go-review.googlesource.com/c/text/+/55331/ > > Which states: > > "language: remove manual hr -> sr mapping was removed in CLDR for > geo-political reasons" > > Whic

[go-nuts] How to properly release a new project as a V2 module

2019-03-01 Thread marcinr
Hi All, I've open sourced some work that I've done to generate Go server stubs from OpenAPI 3.0 specifications, found here: https://github.com/deepmap/oapi-codegen However, I can't figure out why I can't import my code as a V2 module. The release is tagged with v2.0.0, my go.mod file specifies

Re: [go-nuts] does assembly pay the cgo transition cost / does runtime.LockOSThread() make CGO calls faster?

2019-03-01 Thread Jason E. Aten
On Friday, March 1, 2019 at 6:46:11 PM UTC-6, kortschak wrote: > > Assembly incurs a function call cost (non-inlineable AFAIU), but Cgo > incurs a function call cost with additional work for C stack and call > conventions translation as said by Tamás. > Thanks @kortschak. The c2goasm project (

Re: [go-nuts] does assembly pay the cgo transition cost / does runtime.LockOSThread() make CGO calls faster?

2019-03-01 Thread Dan Kortschak
Yes, that's not unreasonable. With f2c, you could potentially get your fortran into C, then Go asm and then call that. Dan On Fri, 2019-03-01 at 20:17 -0800, Jason E. Aten wrote: > On Friday, March 1, 2019 at 6:46:11 PM UTC-6, kortschak wrote: > > > > > > Assembly incurs a function call cost (n