[go-nuts] Building a select friendly condition type

2017-11-29 Thread Dave Cheney
Hello, Anyone for a round of code golf? I'm working on a piece of code for a streaming gRPC server and have found myself in the position that I need to wait for a notification event (in this case that a cache has been updated and I need to stream the results to the client) or a context.Done ev

[go-nuts] Re: Is there a way omit the the additional allocation when passing []byte to C function?

2017-11-29 Thread xingtao zhao
/* C code: struct PKCS15_Ret { int error_code; int len; }; struct PKCS15_Ret PKCS15_wrap(int hash_type, octet message, octet receive) { int error_code = PKCS15(hashType, &mOct, &cOct); return struct PKCS15_Ret{ error_code, cOct.len }; } */ func PKCS15_PLAIN(hashType, RFS int, msg []byte) ([]byt

[go-nuts] Re: Is there a way omit the the additional allocation when passing []byte to C function?

2017-11-29 Thread xingtao zhao
Make your C function to accept octet parameter, instead of *octet parameter? Then there will be no allocations. On Wednesday, November 29, 2017 at 2:39:38 PM UTC-8, Владислав Митов wrote: > > So no way around 4 allocations for 2 values? -- You received this message because you are subscribed t

[go-nuts] Is there a way omit the the additional allocation when passing []byte to C function?

2017-11-29 Thread Владислав Митов
So no way around 4 allocations for 2 values? -- 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. For more options, visit ht

[go-nuts] Is there a way omit the the additional allocation when passing []byte to C function?

2017-11-29 Thread Tamás Gulácsi
The cgo checker is right: you send in a pointer with a pointer in it - mOct is a pointer, and mOct.val is a pointer, too. You have to malloc it. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving em

Re: [go-nuts] Is there a way omit the the additional allocation when passing []byte to C function?

2017-11-29 Thread Владислав Митов
Hey, thanks about the swift answer. I got to that thread but the solutions didn't worked for me. I'm still hitting the cgo pointer check. Works if I disable it though. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this grou

Re: [go-nuts] Is there a way omit the the additional allocation when passing []byte to C function?

2017-11-29 Thread Ian Lance Taylor
On Wed, Nov 29, 2017 at 1:00 PM, Владислав Митов wrote: > > I'm writing a Go wrapper around C library and I'm trying to omit all > possible allocations. > > Here is my working example - > https://github.com/milagro-crypto/milagro-crypto-c/commit/1f070f24d83c76c5e7e5c6c548a9715438abc758#diff-a3c034

[go-nuts] Is there a way omit the the additional allocation when passing []byte to C function?

2017-11-29 Thread Владислав Митов
Hello, I'm writing a Go wrapper around C library and I'm trying to omit all possible allocations. Here is my working example - https://github.com/milagro-crypto/milagro-crypto-c/commit/1f070f24d83c76c5e7e5c6c548a9715438abc758#diff-a3c034fc3f075297e9e3a7cca9ace62eR65. There are 3 allocations t

Re: [go-nuts] Sort a huge slice of data around 2GB

2017-11-29 Thread Michael Jones
agree! On Wed, Nov 29, 2017 at 11:37 AM, 'Axel Wagner' via golang-nuts < golang-nuts@googlegroups.com> wrote: > BTW, depending on what the problem is we are actually talking about, even > the numbers from the initial post might be fine. With those numbers, > sorting the 2GB should take roughly ha

Re: [go-nuts] Sort a huge slice of data around 2GB

2017-11-29 Thread 'Axel Wagner' via golang-nuts
BTW, depending on what the problem is we are actually talking about, even the numbers from the initial post might be fine. With those numbers, sorting the 2GB should take roughly half an hour. A significant amount of time, yes, but if you only need to do it once (or once a day or week or whatever)

Re: [go-nuts] Sort a huge slice of data around 2GB

2017-11-29 Thread Michael Jones
here's a little more detail on system / direct-type / and parallel direct-type sorting: celeste:double mtj$ go test -run=NONE -bench Sort goos: darwin goarch: amd64 pkg: double BenchmarkSSort250-8 10 11285 ns/op BenchmarkSSort500-8 5 31001 ns/op BenchmarkSSort

Re: [go-nuts] Sort a huge slice of data around 2GB

2017-11-29 Thread Michael Jones
Using a personal sort to avoid the standard sort's abstraction... // 50331648 bytes,6291456 8-byte elements, 0.687317 seconds (48MB of uint64) // 50331648 bytes, 50331648 1-byte elements, 1.605258 seconds (48MB of uint8) // 2147483648 bytes, 268435456 8-byte elements, 35.262593 seconds (2

[go-nuts] golang library linking queries

2017-11-29 Thread jaysharma391
Hello All, I am new to golang. I have a few queries: I am developing: SDK which have 4-5 files, SDK has dependency on protocol buffer. *1. If I run the below command on SDK folder : * $ go build - It build all the SDK files and create "sdk.a" file in pkg folder. *

Re: [go-nuts] best practice for listening multiple linux TCP port?

2017-11-29 Thread Ian Lance Taylor
On Tue, Nov 28, 2017 at 10:01 PM, wrote: > > I have a requirement that our application needs to listen multiple TCP ports > (mayebe some hundreds). It is not important why we have such a strange > requirements. We can listen more ports and stop some listened ports at > runtime. > > The applicatio

Re: [go-nuts] Sort a huge slice of data around 2GB

2017-11-29 Thread 'Axel Wagner' via golang-nuts
I'm not sure that the sort package is your your problem, here. First, the actual size (in bytes) of the data set matters, but is not *that* important. The number of elements is much more important. And I wrote a naive program to measure how long it takes to sort different in-memory data sets and ge

Re: [go-nuts] How to check if db connection active after database server restarts ?

2017-11-29 Thread Shawn Milochik
Ping() lets you verify a connection. It should also be used when the initial connection is made. https://golang.org/pkg/database/sql/#DB.Ping -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving email

Re: [go-nuts] Sort a huge slice of data around 2GB

2017-11-29 Thread Subramanian Karunanithi
Hi, Yes measuring it now shall get back, on a side note do we have any big datafile parsing package part of go or some library? The basic sort.Sort() what I have is taking 44sec for 48MB of data, I have to parse 2G of data. Regards, Subu K On Wed, Nov 29, 2017 at 8:03 PM, Jan Mercl <0xj...@gmai

Re: [go-nuts] Sort a huge slice of data around 2GB

2017-11-29 Thread Jan Mercl
On Wed, Nov 29, 2017 at 3:19 PM Subramanian K wrote: > To run 2GB of data it takes really long time, I am trying to split these to buckets and make it run concurrently, finally need to collate results of all these small sorted buckets. Have you measured and detected where the bottleneck is? If i

[go-nuts] How to check if db connection active after database server restarts ?

2017-11-29 Thread nupur8121991
Hi All, I have built a Golang application based on REST services that connects to different databases and fetches results. When 1 url is hit then if a connection does not already exist, it is created. If it already exists then it is used as such. Connection is being stored in a global variable

[go-nuts] Sort a huge slice of data around 2GB

2017-11-29 Thread Subramanian K
Hi I am using native sort provided part of the package and to process 48MB of slice data, it takes ~45sec. To run 2GB of data it takes really long time, I am trying to split these to buckets and make it run concurrently, finally need to collate results of all these small sorted buckets. Do we

[go-nuts] best practice for listening multiple linux TCP port?

2017-11-29 Thread smallnest
I have a requirement that our application needs to listen multiple TCP ports (mayebe some hundreds). It is not important why we have such a strange requirements. We can listen more ports and stop some listened ports at runtime. The application is running at Linux and listen by TCP. My basic th

[go-nuts] Re: profiling webserver with pprof and router middleware

2017-11-29 Thread skaldendudler
Does noone have an idea? :( Am Montag, 27. November 2017 13:37:43 UTC+1 schrieb basti skalendudler: > > The go tool pprof command is interactive, so I thought it is enough type > 'png' to get the image after the benchmark is run > > I tested to start go tool pprof now as well during and after the