[go-nuts] Go string and UTF-8

2019-08-20 Thread Pierre Durand
I know that by convention Go string contain UTF-8 encoded text. Is it recommended/a good practice to store invalid bytes in a string ? The use case: - compute a hash => get a []byte - convert the []byte to string (this string is not UTF-8 valid) - use the string as a map key In my case, the hash

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

2019-08-20 Thread changkun
Hi Robert, Thanks for your explanation. But how could I "logged the number of operations done per Go routine", which particular debug settings you referring to? It is reasonable that sync.Mutex rely on runtime scheduler but channels do not. However, it is unclear why a significant performance d

[go-nuts] Re: Go string and UTF-8

2019-08-20 Thread djego . joss
On Tue, Aug 20, 2019 at 10:12 AM Pierre Durand wrote: > > I know that by convention Go string contain UTF-8 encoded text. To my understanding this is not entirely true -- see https://blog.golang.org/strings#TOC_2. -- It is simply a readonly slice of bytes. However there is at least 2 places wher

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

2019-08-20 Thread Ian Davis
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 Go routine", which particular debug settings you referring to? > It is reasonable that sync.Mutex rely on runtime scheduler but channels do

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

2019-08-20 Thread changkun
Hi Ian Davis, I read the issue before I post this thread. I think the old issue is quite different than here. Here the problem discusses sudden performance drop and unexpected regression, but the issue#5183 only did experiment on a very limited number of goroutines, and Dmitry's answer is fair

[go-nuts] Re: Go string and UTF-8

2019-08-20 Thread Pierre Durand
OK, thank you ! Le mardi 20 août 2019 10:34:55 UTC+2, djeg...@gmail.com a écrit : > > On Tue, Aug 20, 2019 at 10:12 AM Pierre Durand wrote: > > > > I know that by convention Go string contain UTF-8 encoded text. > > To my understanding this is not entirely true -- see > https://blog.golang.org/st

Re: [go-nuts] Go string and UTF-8

2019-08-20 Thread Sam Whited
I personally wouldn't do this. If you're going to incur the overhead of a heap allocation, might as well incur a bit more and encode the hash, eg. using hex.EncodeToString [1], just so that you don't forget and try to print or decode the string as utf8 later. —Sam [1]: https://godoc.org/encodi

Re: [go-nuts] Go string and UTF-8

2019-08-20 Thread Rob Pike
Printf can print hexadecimal just fine. Never understood the point of encoding/hex. Meanwhile, for questions about strings, see blog.golang.org/strings. -rob On Tue, Aug 20, 2019 at 9:00 PM Sam Whited wrote: > I personally wouldn't do this. If you're going to incur the overhead of a > heap al

Re: [go-nuts] Go string and UTF-8

2019-08-20 Thread Sam Whited
On August 20, 2019 11:50:54 AM UTC, Rob Pike wrote: >Printf can print hexadecimal just fine. Never understood the point of >encoding/hex. I always thought that the C style format strings were unreadable and the hex package methods were much clearer, personally. —Sam -- You received this me

Re: [go-nuts] How to build gollvm on arm platform

2019-08-20 Thread eric fang
Hi Than, I'm trying to implement the abi part for arm64, and got two questions for you: 1, function CABIOracle::canPassDirectly in gollvm/bridge/go-llvm-cabi-oracle.cpp, I'm not quite understand the first if statement: if (regsInt + regsSSE == 1) return true; Why not consider whether th

Re: [go-nuts] Go string and UTF-8

2019-08-20 Thread Pierre Durand
Well, in my case I don't want to convert the []byte to hexadecimal string, because it uses 2x more memory. The code contains a huge map where the key is an MD5 hash. Please note that I'm not personally working on this. I was reviewing the code written by a coworker, and I noticed that there was

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

2019-08-20 Thread robert engels
If you just print the final value of V in both cases you will see: On my iMac: channels: 215606060 mutex: 651606060 Or the mutex has 3x greater throughput. How the Go routines are scheduled is OS dependent - the OSX code uses the same mechanism in both cases. You have to remember that that the

[go-nuts] Running tests per package with Go module

2019-08-20 Thread Dr Waryaa
Hi, I have a Go module which looks as follows: go.mod go.sum | - pkg1 | -pkg2 The module is called mydomain.com/mypkg I'm trying to run the tests for pkg1 by calling go test ./pkg1/... My problem is that pkg1 imports mydomain.com/mypkg/pkg2 and that running the tests

Re: [go-nuts] Go string and UTF-8

2019-08-20 Thread Jan Mercl
On Tue, Aug 20, 2019 at 3:17 PM Pierre Durand wrote: > > Well, in my case I don't want to convert the []byte to hexadecimal string, > because it uses 2x more memory. > The code contains a huge map where the key is an MD5 hash. md5 hash is an array type and can be used as a map key directly: http

Re: [go-nuts] How to build gollvm on arm platform

2019-08-20 Thread 'Than McIntosh' via golang-nuts
Hi Eric, Thanks for the note. Your question about the code in CABIOracle::canPassDirectly, e.g . if (regsInt + regsSSE == 1) return true; is a good one. I'll see about adding some comments to the code there. By way of explanation, the Gollvm code is modeled after the approach used in cla

Re: [go-nuts] How to build gollvm on arm platform

2019-08-20 Thread 'Than McIntosh' via golang-nuts
Forgot to add: When I was writing the x86_64 ABI code for gollvm, I spent some time creating an ABI test harness to find problems in my code. You can find it at: https://github.com/thanm/cabi-testgen The overall idea is that it randomly generates a lot of parameter-passing code, then you can bui

Re: [go-nuts] How to build gollvm on arm platform

2019-08-20 Thread 'Than McIntosh' via golang-nuts
Sent https://go-review.googlesource.com/c/gollvm/+/190900 to improve comments. Thanks, Than On Tue, Aug 20, 2019 at 9:33 AM Than McIntosh wrote: > Hi Eric, > > Thanks for the note. Your question about the code in > CABIOracle::canPassDirectly, e.g . > > if (regsInt + regsSSE == 1) > retur

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

2019-08-20 Thread Robert Engels
I am assuming that there is an internal Go structure/process that when there is less than N Go routines it fits in the L1 CPU cache, and beyond a certain point it spills to the L2 or higher - thus the nearly order of magnitude performance decrease, yet consistent times within a range.Since the work

Re: [go-nuts] Existing production-ready libraries for parallelizing HTTP requests?

2019-08-20 Thread 'Thomas Bushnell, BSG' via golang-nuts
I am of the opinion that a case like this is best handled by simply writing the thing you want. Concurrency limits are easily managed by using tokens to gate fetches. One simple technique is to make a channel of struct{} with capacity equal to the maximum number of concurrent connections you are a

[go-nuts] Re: Running tests per package with Go module

2019-08-20 Thread Jacques Supcik
Hello Chris, I made a small project with the same structure as yours to reproduce the problem : https://github.com/supcik/rtppwgm But in my project, everything works as expected : » go test -count=1 ./... ok demo/pkg1 0.006s ok demo/pkg2 0.006s » go test -count=1 ./pkg1/.

Re: [go-nuts] Re: Running tests per package with Go module

2019-08-20 Thread Marcin Romaszewicz
It could fail if you're under $GOPATH and GO111MODULE=auto, since inside the GOPATH, auto=off -- Marcin On Tue, Aug 20, 2019 at 12:43 PM Jacques Supcik wrote: > Hello Chris, > > I made a small project with the same structure as yours to reproduce the > problem : https://github.com/supcik/rtppw

[go-nuts] Patch RFA: [C family frontend]: avoid weird constant values in libgo/sysinfo.go

2019-08-20 Thread Ian Lance Taylor
On Mon, Aug 12, 2019 at 8:21 PM Xiangdong JI wrote: > > The .go files generated during building gccgo seem to have a few constants > with weird values, for example: > > // sysinfo.go (on x86-64, latest gcc-9 trunk) > > const ___FLT128_MAX__ = 1.1 > const ___FLT32X_DENORM_MIN__ = 1.1 > > as a comp

Re: [go-nuts] net library

2019-08-20 Thread joe mcguckin
https://golang.org/pkg/net/ -- 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 on the web visit ht

[go-nuts] Empty cpu profile file?

2019-08-20 Thread joe mcguckin
Using Dave Cheney's profile package to figure out the execution path of a library I'm trying to understand. The application starts, (it's a server), I hit ^c after a couple of minutes, and the console says Stopping Profiling Stopping Main() catches the console interrupt: signal.Not

Re: [go-nuts] net library

2019-08-20 Thread Ian Lance Taylor
On Mon, Aug 19, 2019 at 6:44 PM joe mcguckin wrote: > > I was perusing the NET library web page today. > > 1) Are the packages listed in any particular order? The types and functions are listed alphabetically. > 2) What is the hierarchy? e.g., which functions correspond to the low level > Unix

[go-nuts] asm: FUNCDATA PCDATA

2019-08-20 Thread Gert
https://golang.org/doc/asm $ cat x.go package main func main() { println(3) } $ GOOS=linux GOARCH=amd64 go tool compile -S x.go# or: go build -gcflags -S x.go --- prog list "main" --- (x.go:3) TEXTmain+0(SB),$8-0 0001 (x.go:3) FUNCDATA $0,gcargs·0+0(SB) 0002 (x.go:3) FU

[go-nuts] Re: Running tests per package with Go module

2019-08-20 Thread Dr Waryaa
Hi Jacques, Thanks for trying that. I found out that I was on a wild goose chase. As it turns out, it was code that my TestMain called which had a hard-coded reference looking for the GOPATH. Cheers, Chris On Wednesday, August 21, 2019 at 5:43:51 AM UTC+10, Jacques Supcik wrote: > > Hello Chris,

Re: [go-nuts] How to build gollvm on arm platform

2019-08-20 Thread eric fang
Hi Than, I got it, thanks for your detailed explanation. And I'm also thinking about how to write test cases, the cabi-testgen project would be a great help, I will keep you informed if there are other questions or updates, thank you. -- You received this message because you are subscribed to

[go-nuts] Re: How to convert reflect.Value to time.Time

2019-08-20 Thread Moises Soto
Well, this is really old but I had the same problem and its because you need to export the field on YOUR struct (time.Time doesn't needs to have exported fields like someone else said). Here's the same code with element *t time.Time* declared as *T time.Time: * https://play.golang.org/p/tXh2LqT8

Re: [go-nuts] Existing production-ready libraries for parallelizing HTTP requests?

2019-08-20 Thread Sam Fourman Jr.
I am also in the same boat as tom, there is certainly a demand for this type of library. -- Sam Fourman On Tue, Aug 20, 2019 at 3:33 PM 'Thomas Bushnell, BSG' via golang-nuts < golang-nuts@googlegroups.com> wrote: > I am of the opinion that a case like this is best handled by simply > writing th

[go-nuts] what do init functions like "math ~math" in .gox refer to?

2019-08-20 Thread Xiangdong JI
Hello, In 'init' section of .gox files, there might be functions like the followings besides those 'import', math ~math bits ~math..z2fbits atomic ~runtime..z2finternal..z2fatomic where and how are those functions generated, any source code or doc I can refer to? Thanks. -- Y

[go-nuts] Re: Patch RFA: [C family frontend]: avoid weird constant values in libgo/sysinfo.go

2019-08-20 Thread Xiangdong JI
Thanks a lot, Ian. the schedule is fine. On Wednesday, August 21, 2019 at 7:37:10 AM UTC+8, Ian Lance Taylor wrote: > > On Mon, Aug 12, 2019 at 8:21 PM Xiangdong JI > wrote: > > > > The .go files generated during building gccgo seem to have a few > constants with weird values, for example: >

Re: [go-nuts] what do init functions like "math ~math" in .gox refer to?

2019-08-20 Thread Ian Lance Taylor
On Tue, Aug 20, 2019 at 9:12 PM Xiangdong JI wrote: > > In 'init' section of .gox files, there might be functions like the followings > besides those 'import', > > math ~math bits ~math..z2fbits atomic > ~runtime..z2finternal..z2fatomic > > where and how are those functions generated

Re: [go-nuts] what do init functions like "math ~math" in .gox refer to?

2019-08-20 Thread Xiangdong JI
Thanks Ian. Curious to know the purpose of those dummy functions, and for the 'import' functions do they have real function bodies? On Wednesday, August 21, 2019 at 12:40:44 PM UTC+8, Ian Lance Taylor wrote: > > On Tue, Aug 20, 2019 at 9:12 PM Xiangdong JI > wrote: > > > > In 'init' section o