[go-nuts] Long time blocking CGO call affect and CGO/Go.syscall/Go.net/C IO performance

2018-09-17 Thread changkun
Hi there, I recently managed a data parsing C library in a CGO program by for long time network IO. The data flow is as follows: user socket <> socketpair[0] <---> socketpair[1] <> data store |--Go domain|--C domain-| With such a data f

Re: [go-nuts] Long time blocking CGO call affect and CGO/Go.syscall/Go.net/C IO performance

2018-09-17 Thread changkun
Hi Robert, I checked your benchmark, and it kindly solves the second question "there is no way to optimize". Thank you :) Best, changkun On Monday, September 17, 2018 at 6:19:33 PM UTC+2, Robert Engels wrote: > > You can run my tests at github.com/robaho/go-network-test You

Re: [go-nuts] Long time blocking CGO call affect and CGO/Go.syscall/Go.net/C IO performance

2018-09-17 Thread changkun
Is the benchmark measured in a wrong way? Are all I/Os call via net package suffering it? Best, changkun On Monday, September 17, 2018 at 8:51:06 PM UTC+2, Ian Lance Taylor wrote: > > On Mon, Sep 17, 2018 at 1:41 AM, changkun > wrote: > > > > Thus, my first question is: C

Re: [go-nuts] Long time blocking CGO call affect and CGO/Go.syscall/Go.net/C IO performance

2018-09-17 Thread changkun
Your answers are very decent, it solve all my doubts. Thank you very much! I believe I need to spend some time reading how runtime scheduler works for more deep understanding of all "magic". Cheers, changkun On Monday, September 17, 2018 at 9:25:20 PM UTC+2, Ian Lance Taylor wrote:

[go-nuts] Debug Go program with GDB on macOS shows nothing

2018-09-27 Thread changkun
port. (gdb) info files Symbols from "/Users/changkun/Desktop/demo/main". Local exec file: `/Users/changkun/Desktop/demo/main', file type mach-o-x86-64. Entry point: 0x1049e20 0x01001000 - 0x0104dfcf is .text 0x00

[go-nuts] Re: Debug Go program with GDB on macOS shows nothing

2018-09-27 Thread changkun
> have adequate debugging information; it's not perfect, but we are hoping to > get it good enough that core dumps and probes from/on running applications > will yield useful information. > > Sorry for the inconvenience. > > > On Thursday, September 27, 2018 at 9:38:

[go-nuts] Are C allocated memory completely isolated to Go memory in any cases?

2018-09-28 Thread changkun
ories allocated in a cgo call always stands in the same sharing heap even threading? 5. Any other theories and how cloud possibly solve the problem? 6. If I am asking a wrong question, could you shoot any ideas of solving the issue described above? Thank you very much in advance. Best, chan

Re: [go-nuts] Are C allocated memory completely isolated to Go memory in any cases?

2018-09-28 Thread changkun
On Friday, September 28, 2018 at 4:12:31 PM UTC+2, Ian Lance Taylor wrote: > > On Fri, Sep 28, 2018 at 7:08 AM, changkun > wrote: > > > > 1. Is my suspicion reasonable and correct? > > I wouldn't be my first guess. You say that pango memory is > per-thre

Re: [go-nuts] Are C allocated memory completely isolated to Go memory in any cases?

2018-09-28 Thread changkun
On Friday, September 28, 2018 at 6:44:10 PM UTC+2, Ian Lance Taylor wrote: > > On Fri, Sep 28, 2018 at 7:45 AM, changkun > wrote: > > > > On Friday, September 28, 2018 at 4:12:31 PM UTC+2, Ian Lance Taylor > wrote: > >> > >> On Fri

Re: [go-nuts] Are C allocated memory completely isolated to Go memory in any cases?

2018-09-29 Thread changkun
As discussed before, the every pango call is called in a non-Go newly created thread by C. runtime.LockOSThread doesn't work. On Saturday, September 29, 2018 at 1:24:21 PM UTC+2, Tamás Gulácsi wrote: > > You should LockOSThread and process every pango-facing call in that > goroutine. -- You r

Re: [go-nuts] Are C allocated memory completely isolated to Go memory in any cases?

2018-09-29 Thread changkun
On Saturday, September 29, 2018 at 2:08:03 PM UTC+2, Tamás Gulácsi wrote: > > Yes, but is that a one and only goroutine? No. The cgo call is opened for every new incoming user request. Let's summarize: - Every network request creates a goroutine without response processing result to a user

Re: [go-nuts] Are C allocated memory completely isolated to Go memory in any cases?

2018-09-29 Thread changkun
On Saturday, September 29, 2018 at 3:46:41 PM UTC+2, Robert Engels wrote: > > Your description makes no sense. Why are you creating another C thread, > you should just lock the OS thread the Go routine is on. Otherwise if you > create another C thread, in the cgo call you need to block that thr

Re: [go-nuts] Are C allocated memory completely isolated to Go memory in any cases?

2018-09-29 Thread changkun
On Saturday, September 29, 2018 at 4:03:42 PM UTC+2, Tamás Gulácsi wrote: > > Create One (1) goroutine with LockOSThread and let it get the todo and > response channel from a channel and send the response back when ready, and > make all other goroutines communicate with this one and only one >

[go-nuts] When will mexit be executed?

2018-10-13 Thread changkun
Hi golang nuts: In "mstart", there is a call "mexit" after "mstart1". Howeverm "mstart1" will be entering sched loop and never returns. So, my question is when will "mexit" be executed? How? mstart1() // Exit this thread. if GOOS == "windows" || GOOS == "solaris" || GOOS == "plan9" || GOOS ==

Re: [go-nuts] Are C allocated memory completely isolated to Go memory in any cases?

2018-10-13 Thread changkun
Hi, sorry for late response. Your solution is very inspiration! I solved the problem with letting pango call entering go domain and lock on os thread, then back to c domain. Thank you very much! cheers, changkun On Saturday, September 29, 2018 at 6:16:10 PM UTC+2, Tamás Gulácsi wrote

Re: [go-nuts] Are C allocated memory completely isolated to Go memory in any cases?

2018-10-13 Thread changkun
Hi, Thanks for your recommendations, very interesting implementation :) I solved the problem with a callback from c to go to c. cheers, changkun On Saturday, September 29, 2018 at 6:27:08 PM UTC+2, ohir wrote: > > On Fri, 28 Sep 2018 22:27:04 -0700 (PDT) > changkun > wrote: >

[go-nuts] Re: Are C allocated memory completely isolated to Go memory in any cases?

2018-10-13 Thread changkun
Thank you, I probably will use them in the future of more migrations~ cheers, changkun On Sunday, September 30, 2018 at 12:06:09 AM UTC+2, K Davidson wrote: > > Not sure if it would be of any help, but maybe you can gleem some insight > from the way these packages did things?

[go-nuts] Re: When will mexit be executed?

2018-10-13 Thread changkun
Just ignore this thread. I've figured it out. On Saturday, October 13, 2018 at 12:38:53 PM UTC+2, changkun wrote: > > Hi golang nuts: > > In "mstart", there is a call "mexit" after "mstart1". > Howeverm "mstart1" will be entering sc

[go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-19 Thread changkun
I am comparing the performance regarding sync.Mutex and Go channels. Here is my benchmark: https://play.golang.org/p/zLjVtsSx9gd The performance comparison visualization is as follows: [image: sync.Mutex performance (1).png] What are the reasons that 1. sync.Mutex encounter a large performance

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-19 Thread changkun
wrote: > > On Mon, Aug 19, 2019 at 10:50 AM changkun > wrote: > > > > I am comparing the performance regarding sync.Mutex and Go channels. > Here is my benchmark: https://play.golang.org/p/zLjVtsSx9gd > > Might be interesting to try running your benchmark

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-20 Thread changkun
erformance drop appears. Is it possible to determine when the performance will appear? Best, Changkun On Monday, August 19, 2019 at 10:27:19 PM UTC+2, Robert Engels wrote: > > I think you'll find the reason that the Mutex uses the Go scheduler. The > chan is controlled by a 'm

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-20 Thread changkun
fair in that case. Best, Changkun On Tuesday, August 20, 2019 at 10:55:13 AM UTC+2, Ian Davis wrote: > > > On Tue, 20 Aug 2019, at 9:33 AM, changkun wrote: > > Hi Robert, > > Thanks for your explanation. But how could I "logged the number of > operations done per G

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-21 Thread changkun
ot as trivial so the overhead of the locking/scheduler constructs have > far less effect (or the worker is causing L1 evictions anyway - so you > never see the optimum performance possible of the scheduler). > > -Original Message- > From: changkun > Sent: Aug 20, 2019 3:33 AM

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-26 Thread changkun
0.10s 1.83% 82.82% 0.11s 2.01% sync.runtime_nanotime 0.09s 1.65% 84.46% 3.64s 66.54% _/home/changkun/dev/tests_test.BenchmarkMutexWrite.func1.1 0.09s 1.65% 86.11% 0.09s 1.65% runtime.casgstatus 0.08s 1.46% 87.57% 0.08s 1.46% runtime.(*semaRoot).d

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-26 Thread changkun
And it looks like the `semacquire1` executed too many `gopark`, which means indicating that `cansemacquire` failed a lot when too much contention happens. On Monday, August 26, 2019 at 6:27:14 PM UTC+2, changkun wrote: > > Sorry for late response. Do you mean the total execution was n

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-26 Thread changkun
al to each other, but they both three times slower than 2400. goos: linux goarch: amd64 BenchmarkMutexWrite/goroutines-2400-8 5000 46.5 ns/op PASS ok _/home/changkun/dev/tests 2.508s goos: linux goarch: amd64 BenchmarkMutexWrite/goroutines-3

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-26 Thread changkun
slower than 3600 - so it is > increasing linearly with the number of Go routines. > > > -----Original Message- > From: changkun > Sent: Aug 26, 2019 11:49 AM > To: golang-nuts > Subject: Re: [go-nuts] sync.Mutex encounter large performance drop when > goroutine

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-26 Thread changkun
x27; and monitor the cpu cache hit/miss > ratio. > > -Original Message- > From: changkun > Sent: Aug 26, 2019 2:23 PM > To: golang-nuts > Subject: Re: [go-nuts] sync.Mutex encounter large performance drop when > goroutine contention more than 3400 > > Your

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-26 Thread changkun
then `cansemacquire` success again. The drop happens in the case that goroutines are failed for fast path and middle path, and therefore needs to be parked, which involves runtime schedule costs. How do you refute to this argument? On Monday, August 26, 2019 at 10:56:21 PM UTC+2, changkun wrote

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-26 Thread changkun
of > workloads. > > Still, you keep ignoring this aspect - in the context of actual workloads > the difference is negligible. > > -Original Message- > From: changkun > Sent: Aug 26, 2019 4:08 PM > To: golang-nuts > Subject: Re: [go-nuts] sync.Mutex enco

[go-nuts] How to do a forward compatibility support for go 1.13?

2019-09-06 Thread changkun
I have upgraded my code to Go 1.13 with newly introduced errors APIs. However, I am not able to upgrade the production environment Go version which is Go 1.11, which means I have to run Go 1.13 code on a Go 1.11 environment. What are the way to make my builds both happy on local and production

[go-nuts] What is the memory order when select on multiple channels that one is closing and the other is receiving?

2019-09-08 Thread changkun
Hi, golang nuts, Let's think about this snippet: https://play.golang.org/p/3cNGho3gWTG In the code snippet, a ticker is activating and another that that is closing, it seems that they can happen concurrently and result in two different outcomes: either ticker case being executed first or the o

Re: [go-nuts] What is the memory order when select on multiple channels that one is closing and the other is receiving?

2019-09-08 Thread changkun
PM UTC+2, robert engels wrote: > > You need to code it knowing that either can occur in any order. > > On Sep 8, 2019, at 10:14 AM, changkun > > wrote: > > Hi, golang nuts, > > Let's think about this snippet: https://play.golang.org/p/3cNGho3gWTG > > In the

Re: [go-nuts] What is the memory order when select on multiple channels that one is closing and the other is receiving?

2019-09-08 Thread changkun
8, 2019 at 8:40 AM changkun > > wrote: > >> The provided code snipped on my machine can result in different outputs, >> which basically shows that it could occur in any order. >> > > Yes > > >> The randomization mechanism in select statement made

Re: [go-nuts] What is the memory order when select on multiple channels that one is closing and the other is receiving?

2019-09-09 Thread changkun
Hi Alex, Thank you for giving such great clarification. You thought is more sophisticated than me. First: The close *does* happen-before the case clause of the select for the > closed channel, as per the memory model. > Indeed, no question here. > Second: If you actually establish an orde

Re: [go-nuts] What is the memory order when select on multiple channels that one is closing and the other is receiving?

2019-09-09 Thread changkun
Sincerely sorry for the typo of your name :( Axel -- 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...@googlegroups.com. To view this discussio

[go-nuts] Why runtime.sigtrampgo calls runtime.morestack?

2019-12-08 Thread changkun
As we all know that a program is interrupted by a signal and entering kernel space then switch to a userspace signal handler. After the signal handler is accomplished, it will be reentering the kernel space then switch back to where was interrupted. I am recently reading the newly implemented a

Re: [go-nuts] Why runtime.sigtrampgo calls runtime.morestack?

2019-12-08 Thread changkun
n Sunday, December 8, 2019 at 7:37:12 PM UTC+1, Ian Lance Taylor wrote: > > On Sun, Dec 8, 2019 at 7:02 AM changkun > > wrote: > > > > As we all know that a program is interrupted by a signal and entering > kernel space then switch to a userspace signal handler. Aft

Re: [go-nuts] Why runtime.sigtrampgo calls runtime.morestack?

2019-12-08 Thread changkun
msg1))) } //go:nosplit func printmsg2() { write(2, unsafe.Pointer(&msg2[0]), int32(len(msg2))) } On Monday, December 9, 2019 at 12:42:42 AM UTC+1, Ian Lance Taylor wrote: > > On Sun, Dec 8, 2019 at 1:10 PM changkun > > wrote: > > > > Thank you so much for your hin

[go-nuts] Re: why p's local run queue size is 256?

2020-01-26 Thread changkun
256 run queue size is designed for the work-steal scheduler to prevent false sharing. 128 run queue size exactly fits one cache line. Since the run queue can be stolen half of the run queue from the tail by other Ps, 256 run queue size prevents false sharing when the work-steal happens on diffe

[go-nuts] Is it considered to separate runtime and cmd/compile irrelevant standard libraries out from the core language repo and hosted in a different module, eg. std?

2020-01-27 Thread changkun
mod file, import as "io" directly. Thanks for reading. Changkun -- 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...@goog

[go-nuts] Re: Is it considered to separate runtime and cmd/compile irrelevant standard libraries out from the core language repo and hosted in a different module, eg. std?

2020-01-27 Thread changkun
> > but the others are needed for "go build" & co. > This can be solved by first issuing an std module first, then using go modules to import these packages for go build. The idea is to separate compiler and runtime, then have a minimum go core distribution. The Go development process then can

Re: [go-nuts] Re: Is it considered to separate runtime and cmd/compile irrelevant standard libraries out from the core language repo and hosted in a different module, eg. std?

2020-01-28 Thread changkun
ouble we have making a single unified release, it's not obvious > to me that the Go team has the bandwidth to handle separate release > cycles that need to work together. > > Ian > > > > > On Mon, Jan 27, 2020 at 3:31 PM Volker Dobler > wrote: > >>

Re: [go-nuts] Re: Is it considered to separate runtime and cmd/compile irrelevant standard libraries out from the core language repo and hosted in a different module, eg. std?

2020-01-30 Thread changkun
nd see if I can find any undetailed planned proposal leaks, sorry about any inappropriate wording. Changkun On Tuesday, January 28, 2020 at 11:38:20 PM UTC+8, Ian Lance Taylor wrote: > > On Tue, Jan 28, 2020 at 12:27 AM changkun > wrote: > > > > - the main repo team focus

[go-nuts] How to plug git version when using "go get" to fetch a cli?

2020-11-25 Thread changkun
Hi golang-nuts, As far as I know, there are two approaches to add extra information at build time: 1. using -ldflags="-X path/pkg.Var=${ENV_VAR}", in a Makefile 2. using `go generate ./...`, before `go build` These approaches are good as it is if I build my binary and distribute it to other use

Re: [go-nuts] How to plug git version when using "go get" to fetch a cli?

2020-11-25 Thread changkun
That is really unfortunate. Is there any alternative solution so that I can burn at least the version information to the binary when a user uses `go get`? On Wednesday, November 25, 2020 at 6:36:17 PM UTC+1 Jan Mercl wrote: > On Wed, Nov 25, 2020 at 6:25 PM changkun wrote: > > >

[go-nuts] How to use atomic_int in cgo?

2021-02-15 Thread changkun
Hi golang-nuts, I would like to call a C function from Go and get notified about the execution status in Go, say a goroutine wait until the C function finally made some progress. Initially, I thought about passing a channel to C but the cgo document does not say anything about that: Later, I a

Re: [go-nuts] How to use atomic_int in cgo?

2021-02-15 Thread changkun
nels in correspondingly invoked C functions? Sincerely, Changkun -- 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...@googlegroups.com. T

Re: [go-nuts] How to use atomic_int in cgo?

2021-02-20 Thread changkun
12:39 PM changkun wrote: > > > > Thanks for the hint, but I have some follow-up questions: > > > >> > >> Even if there were a way to do this, an atomic variable is not a good > >> synchronization mechanism, because the other side has to poll the > >&

[go-nuts] A Question About Type Set and Parameter Design

2021-08-23 Thread changkun
Hi golang-nuts, I am trying out the latest type parameter, and type sets design. The purpose is to implement a Clamp function that works for numbers and vectors. The version for numbers is straightforward and easy: ```go // Number is a type set of numbers. type Number interface { ~int | ~int

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-27 Thread Changkun Ou
Many thank for the perf tool, it is pretty awesome. > On 27. Aug 2019, at 13:36, Robert Engels wrote: > > Ok maybe it wasn’t the cache issue, so then try this, below a certain number > of go routines given the workload the spin and cas works, beyond a certain > point it is forced into the sema

[go-nuts] A question about Type Sets

2021-08-23 Thread Changkun Ou
Hi golang-nuts, I am trying out the latest type parameter and type sets design. The purpose is to implement a Clamp function that works for numbers and vectors. The version for numbers is straightforward and easy: ```go // Number is a type set of numbers. type Number interface { ~int | ~int8 | ~

[go-nuts] Is introducing ... to parameter list a breaking change? How is it considered in the proposal process?

2022-05-03 Thread Changkun Ou
ctual breaking change? Thanks! Changkun -- 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...@googlegroups.com. To view this discussion o

Re: [go-nuts] Is introducing ... to parameter list a breaking change? How is it considered in the proposal process?

2022-05-03 Thread Changkun Ou
lot of time from a very early attempt to tackle the problem once again. Changkun On Tuesday, May 3, 2022 at 9:38:35 PM UTC+2 Ian Lance Taylor wrote: > On Tue, May 3, 2022 at 12:28 PM Changkun Ou wrote: > > > > I wonder how the Go project defines a breaking change, specifically f

Re: [go-nuts] About Go 1.19 memory model clarificaitons on atomic operations.

2022-08-15 Thread Changkun Ou
I think the new memory model does not guarantee this program always prints 1: 1. There is no synchronization guarantee between line 13 and line 14 as these atomic operations are manipulated on the different memory locations. 2. It is *not* prohibited for the compiler to switch line 13 and line 14

Re: [go-nuts] About Go 1.19 memory model clarificaitons on atomic operations.

2022-08-15 Thread Changkun Ou
of execution. The most relaxing requirement: permit the compiler to switch the statement. On Mon, Aug 15, 2022 at 9:32 AM Axel Wagner wrote: > > > > On Mon, Aug 15, 2022 at 9:06 AM Changkun Ou wrote: >> >> I think the new memory model does not guarantee this program always pr

Re: [go-nuts] About Go 1.19 memory model clarificaitons on atomic operations.

2022-08-15 Thread Changkun Ou
ations on different memory locations obey the program statements order within a goroutine. On Mon, Aug 15, 2022 at 10:16 AM Axel Wagner wrote: > > On Mon, Aug 15, 2022 at 10:02 AM Changkun Ou wrote: >> >> > The memory operations in each goroutine must correspond to

[go-nuts] Re: Is golang/mobile still active?

2022-09-12 Thread Changkun Ou
golang/mobile is still maintenance. If you encounter any usage issues, feel free to report them here: https://github.com/golang/go/issues On Monday, September 12, 2022 at 3:33:18 AM UTC+2 sytuv ccoxf wrote: > Is golang/mobile still active? > > It seems like does not committed since Jul 23 2022.