Re: [go-nuts] Re: are interface calls to empty methods optimized away - so there is no function call overhead beyond the dereference/jump?

2017-12-04 Thread Dave Cheney
I think you're right. The subtleties escape me as they changed several 
times around ~1.6 because of the requirements of the concurrent collector. 
I had thought that _anything_ that was not already pointer shaped was 
copied and the address of the copy was placed into the interface.

On Tuesday, 5 December 2017 18:41:51 UTC+11, Axel Wagner wrote:
>
> Slight correction (I think): If you store a non-pointer in an interface, 
> it won't store the address of the value (variable? values don't have an 
> address, strictly speaking), but will make a copy. Otherwise, this wouldn't 
> work: https://play.golang.org/p/P1YwxBk7lR
> You can also see these effects here (and feel free to play around a bit): 
> https://play.golang.org/p/GqAUn31A1y
>
> On Tue, Dec 5, 2017 at 2:44 AM, Dave Cheney  > wrote:
>
>>
>>
>> On Tuesday, 5 December 2017 12:19:29 UTC+11, simon place wrote:
>>>
>>> in a very similar vein, something i have been wondering about for a 
>>> while now;
>>>
>>> when an interface contains a pointer type, does Go double dereference or 
>>> conflate the pointers?
>>>
>>
>> If the *type* of the value placed into the interface is pointer shaped 
>> then it value is used as is, if not, the address of the value is taken, and 
>> the address is used as the interface's value.
>>  
>>
>> -- 
>> 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...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] Re: are interface calls to empty methods optimized away - so there is no function call overhead beyond the dereference/jump?

2017-12-04 Thread 'Axel Wagner' via golang-nuts
Slight correction (I think): If you store a non-pointer in an interface, it
won't store the address of the value (variable? values don't have an
address, strictly speaking), but will make a copy. Otherwise, this wouldn't
work: https://play.golang.org/p/P1YwxBk7lR
You can also see these effects here (and feel free to play around a bit):
https://play.golang.org/p/GqAUn31A1y

On Tue, Dec 5, 2017 at 2:44 AM, Dave Cheney  wrote:

>
>
> On Tuesday, 5 December 2017 12:19:29 UTC+11, simon place wrote:
>>
>> in a very similar vein, something i have been wondering about for a while
>> now;
>>
>> when an interface contains a pointer type, does Go double dereference or
>> conflate the pointers?
>>
>
> If the *type* of the value placed into the interface is pointer shaped
> then it value is used as is, if not, the address of the value is taken, and
> the address is used as the interface's value.
>
>
> --
> 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 https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] Re: GC SW times on Heroku (Beta metrics)

2017-12-04 Thread Henrik Johansson
I am watching with childlike fascination...
This is interesting perhaps:

gc 130 @2834.158s 0%: 0.056+3.4+2.9 ms clock, 0.45+2.8/5.6/0+23 ms cpu,
8->8->4 MB, 9 MB goal, 8 P
gc 131 @2834.178s 0%: 0.023+7.3+0.12 ms clock, 0.18+1.2/5.4/9.2+1.0 ms cpu,
9->9->5 MB, 10 MB goal, 8 P

---> gc 132 @2836.882s 0%: 3.5+34+8.0 ms clock, 28+1.6/3.8/27+64 ms cpu,
10->11->4 MB, 11 MB goal, 8 P

gc 133 @2836.961s 0%: 0.022+14+1.0 ms clock, 0.18+2.1/12/0+8.4 ms cpu,
8->9->5 MB, 9 MB goal, 8 P
gc 134 @2837.010s 0%: 7.0+18+0.16 ms clock, 56+14/21/1.6+1.2 ms cpu,
9->10->5 MB, 10 MB goal, 8 P

28 + 64 ms SW (if I understand this correctly) to collect what 6-7 MB?



tis 5 dec. 2017 kl 08:25 skrev Dave Cheney :

> Oh yeah, I forgot someone added that a while back. That should work.
>
> On Tue, Dec 5, 2017 at 6:23 PM, Henrik Johansson 
> wrote:
> > So it has to run the program? I thought I saw "logfile" scenario in the
> > examples?
> >
> > GODEBUG=gctrace=1 godoc -index -http=:6060 2> stderr.log
> > cat stderr.log | gcvis
> >
> > I have shuffled the Heroku logs into Papertrail so I should be able to
> > extract the log lines from there.
> >
> >
> > tis 5 dec. 2017 kl 08:10 skrev Dave Cheney :
> >>
> >> Probably not for your scenario, gcviz assumes it can run your program
> >> as a child.
> >>
> >> On Tue, Dec 5, 2017 at 6:07 PM, Henrik Johansson 
> >> wrote:
> >> > I found https://github.com/davecheney/gcvis from +Dave Cheney is it a
> >> > good
> >> > choice for inspecting the gc logs?
> >> >
> >> > tis 5 dec. 2017 kl 07:57 skrev Henrik Johansson  >:
> >> >>
> >> >> I have just added the gc tracing and it looks like this more or less
> >> >> all
> >> >> the time:
> >> >>
> >> >> gc 78 @253.095s 0
> %:
> 0.032+3.3+0.46 ms clock, 0.26+0.24/2.6/2.4+3.6 ms
> >> >> cpu,
> >> >> 11->12->4 MB, 12 MB goal, 8 P
> >> >> gc 79 @253.109s 0%: 0.021+2.1+0.17 ms clock, 0.16+0.19/3.6/1.2+1.3 ms
> >> >> cpu,
> >> >> 9->9->4 MB, 10 MB goal, 8 P
> >> >> gc 80 @253.120s 0%: 0.022+2.8+2.2 ms clock, 0.17+0.27/4.8/0.006+18 ms
> >> >> cpu,
> >> >> 8->8->4 MB, 9 MB goal, 8 P
> >> >> gc 81 @253.138s 0%: 0.019+2.3+0.10 ms clock, 0.15+0.73/3.9/3.1+0.81
> ms
> >> >> cpu, 9->9->5 MB, 10 MB goal, 8 P
> >> >>
> >> >> Heroku already reports a SW of 343 ms but I can't find it by manual
> >> >> inspection. I will download the logs later today and try to generate
> >> >> realistic load.
> >> >> What is the overhead of running like this, aside from the obvious
> extra
> >> >> logging?
> >> >> Are there any automatic tools to analyze these logs?
> >> >>
> >> >> lör 2 dec. 2017 kl 22:36 skrev Henrik Johansson <
> dahankz...@gmail.com>:
> >> >>>
> >> >>> I am sorry, I was unclear. The app uses very little ram but the
> >> >>> provisioned available memory is 512 MB.
> >> >>>
> >> >>> I will try to experiment with GC toggles as you suggest and report
> >> >>> back.
> >> >>>
> >> >>> Thx!
> >> >>>
> >> >>>
> >> >>> On Sat, Dec 2, 2017, 22:18 rlh via golang-nuts
> >> >>>  wrote:
> >> 
> >>  Hard telling what it going on. 35MB, even for 1 CPU, seems very
> >>  small.
> >>  Most modern system provision more than 1GB per HW thread though
> I've
> >>  seen
> >>  some provision as little as 512MB. GOGC (SetGCPercent) can be
> adjust
> >>  so that
> >>  the application uses more of the available RAM. Running with
> >>  GODEBUG=gctrace=1 will give you a sense of the GC's view of the
> >>  application.
> >> 
> >>  In any case these kinds of numbers, running on a real systems, and
> >>  duplicatable on tip are worth filing an issue.
> >> 
> >>  On Saturday, December 2, 2017 at 3:02:30 AM UTC-5, Henrik Johansson
> >>  wrote:
> >> >
> >> > Hi,
> >> >
> >> > I am befuddled by GC SW times on several seconds (seen 20s once)
> in
> >> > the
> >> > metrics page for our app. There are several things that are
> strange
> >> > but
> >> > perhaps I am misreading it. The same metrics page reports Max
> Total
> >> > 35 MB
> >> > out of which 1 MB s swap the rest RSS. The response times on the
> >> > service is
> >> > has 99% ~400 ms which is not good but 95% is ~120 ms usually.
> >> > The app reloads an in memory cache as needed using atomic,Value
> as a
> >> > holder and the size is no more than a few thousand at any given
> >> > time.
> >> > Basically a map with pointers to simple structs and lists with
> >> > pointers
> >> > to the same structs to allow for some simple access scenarios.
> >> >
> >> > Now I haven't profiled the app yet but even in a very pathologial
> >> > case
> >> > it seems as though the GC would be able to keep up easily with
> such
> >> > little
> >> > amount of memory being used. Granted this is a Standard 1x dyno
> but
> >> > 

Re: [go-nuts] Re: GC SW times on Heroku (Beta metrics)

2017-12-04 Thread Henrik Johansson
So it has to run the program? I thought I saw "logfile" scenario in the
examples?

GODEBUG=gctrace=1 godoc -index -http=:6060 2> stderr.log
cat stderr.log | gcvis

I have shuffled the Heroku logs into Papertrail so I should be able to
extract the log lines from there.


tis 5 dec. 2017 kl 08:10 skrev Dave Cheney :

> Probably not for your scenario, gcviz assumes it can run your program
> as a child.
>
> On Tue, Dec 5, 2017 at 6:07 PM, Henrik Johansson 
> wrote:
> > I found https://github.com/davecheney/gcvis from +Dave Cheney is it a
> good
> > choice for inspecting the gc logs?
> >
> > tis 5 dec. 2017 kl 07:57 skrev Henrik Johansson :
> >>
> >> I have just added the gc tracing and it looks like this more or less all
> >> the time:
> >>
> >> gc 78 @253.095s 0%: 0.032+3.3+0.46 ms clock, 0.26+0.24/2.6/2.4+3.6 ms
> cpu,
> >> 11->12->4 MB, 12 MB goal, 8 P
> >> gc 79 @253.109s 0%: 0.021+2.1+0.17 ms clock, 0.16+0.19/3.6/1.2+1.3 ms
> cpu,
> >> 9->9->4 MB, 10 MB goal, 8 P
> >> gc 80 @253.120s 0%: 0.022+2.8+2.2 ms clock, 0.17+0.27/4.8/0.006+18 ms
> cpu,
> >> 8->8->4 MB, 9 MB goal, 8 P
> >> gc 81 @253.138s 0%: 0.019+2.3+0.10 ms clock, 0.15+0.73/3.9/3.1+0.81 ms
> >> cpu, 9->9->5 MB, 10 MB goal, 8 P
> >>
> >> Heroku already reports a SW of 343 ms but I can't find it by manual
> >> inspection. I will download the logs later today and try to generate
> >> realistic load.
> >> What is the overhead of running like this, aside from the obvious extra
> >> logging?
> >> Are there any automatic tools to analyze these logs?
> >>
> >> lör 2 dec. 2017 kl 22:36 skrev Henrik Johansson :
> >>>
> >>> I am sorry, I was unclear. The app uses very little ram but the
> >>> provisioned available memory is 512 MB.
> >>>
> >>> I will try to experiment with GC toggles as you suggest and report
> back.
> >>>
> >>> Thx!
> >>>
> >>>
> >>> On Sat, Dec 2, 2017, 22:18 rlh via golang-nuts
> >>>  wrote:
> 
>  Hard telling what it going on. 35MB, even for 1 CPU, seems very small.
>  Most modern system provision more than 1GB per HW thread though I've
> seen
>  some provision as little as 512MB. GOGC (SetGCPercent) can be adjust
> so that
>  the application uses more of the available RAM. Running with
>  GODEBUG=gctrace=1 will give you a sense of the GC's view of the
> application.
> 
>  In any case these kinds of numbers, running on a real systems, and
>  duplicatable on tip are worth filing an issue.
> 
>  On Saturday, December 2, 2017 at 3:02:30 AM UTC-5, Henrik Johansson
>  wrote:
> >
> > Hi,
> >
> > I am befuddled by GC SW times on several seconds (seen 20s once) in
> the
> > metrics page for our app. There are several things that are strange
> but
> > perhaps I am misreading it. The same metrics page reports Max Total
> 35 MB
> > out of which 1 MB s swap the rest RSS. The response times on the
> service is
> > has 99% ~400 ms which is not good but 95% is ~120 ms usually.
> > The app reloads an in memory cache as needed using atomic,Value as a
> > holder and the size is no more than a few thousand at any given time.
> > Basically a map with pointers to simple structs and lists with
> pointers
> > to the same structs to allow for some simple access scenarios.
> >
> > Now I haven't profiled the app yet but even in a very pathologial
> case
> > it seems as though the GC would be able to keep up easily with such
> little
> > amount of memory being used. Granted this is a Standard 1x dyno but
> even so
> > once the machiine is stopped the GC should be able to complete it's
> work in
> > a very short time given the low used memory.
> >
> > Has anyone seen this as well? Could the Go metrics on Heroku simply
> > report erroneously? Perhaps a couple of orders of magnitide?
> >
> > Cheers,
> >
>  --
>  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 https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] Re: GC SW times on Heroku (Beta metrics)

2017-12-04 Thread Dave Cheney
Probably not for your scenario, gcviz assumes it can run your program
as a child.

On Tue, Dec 5, 2017 at 6:07 PM, Henrik Johansson  wrote:
> I found https://github.com/davecheney/gcvis from +Dave Cheney is it a good
> choice for inspecting the gc logs?
>
> tis 5 dec. 2017 kl 07:57 skrev Henrik Johansson :
>>
>> I have just added the gc tracing and it looks like this more or less all
>> the time:
>>
>> gc 78 @253.095s 0%: 0.032+3.3+0.46 ms clock, 0.26+0.24/2.6/2.4+3.6 ms cpu,
>> 11->12->4 MB, 12 MB goal, 8 P
>> gc 79 @253.109s 0%: 0.021+2.1+0.17 ms clock, 0.16+0.19/3.6/1.2+1.3 ms cpu,
>> 9->9->4 MB, 10 MB goal, 8 P
>> gc 80 @253.120s 0%: 0.022+2.8+2.2 ms clock, 0.17+0.27/4.8/0.006+18 ms cpu,
>> 8->8->4 MB, 9 MB goal, 8 P
>> gc 81 @253.138s 0%: 0.019+2.3+0.10 ms clock, 0.15+0.73/3.9/3.1+0.81 ms
>> cpu, 9->9->5 MB, 10 MB goal, 8 P
>>
>> Heroku already reports a SW of 343 ms but I can't find it by manual
>> inspection. I will download the logs later today and try to generate
>> realistic load.
>> What is the overhead of running like this, aside from the obvious extra
>> logging?
>> Are there any automatic tools to analyze these logs?
>>
>> lör 2 dec. 2017 kl 22:36 skrev Henrik Johansson :
>>>
>>> I am sorry, I was unclear. The app uses very little ram but the
>>> provisioned available memory is 512 MB.
>>>
>>> I will try to experiment with GC toggles as you suggest and report back.
>>>
>>> Thx!
>>>
>>>
>>> On Sat, Dec 2, 2017, 22:18 rlh via golang-nuts
>>>  wrote:

 Hard telling what it going on. 35MB, even for 1 CPU, seems very small.
 Most modern system provision more than 1GB per HW thread though I've seen
 some provision as little as 512MB. GOGC (SetGCPercent) can be adjust so 
 that
 the application uses more of the available RAM. Running with
 GODEBUG=gctrace=1 will give you a sense of the GC's view of the 
 application.

 In any case these kinds of numbers, running on a real systems, and
 duplicatable on tip are worth filing an issue.

 On Saturday, December 2, 2017 at 3:02:30 AM UTC-5, Henrik Johansson
 wrote:
>
> Hi,
>
> I am befuddled by GC SW times on several seconds (seen 20s once) in the
> metrics page for our app. There are several things that are strange but
> perhaps I am misreading it. The same metrics page reports Max Total 35 MB
> out of which 1 MB s swap the rest RSS. The response times on the service 
> is
> has 99% ~400 ms which is not good but 95% is ~120 ms usually.
> The app reloads an in memory cache as needed using atomic,Value as a
> holder and the size is no more than a few thousand at any given time.
> Basically a map with pointers to simple structs and lists with pointers
> to the same structs to allow for some simple access scenarios.
>
> Now I haven't profiled the app yet but even in a very pathologial case
> it seems as though the GC would be able to keep up easily with such little
> amount of memory being used. Granted this is a Standard 1x dyno but even 
> so
> once the machiine is stopped the GC should be able to complete it's work 
> in
> a very short time given the low used memory.
>
> Has anyone seen this as well? Could the Go metrics on Heroku simply
> report erroneously? Perhaps a couple of orders of magnitide?
>
> Cheers,
>
 --
 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 https://groups.google.com/d/optout.

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] Re: GC SW times on Heroku (Beta metrics)

2017-12-04 Thread Henrik Johansson
I found https://github.com/davecheney/gcvis from +Dave Cheney
 is it a good choice for inspecting the gc logs?

tis 5 dec. 2017 kl 07:57 skrev Henrik Johansson :

> I have just added the gc tracing and it looks like this more or less all
> the time:
>
> gc 78 @253.095s 0%: 0.032+3.3+0.46 ms clock, 0.26+0.24/2.6/2.4+3.6 ms cpu,
> 11->12->4 MB, 12 MB goal, 8 P
> gc 79 @253.109s 0%: 0.021+2.1+0.17 ms clock, 0.16+0.19/3.6/1.2+1.3 ms cpu,
> 9->9->4 MB, 10 MB goal, 8 P
> gc 80 @253.120s 0%: 0.022+2.8+2.2 ms clock, 0.17+0.27/4.8/0.006+18 ms cpu,
> 8->8->4 MB, 9 MB goal, 8 P
> gc 81 @253.138s 0%: 0.019+2.3+0.10 ms clock, 0.15+0.73/3.9/3.1+0.81 ms
> cpu, 9->9->5 MB, 10 MB goal, 8 P
>
> Heroku already reports a SW of 343 ms but I can't find it by manual
> inspection. I will download the logs later today and try to generate
> realistic load.
> What is the overhead of running like this, aside from the obvious extra
> logging?
> Are there any automatic tools to analyze these logs?
>
> lör 2 dec. 2017 kl 22:36 skrev Henrik Johansson :
>
>> I am sorry, I was unclear. The app uses very little ram but the
>> provisioned available memory is 512 MB.
>>
>> I will try to experiment with GC toggles as you suggest and report back.
>>
>> Thx!
>>
>> On Sat, Dec 2, 2017, 22:18 rlh via golang-nuts <
>> golang-nuts@googlegroups.com> wrote:
>>
>>> Hard telling what it going on. 35MB, even for 1 CPU, seems very small.
>>> Most modern system provision more than 1GB per HW thread though I've seen
>>> some provision as little as 512MB. GOGC (SetGCPercent) can be adjust so
>>> that the application uses more of the available RAM. Running with
>>> GODEBUG=gctrace=1 will give you a sense of the GC's view of the application.
>>>
>>> In any case these kinds of numbers, running on a real systems, and
>>> duplicatable on tip are worth filing an issue.
>>>
>>> On Saturday, December 2, 2017 at 3:02:30 AM UTC-5, Henrik Johansson
>>> wrote:

 Hi,

 I am befuddled by GC SW times on several seconds (seen 20s once) in the
 metrics page for our app. There are several things that are strange but
 perhaps I am misreading it. The same metrics page reports Max Total 35 MB
 out of which 1 MB s swap the rest RSS. The response times on the service is
 has 99% ~400 ms which is not good but 95% is ~120 ms usually.
 The app reloads an in memory cache as needed using atomic,Value as a
 holder and the size is no more than a few thousand at any given time.
 Basically a map with pointers to simple structs and lists with pointers
 to the same structs to allow for some simple access scenarios.

 Now I haven't profiled the app yet but even in a very pathologial case
 it seems as though the GC would be able to keep up easily with such little
 amount of memory being used. Granted this is a Standard 1x dyno but even so
 once the machiine is stopped the GC should be able to complete it's work in
 a very short time given the low used memory.

 Has anyone seen this as well? Could the Go metrics on Heroku simply
 report erroneously? Perhaps a couple of orders of magnitide?

 Cheers,

 --
>>> 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 https://groups.google.com/d/optout.
>>>
>>

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] Re: GC SW times on Heroku (Beta metrics)

2017-12-04 Thread Henrik Johansson
I have just added the gc tracing and it looks like this more or less all
the time:

gc 78 @253.095s 0%: 0.032+3.3+0.46 ms clock, 0.26+0.24/2.6/2.4+3.6 ms cpu,
11->12->4 MB, 12 MB goal, 8 P
gc 79 @253.109s 0%: 0.021+2.1+0.17 ms clock, 0.16+0.19/3.6/1.2+1.3 ms cpu,
9->9->4 MB, 10 MB goal, 8 P
gc 80 @253.120s 0%: 0.022+2.8+2.2 ms clock, 0.17+0.27/4.8/0.006+18 ms cpu,
8->8->4 MB, 9 MB goal, 8 P
gc 81 @253.138s 0%: 0.019+2.3+0.10 ms clock, 0.15+0.73/3.9/3.1+0.81 ms cpu,
9->9->5 MB, 10 MB goal, 8 P

Heroku already reports a SW of 343 ms but I can't find it by manual
inspection. I will download the logs later today and try to generate
realistic load.
What is the overhead of running like this, aside from the obvious extra
logging?
Are there any automatic tools to analyze these logs?

lör 2 dec. 2017 kl 22:36 skrev Henrik Johansson :

> I am sorry, I was unclear. The app uses very little ram but the
> provisioned available memory is 512 MB.
>
> I will try to experiment with GC toggles as you suggest and report back.
>
> Thx!
>
> On Sat, Dec 2, 2017, 22:18 rlh via golang-nuts <
> golang-nuts@googlegroups.com> wrote:
>
>> Hard telling what it going on. 35MB, even for 1 CPU, seems very small.
>> Most modern system provision more than 1GB per HW thread though I've seen
>> some provision as little as 512MB. GOGC (SetGCPercent) can be adjust so
>> that the application uses more of the available RAM. Running with
>> GODEBUG=gctrace=1 will give you a sense of the GC's view of the application.
>>
>> In any case these kinds of numbers, running on a real systems, and
>> duplicatable on tip are worth filing an issue.
>>
>> On Saturday, December 2, 2017 at 3:02:30 AM UTC-5, Henrik Johansson wrote:
>>>
>>> Hi,
>>>
>>> I am befuddled by GC SW times on several seconds (seen 20s once) in the
>>> metrics page for our app. There are several things that are strange but
>>> perhaps I am misreading it. The same metrics page reports Max Total 35 MB
>>> out of which 1 MB s swap the rest RSS. The response times on the service is
>>> has 99% ~400 ms which is not good but 95% is ~120 ms usually.
>>> The app reloads an in memory cache as needed using atomic,Value as a
>>> holder and the size is no more than a few thousand at any given time.
>>> Basically a map with pointers to simple structs and lists with pointers
>>> to the same structs to allow for some simple access scenarios.
>>>
>>> Now I haven't profiled the app yet but even in a very pathologial case
>>> it seems as though the GC would be able to keep up easily with such little
>>> amount of memory being used. Granted this is a Standard 1x dyno but even so
>>> once the machiine is stopped the GC should be able to complete it's work in
>>> a very short time given the low used memory.
>>>
>>> Has anyone seen this as well? Could the Go metrics on Heroku simply
>>> report erroneously? Perhaps a couple of orders of magnitide?
>>>
>>> Cheers,
>>>
>>> --
>> 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 https://groups.google.com/d/optout.
>>
>

-- 
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 https://groups.google.com/d/optout.


[go-nuts] Re: ssh session

2017-12-04 Thread hiltov
Yes I mean to pass that connection to another Go program.

On Tuesday, December 5, 2017 at 5:52:19 AM UTC+3, Jonathan Pittman wrote:
>
> Elaborate on what you mean by "another place." Do you just need multiple 
> sessions within your own program or do you need to pass that connection to 
> another program (e.g. a proxy command or shared socket connection)?
>
> Within your program, once you have dialed an ssh connection and have an 
> *ssh.Client, you can create multiple new sessions.  The ability to run 
> those sessions simultaneously may be limited by the MaxSessionLimit on the 
> host which limits the number of concurrent sessions per connection.  You 
> will generally be safe if you run them one after the other.
>
> On Monday, December 4, 2017 at 2:56:19 PM UTC-5, Alex Hiltov wrote:
>>
>> Could somebody explain how can I reconnect (reuse) already opened ssh 
>> connection in Go. I'm using x/crypto/ssh ssh.Dial function to dial a 
>> connection . Then I can start a new session/ run command but I need to use 
>> this opened  ss.dial connection from another place. How can i do this?
>>
>> Thanx
>> Alex
>>
>

-- 
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 https://groups.google.com/d/optout.


[go-nuts] swagger

2017-12-04 Thread Jérôme LAFORGE
In my previous projects, I used go-swagger successfully:
- to generate code (model) from swagger (still some little bugs sometimes)
- to generate swagger file from code based on godoc (you have to follow 
specific format of godoc. The document is not very clear imho) 

-- 
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 https://groups.google.com/d/optout.


[go-nuts] Re: ssh session

2017-12-04 Thread Jonathan Pittman
Elaborate on what you mean by "another place." Do you just need multiple 
sessions within your own program or do you need to pass that connection to 
another program (e.g. a proxy command or shared socket connection)?

Within your program, once you have dialed an ssh connection and have an 
*ssh.Client, you can create multiple new sessions.  The ability to run 
those sessions simultaneously may be limited by the MaxSessionLimit on the 
host which limits the number of concurrent sessions per connection.  You 
will generally be safe if you run them one after the other.

On Monday, December 4, 2017 at 2:56:19 PM UTC-5, Alex Hiltov wrote:
>
> Could somebody explain how can I reconnect (reuse) already opened ssh 
> connection in Go. I'm using x/crypto/ssh ssh.Dial function to dial a 
> connection . Then I can start a new session/ run command but I need to use 
> this opened  ss.dial connection from another place. How can i do this?
>
> Thanx
> Alex
>

-- 
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 https://groups.google.com/d/optout.


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

2017-12-04 Thread Chao Yuepan
implemented by goroutine per port, Thanks Ian

在 2017年11月29日星期三 UTC+8下午11:42:05,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 application is running at Linux and listen by TCP. 
> > 
> > My basic thought is starting multiple TCPListeners. One TCPListener per 
> port 
> > and one goroutine for each TCPListener. 
> > 
> > 
> > But what I want to know there are better solutions than this, for 
> example, 
> > using epoll/ underlying file descriptor? 
>
> The go runtime will use epoll internally.  Your Go code may as well 
> use multiple TCPListeners. 
>
> Ian 
>

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] corrupt stack?

2017-12-04 Thread Ian Lance Taylor
On Sun, Dec 3, 2017 at 6:42 PM,   wrote:
>
> i'm running go 1.8.3 on linux.  about 1 in ~10 billion calls (spread across
> many machines), i get
> a backtrace that looks like the following:
>
> panic: runtime error: invalid memory address or nil pointer dereference
> [signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x4c3406]
> goroutine 441026 [running]:
> bufio.(*Reader).ReadSlice(0x0, 0xa, 0x30, 0xc420256ec8, 0xc4201b9ef0,
> 0xc420315580, 0x0)
> #011/usr/lib/golang/src/bufio/bufio.go:316 +0x26
> bufio.(*Reader).ReadLine(0x0, 0xa1f378, 0x30, 0xc4201b9ef0, 0x30,
> 0xc4201b9ef0, 0x30)
> #011/usr/lib/golang/src/bufio/bufio.go:367 +0x37
> fakexpkg.(*Xpkg).tableParse(0x, 0x0, 0x0)
> <- HERE
> #011/builddir/build/BUILD/posthoc-1.1/src/fakexpkg/xpkg.go:175 +0x86
> created by fakexpkg.(*Xpkg).List
> #011/builddir/build/BUILD/posthoc-1.1/src/fakexpkg/xpkg.go:225 +0x2ac
>
> the code calling tableparse looks something like this.  no references to
> anything
> table at the end are kept in other places.
>
> ret := make(chan []*Info, 1)
> go x.tableParse(bufio.NewReader(outpipe), ret)
> table := <-ret
>
> other c programs that i run on these same machines do not core dump at all.
>
> since there is no use of the unsafe package anywhere in this program, i'm
> confused as to
> how the Xpkg receiver could be -1 unless something has gone wrong with the
> runtime.
> i feel like i must be missing something though, since it's never the layer
> below.
>
> does anyone have any idea what's going on here, or some hints on debugging
> this?

Assuming that the race detector doesn't report any problems, this is a
strange example of memory corruption: not only is the receiver pointer
invalid, the two arguments to the function are nil even though the
code fragment shows that that is not possible.  From your description
the problem is very very rare.  How much time and energy do you have
for experimentation?  If you have some, the first step is certainly to
try using Go 1.9, as various bugs have been fixed.  If it still
happens the same way, the next step is to try to reduce the program to
a self-contained example that you can share.  At a guess given that
three words appear to be corrupt, it may have something to do with the
way that goroutine arguments are saved.  I don't see any way that
could fail, but then this is a very rare problem.

Ian

-- 
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 https://groups.google.com/d/optout.


[go-nuts] Re: benchmark a remote arch

2017-12-04 Thread Dave Cheney
Yes, 

GOOS= GOARCH= go test -c 

will produce a binary for the target, the name by default will be the 
package's name, plus ".test"

Copy that to your target and run it

./$package.test -test.bench=.

On Tuesday, 5 December 2017 11:56:52 UTC+11, simon place wrote:
>
>
> is it possible, with the go tools, to build the benchmark executable, so i 
> could copy and run it remotely? (for any given os/arch)
>
>

-- 
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 https://groups.google.com/d/optout.


[go-nuts] Re: are interface calls to empty methods optimized away - so there is no function call overhead beyond the dereference/jump?

2017-12-04 Thread Dave Cheney


On Tuesday, 5 December 2017 12:19:29 UTC+11, simon place wrote:
>
> in a very similar vein, something i have been wondering about for a while 
> now;
>
> when an interface contains a pointer type, does Go double dereference or 
> conflate the pointers?
>

If the *type* of the value placed into the interface is pointer shaped then 
it value is used as is, if not, the address of the value is taken, and the 
address is used as the interface's value.
 

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] swagger

2017-12-04 Thread mattherman11
I haven't used either, but I've heard good things about go-swagger on the Go 
Time podcast .

-- 
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 https://groups.google.com/d/optout.


[go-nuts] Re: are interface calls to empty methods optimized away - so there is no function call overhead beyond the dereference/jump?

2017-12-04 Thread 'simon place' via golang-nuts
in a very similar vein, something i have been wondering about for a while 
now;

when an interface contains a pointer type, does Go double dereference or 
conflate the pointers?


-- 
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 https://groups.google.com/d/optout.


[go-nuts] understanding memory profile

2017-12-04 Thread Sangjin Lee
A couple of questions on understanding go pprof's memory profile...

When I list a certain function (with --alloc_objects), I see an allocation 
number associated with an import line mysteriously. I am pretty certain I 
can rule out any source line offset. For example,

(pprof) list foo
Total: 534804146
ROUTINE  (snip)
  24057960   27540717 (flat, cum)  5.15% of Total
 .  .  1:package protocol
 .  .  2:
 .  .  3:import (
  12092676   12092676  4:   "bytes"
 .  .  5:   "fmt"
 .  .  6:   "net/url"
 .  .  7:   "strconv"
 .  .  8:   "strings"
 .  .  9:   "time"
 .  . 10:   "unicode"
 .  . 11:)

Any idea how to interpret this?

In addition, is there a way to drill down further into exactly what type of 
memory allocation is contributing to the allocation when I list a function? 
The tree/web/pdf view doesn't break down further function names (only shows 
the boxes with what I believe is the individual allocation size). I'm kind 
of guessing from the line of code on what it is, but it'd be great if there 
is a way to track down exactly what type of memory allocation it is (string 
copy, map growth, byte allocation, etc.). For example,

(pprof) list add
Total: 534804146
ROUTINE  (snip)
  17248777   17248777 (flat, cum)  3.23% of Total
 .  .220: l *logger
 .  .221:}
 .  .222:
 .  .223:func (l *logger) add(data 
map[string]interface{}) {
 .  .224: if id := l.Id(); id != "" {
  17248777   17248777225: data[ID] = id
 .  .226: }
 .  .227:}
 .  .228:

where id is a string.

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] corrupt stack?

2017-12-04 Thread andrey mirtchovski
Erik, any chance you're hitting this?

https://github.com/golang/go/issues/20427

Related article discussing bad ram:
https://marcan.st/2017/12/debugging-an-evil-go-runtime-bug/

On Mon, Dec 4, 2017, 5:35 PM 'Keith Randall' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> package main
>
> // Convert an *A to a *B, using a data race.
> // Works for any types A and B.
> func cast(a *A) *B {
> var x interface{}
>
> go func() {
> for i := 0; i < 10; i++ {
> x = a
> }
> }()
> go func() {
> var b *B
> for i := 0; i < 10; i++ {
> x = b
> }
> }()
>
> for i := 0; i < 10; i++ {
> b, ok := x.(*B)
> if ok && b != nil {
> // Empty interfaces are 2 words, a type and a value.
> // We managed to read the type of b, but the value of a.
> return b
> }
> }
> panic("cast failed")
> }
>
> type A *int
> type B int
>
> func main() {
> var a *A = new(A)
> b := cast(a)
> *b = -1
> _ = **a // seg faults at address -1.
> }
>
>
> On Monday, December 4, 2017 at 4:57:42 AM UTC-8, Erik Quanstrom wrote:
>>
>> i should have mentioned the race detector found nothing.  jan, can you
>> give an example of a go program
>> setting a pointer to -1 without using unsafe?  this requires the gc to
>> have free'd something that is still live,
>> doesn't it?
>>
>> - erik
>>
>> On Monday, December 4, 2017 at 2:58:22 AM UTC-8, Peter Waller wrote:
>>>
>>> Some worthwhile reading:
>>> https://software.intel.com/en-us/blogs/2013/01/06/benign-data-races-what-could-possibly-go-wrong
>>>
>>> Races are important, and if your program has a race, otherwise
>>> impossible-seeming things can happen. First ruling out races is a
>>> worthwhile activity.
>>>
>>> In terms of debugging it, it's difficult, but it will help a lot if you
>>> can make it crash predictably. Moreso if you can share a minimum reproducer.
>>>
>>> When I've been in such a situation as yours, I've found that once I can
>>> get it to crash predictably, it is often a short path from there to a
>>> solution.
>>>
>>>
>>> On 4 December 2017 at 06:46,  wrote:
>>>
 a program not using unsafe cannot set a pointer to -1, even if there is
 a race, right?

 - erik


 On Sunday, December 3, 2017 at 10:20:44 PM UTC-8, Jan Mercl wrote:
>
> On Mon, Dec 4, 2017 at 7:03 AM  wrote:
>
> > does anyone have any idea what's going on here, or some hints on
> debugging this?
>
> What does the race detector say?
>
> --
>
> -j
>
 --
 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...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>>
>>> --
> 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 https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/d/optout.


[go-nuts] benchmark a remote arch

2017-12-04 Thread 'simon place' via golang-nuts

is it possible, with the go tools, to build the benchmark executable, so i 
could copy and run it remotely? (for any given os/arch)

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] corrupt stack?

2017-12-04 Thread 'Keith Randall' via golang-nuts
package main

// Convert an *A to a *B, using a data race.
// Works for any types A and B.
func cast(a *A) *B {
var x interface{}

go func() {
for i := 0; i < 10; i++ {
x = a
}
}()
go func() {
var b *B
for i := 0; i < 10; i++ {
x = b
}
}()

for i := 0; i < 10; i++ {
b, ok := x.(*B)
if ok && b != nil {
// Empty interfaces are 2 words, a type and a value.
// We managed to read the type of b, but the value of a.
return b
}
}
panic("cast failed")
}

type A *int
type B int

func main() {
var a *A = new(A)
b := cast(a)
*b = -1
_ = **a // seg faults at address -1.
}


On Monday, December 4, 2017 at 4:57:42 AM UTC-8, Erik Quanstrom wrote:
>
> i should have mentioned the race detector found nothing.  jan, can you 
> give an example of a go program
> setting a pointer to -1 without using unsafe?  this requires the gc to 
> have free'd something that is still live,
> doesn't it?
>
> - erik
>
> On Monday, December 4, 2017 at 2:58:22 AM UTC-8, Peter Waller wrote:
>>
>> Some worthwhile reading: 
>> https://software.intel.com/en-us/blogs/2013/01/06/benign-data-races-what-could-possibly-go-wrong
>>
>> Races are important, and if your program has a race, otherwise 
>> impossible-seeming things can happen. First ruling out races is a 
>> worthwhile activity.
>>
>> In terms of debugging it, it's difficult, but it will help a lot if you 
>> can make it crash predictably. Moreso if you can share a minimum reproducer.
>>
>> When I've been in such a situation as yours, I've found that once I can 
>> get it to crash predictably, it is often a short path from there to a 
>> solution.
>>
>>
>> On 4 December 2017 at 06:46,  wrote:
>>
>>> a program not using unsafe cannot set a pointer to -1, even if there is 
>>> a race, right?
>>>
>>> - erik
>>>
>>>
>>> On Sunday, December 3, 2017 at 10:20:44 PM UTC-8, Jan Mercl wrote:

 On Mon, Dec 4, 2017 at 7:03 AM  wrote:

 > does anyone have any idea what's going on here, or some hints on 
 debugging this?

 What does the race detector say?

 -- 

 -j

>>> -- 
>>> 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...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] os.remove is slow

2017-12-04 Thread Dan Kortschak
Have you tried os.RemoveAll("/var/spool/directory")?

https://golang.org/pkg/os/#RemoveAll

If that's slow, file an issue.

On Mon, 2017-12-04 at 09:41 -0800, gabejessfors...@gmail.com wrote:
> What takes 18 seconds in a perl command:
> perl -e 'for(<*>){((stat)[9]<(unlink))}'
> 
> is taking almost 8 minutes with the following code. Any ideas how I
> can 
> speed this up?
> 
> dir, err := os.Open("/var/spool/directory")
> if err != nil {
> fmt.Fprintf(w, "failed - " + err.Error())
> return
> }
> defer dir.Close()
> 
> 
> files, err := dir.Readdir(-1)
> if err != nil {
> fmt.Fprintf(w, "failed - " + err.Error())
> return
> }
> 
> for _, file := range files {
> if file.Name() == "." || file.Name() == ".." {
> continue
> }
> 
> os.Remove("/var/spool/directory/" + file.Name())
> }
> 
> 
> fmt.Fprintf(w, "success")
> 
> 

-- 
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 https://groups.google.com/d/optout.


[go-nuts] Traceroute

2017-12-04 Thread Camila Luísa
Hello everyone,

I'm new with go, so, I try to start with a simple traceroute. I found some 
examples in github. But they don't work correctly.
Attached is the code with a small change that I made to work, but still 
does not work correctly. The code works only in linux.
this is the link to the original code:

https://github.com/damnever/traceroute/blob/master/traceroute.go


-- 
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 https://groups.google.com/d/optout.


traceroute.go
Description: Binary data


[go-nuts] Re: Request for feedback: MIDI library for reading and writing SMF and live MIDI data

2017-12-04 Thread me
That Google group doesn't seem to exist.   ...Tim...

On Wednesday, July 19, 2017 at 3:27:33 AM UTC-7, meta keule wrote:
>
> Discussion/Google group: https://groups.google.com/forum/#!forum/gomidi
>

-- 
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 https://groups.google.com/d/optout.


[go-nuts] ssh session

2017-12-04 Thread hiltov
Could somebody explain how can I reconnect (reuse) already opened ssh 
connection in Go. I'm using x/crypto/ssh ssh.Dial function to dial a 
connection . Then I can start a new session/ run command but I need to use 
this opened  ss.dial connection from another place. How can i do this?

Thanx
Alex

-- 
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 https://groups.google.com/d/optout.


[go-nuts] Re: Calculation of the combinations between an unlimited number of slices

2017-12-04 Thread Fred
it seems that making a copy of the temp var, replacing :

temp = append(temp, c1)

by :

temp = append(temp, append([]int{}, c1...))

helps, but still unclear for me why the problem was only visible on slice 
4...

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] Re: os.remove is slow

2017-12-04 Thread Reto Brunner
But why? Why does it matter if you are in the same dir or not when you glob?

On Mon, Dec 4, 2017, 20:34 Gabriel Forster 
wrote:

> Ding ding ding! We have a winner! Thank you so much.  That made a huge
> difference. It is now running ~20 seconds.
>
> The key is being in the same directory.
>
>
> On Monday, December 4, 2017 at 2:17:03 PM UTC-5, Patrick Smith wrote:
>
>> Does it make a difference if you first change directory to
>> /var/spool/directory, then glob * and unlink the resulting filenames,
>> without prepending the directory?
>>
> On Mon, Dec 4, 2017 at 11:05 AM, Gabriel Forster 
>> wrote:
>>
> Readdirnames wasn't much better. Now using globbing and syscall.Unlink
>>> which take ~1minute 30seconds. It is much better, but still a long way from
>>> perl's sub-20 seconds.
>>>
>>> package main
>>>
>>> import (
>>> "fmt"
>>> "path/filepath"
>>> "syscall"
>>> )
>>>
>>> func main() {
>>>
>>> upperDirPattern := "/var/spool/directory/*"
>>> matches, err := filepath.Glob(upperDirPattern)
>>>
>>> if err != nil {
>>> fmt.Println(err)
>>> }
>>>
>>> for _, file := range matches {
>>> syscall.Unlink(file)
>>> }
>>> }
>>>
>>>
>>>
>>> On Monday, December 4, 2017 at 12:50:54 PM UTC-5, Gabriel Forster wrote:

 What takes 18 seconds in a perl command:
 perl -e 'for(<*>){((stat)[9]<(unlink))}'

 is taking almost 8 minutes with the following code. Any ideas how I can
 speed this up?

 dir, err := os.Open("/var/spool/directory")
 if err != nil {
 fmt.Fprintf(w, "failed - " + err.Error())
 return
 }
 defer dir.Close()


 files, err := dir.Readdir(-1)
 if err != nil {
 fmt.Fprintf(w, "failed - " + err.Error())
 return
 }

 for _, file := range files {
 if file.Name() == "." || file.Name() == ".." {
 continue
 }

 os.Remove("/var/spool/directory/" + file.Name())
 }


 fmt.Fprintf(w, "success")


 --
>>> 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...@googlegroups.com.
>>
>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> 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 https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] Re: os.remove is slow

2017-12-04 Thread Gabriel Forster
Ding ding ding! We have a winner! Thank you so much.  That made a huge 
difference. It is now running ~20 seconds.

The key is being in the same directory.

On Monday, December 4, 2017 at 2:17:03 PM UTC-5, Patrick Smith wrote:
>
> Does it make a difference if you first change directory to 
> /var/spool/directory, then glob * and unlink the resulting filenames, 
> without prepending the directory?
>
> On Mon, Dec 4, 2017 at 11:05 AM, Gabriel Forster  > wrote:
>
>> Readdirnames wasn't much better. Now using globbing and syscall.Unlink 
>> which take ~1minute 30seconds. It is much better, but still a long way from 
>> perl's sub-20 seconds.
>>
>> package main
>>
>> import (
>> "fmt"
>> "path/filepath"
>> "syscall"
>> )
>>
>> func main() {
>>
>> upperDirPattern := "/var/spool/directory/*"  
>> matches, err := filepath.Glob(upperDirPattern)
>>
>> if err != nil {
>> fmt.Println(err)
>> }
>> 
>> for _, file := range matches {
>> syscall.Unlink(file)
>> }
>> }
>>
>>
>>
>> On Monday, December 4, 2017 at 12:50:54 PM UTC-5, Gabriel Forster wrote:
>>>
>>> What takes 18 seconds in a perl command:
>>> perl -e 'for(<*>){((stat)[9]<(unlink))}'
>>>
>>> is taking almost 8 minutes with the following code. Any ideas how I can 
>>> speed this up?
>>>
>>> dir, err := os.Open("/var/spool/directory")
>>> if err != nil {
>>> fmt.Fprintf(w, "failed - " + err.Error())
>>> return
>>> }
>>> defer dir.Close()
>>>
>>>
>>> files, err := dir.Readdir(-1)
>>> if err != nil {
>>> fmt.Fprintf(w, "failed - " + err.Error())
>>> return
>>> }
>>>
>>> for _, file := range files {
>>> if file.Name() == "." || file.Name() == ".." {
>>> continue
>>> }
>>>
>>> os.Remove("/var/spool/directory/" + file.Name())
>>> }
>>>
>>>
>>> fmt.Fprintf(w, "success")
>>>
>>>
>>> -- 
>> 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...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] Re: os.remove is slow

2017-12-04 Thread Patrick Smith
Does it make a difference if you first change directory to
/var/spool/directory, then glob * and unlink the resulting filenames,
without prepending the directory?

On Mon, Dec 4, 2017 at 11:05 AM, Gabriel Forster 
wrote:

> Readdirnames wasn't much better. Now using globbing and syscall.Unlink
> which take ~1minute 30seconds. It is much better, but still a long way from
> perl's sub-20 seconds.
>
> package main
>
> import (
> "fmt"
> "path/filepath"
> "syscall"
> )
>
> func main() {
>
> upperDirPattern := "/var/spool/directory/*"
> matches, err := filepath.Glob(upperDirPattern)
>
> if err != nil {
> fmt.Println(err)
> }
>
> for _, file := range matches {
> syscall.Unlink(file)
> }
> }
>
>
>
> On Monday, December 4, 2017 at 12:50:54 PM UTC-5, Gabriel Forster wrote:
>>
>> What takes 18 seconds in a perl command:
>> perl -e 'for(<*>){((stat)[9]<(unlink))}'
>>
>> is taking almost 8 minutes with the following code. Any ideas how I can
>> speed this up?
>>
>> dir, err := os.Open("/var/spool/directory")
>> if err != nil {
>> fmt.Fprintf(w, "failed - " + err.Error())
>> return
>> }
>> defer dir.Close()
>>
>>
>> files, err := dir.Readdir(-1)
>> if err != nil {
>> fmt.Fprintf(w, "failed - " + err.Error())
>> return
>> }
>>
>> for _, file := range files {
>> if file.Name() == "." || file.Name() == ".." {
>> continue
>> }
>>
>> os.Remove("/var/spool/directory/" + file.Name())
>> }
>>
>>
>> fmt.Fprintf(w, "success")
>>
>>
>> --
> 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 https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/d/optout.


[go-nuts] Re: os.remove is slow

2017-12-04 Thread Gabriel Forster
Readdirnames wasn't much better. Now using globbing and syscall.Unlink 
which take ~1minute 30seconds. It is much better, but still a long way from 
perl's sub-20 seconds.

package main

import (
"fmt"
"path/filepath"
"syscall"
)

func main() {

upperDirPattern := "/var/spool/directory/*"  
matches, err := filepath.Glob(upperDirPattern)

if err != nil {
fmt.Println(err)
}

for _, file := range matches {
syscall.Unlink(file)
}
}



On Monday, December 4, 2017 at 12:50:54 PM UTC-5, Gabriel Forster wrote:
>
> What takes 18 seconds in a perl command:
> perl -e 'for(<*>){((stat)[9]<(unlink))}'
>
> is taking almost 8 minutes with the following code. Any ideas how I can 
> speed this up?
>
> dir, err := os.Open("/var/spool/directory")
> if err != nil {
> fmt.Fprintf(w, "failed - " + err.Error())
> return
> }
> defer dir.Close()
>
>
> files, err := dir.Readdir(-1)
> if err != nil {
> fmt.Fprintf(w, "failed - " + err.Error())
> return
> }
>
> for _, file := range files {
> if file.Name() == "." || file.Name() == ".." {
> continue
> }
>
> os.Remove("/var/spool/directory/" + file.Name())
> }
>
>
> fmt.Fprintf(w, "success")
>
>
>

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] swagger

2017-12-04 Thread Justin Israel
On Mon, Dec 4, 2017, 7:34 AM Keith Brown  wrote:

> I am trying to use golang and swagger but I am confused on what package I
> should use:
> There is: https://github.com/go-swagger/go-swagger or
> https://github.com/yvasiyarov/swagger
>
> Does anyone use Swagger with go and any tips would be much appreciated.
>

I've actually just started playing with these two projects for the first
time. The goal was to generate a swagger doc from my existing API and be
able to serve the spec as HTML.
So far I am seeing go-swagger being better. It has better notation for
defining the spec in your comments. I wasn't able to express that a single
api function could accept multiple content types via yvasiyarov/swagger


> --
> 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 https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/d/optout.


[go-nuts] Please take the 2017 Gopher Survey

2017-12-04 Thread Steve Francia
Gophers,

*We blogged this recently, but haven't started a thread here and want to
make sure that we reach as broad a group of Gophers as possible as to
provide accurate data. *

The Go project wants to hear from you! If you haven't already, please help
by participating in our annual survey.

Please take this 15-minute survey by Friday December 8th
https://goo.gl/n9M7SB

More details available at https://blog.golang.org/survey2017

Thanks to everyone who has or will shared their experiences with the Go
project.

Thanks,
Steve

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] Re: os.remove is slow

2017-12-04 Thread Justin Israel
On Tue, Dec 5, 2017, 7:13 AM Gabriel Forster 
wrote:

> As far as I understand, that perl line is by far the fastest way to delete
> files in linux.  We're talking over 500k files on hdd.
>

It may be the 500k stats that are killing you. From the looks of your code,
the stat seems unnecessary as you only use it to get the file name. Can you
switch to Readdirnames() and see how that goes?


> On Monday, December 4, 2017 at 12:50:54 PM UTC-5, Gabriel Forster wrote:
>
>> What takes 18 seconds in a perl command:
>> perl -e 'for(<*>){((stat)[9]<(unlink))}'
>>
>> is taking almost 8 minutes with the following code. Any ideas how I can
>> speed this up?
>>
>> dir, err := os.Open("/var/spool/directory")
>> if err != nil {
>> fmt.Fprintf(w, "failed - " + err.Error())
>> return
>> }
>> defer dir.Close()
>>
>>
>> files, err := dir.Readdir(-1)
>> if err != nil {
>> fmt.Fprintf(w, "failed - " + err.Error())
>> return
>> }
>>
>> for _, file := range files {
>> if file.Name() == "." || file.Name() == ".." {
>> continue
>> }
>>
>> os.Remove("/var/spool/directory/" + file.Name())
>> }
>>
>>
>> fmt.Fprintf(w, "success")
>>
>>
>> --
> 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 https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/d/optout.


[go-nuts] Re: os.remove is slow

2017-12-04 Thread Hotei
Gabriel - Thank you for reminding me that perl is a write-only language.  
It's been a few years since I had to deal with it.  How many files are we 
talking about and on what media?

On Monday, December 4, 2017 at 12:50:54 PM UTC-5, Gabriel Forster wrote:
>
> What takes 18 seconds in a perl command:
> perl -e 'for(<*>){((stat)[9]<(unlink))}'
>
> is taking almost 8 minutes with the following code. Any ideas how I can 
> speed this up?
>
> dir, err := os.Open("/var/spool/directory")
> if err != nil {
> fmt.Fprintf(w, "failed - " + err.Error())
> return
> }
> defer dir.Close()
>
>
> files, err := dir.Readdir(-1)
> if err != nil {
> fmt.Fprintf(w, "failed - " + err.Error())
> return
> }
>
> for _, file := range files {
> if file.Name() == "." || file.Name() == ".." {
> continue
> }
>
> os.Remove("/var/spool/directory/" + file.Name())
> }
>
>
> fmt.Fprintf(w, "success")
>
>
>

-- 
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 https://groups.google.com/d/optout.


[go-nuts] os.remove is slow

2017-12-04 Thread gabejessforster
What takes 18 seconds in a perl command:
perl -e 'for(<*>){((stat)[9]<(unlink))}'

is taking almost 8 minutes with the following code. Any ideas how I can 
speed this up?

dir, err := os.Open("/var/spool/directory")
if err != nil {
fmt.Fprintf(w, "failed - " + err.Error())
return
}
defer dir.Close()


files, err := dir.Readdir(-1)
if err != nil {
fmt.Fprintf(w, "failed - " + err.Error())
return
}

for _, file := range files {
if file.Name() == "." || file.Name() == ".." {
continue
}

os.Remove("/var/spool/directory/" + file.Name())
}


fmt.Fprintf(w, "success")


-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] corrupt stack?

2017-12-04 Thread David Anderson
Programs with a data race can do all kinds of things that seem incredibly
improbable to humans, because compilers assume that the program is
race-free and make optimizations that are unsafe in the presence of races.
See
https://software.intel.com/en-us/blogs/2013/01/06/benign-data-races-what-could-possibly-go-wrong
for a great writeup about this. It uses C++ for its examples, but the same
ideas apply to Go.

- Dave

On Sun, Dec 3, 2017 at 10:46 PM,  wrote:

> a program not using unsafe cannot set a pointer to -1, even if there is a
> race, right?
>
> - erik
>
>
> On Sunday, December 3, 2017 at 10:20:44 PM UTC-8, Jan Mercl wrote:
>>
>> On Mon, Dec 4, 2017 at 7:03 AM  wrote:
>>
>> > does anyone have any idea what's going on here, or some hints on
>> debugging this?
>>
>> What does the race detector say?
>>
>> --
>>
>> -j
>>
> --
> 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 https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/d/optout.


[go-nuts] Calculation of the combinations between an unlimited number of slices

2017-12-04 Thread fred . softwares
Hi !

I have made a recursive algorithm to compute all the combinations between 
an unlimited number of slices. The algorithm does good results for 2 and 3 
slices.

For example with 3 slices a,b,c :

a := []int{1,2}
b := []int{3,4}
c := []int{5,6}
final comb [[1 3 5] [1 3 6] [1 4 5] [1 4 6] [2 3 5] [2 3 6] [2 4 5] [2 4 
6]] // good





, but I have a strange bug with 4 slices : only the last element of the 
slice 4 is recorded.


a := []int{1,2}
b := []int{3,4}
c := []int{5,6}
d := []int{7,8,9}
final comb [[1 3 5 9] [1 3 5 9] [1 3 5 9] [1 3 6 9] [1 3 6 9] [1 3 6 9] [1 
4 5 9] [1 4 5 9]
[1 4 5 9] [1 4 6 9] [1 4 6 9] [1 4 6 9] [2 3 5 9] [2 3 5 9] [2 3 5 9] [2 3 
6 9] [2 3 6 9]
[2 3 6 9] [2 4 5 9] [2 4 5 9] [2 4 5 9] [2 4 6 9] [2 4 6 9] [2 4 6 9]] 
// bad result, the combination [1 3 5 7] and [1 3 5 8] are missing

The error occurs between these 2 steps
c1 := append(c, s)
temp = append(temp, c1)

when  c1 is appended to temp, 
i,j,k = 2, 0, 0 - temp = [[1 3 5 7]]

 [[1 3 5 7]] is replaced by [1 3 5 8] inside the loop and [1 3 5 7] 
combination is lost !
i,j,k =2, 0, 1 - temp = [[1 3 5 8] [1 3 5 8]]
i,j,k =2, 0, 2 - temp = [[1 3 5 9] [1 3 5 9] [1 3 5 9]]


Here is the algorithm. With 5 slices the results are good except for the 
slice 4 combinations. I did not found the bug, if you see it,  thank you 
for your help !

package main

import (
"fmt"
)

func main() {
a := []int{1,2}
b := []int{3,4}
c := []int{5,6}
d := []int{7,8,9}
//e := []int{1,2}   

seq := [][]int{a, b, c, d} // slice to combine with comb [[b1 b2] [c1 
c2 c3]]

fmt.Println("final comb ", combIntSlices(seq) )
}

// function to build the combinations
func combIntSlices(seq [][]int) (out [][]int) {

// fill combSeq with the first slice of seq
var combSeq [][]int // combSeq is the initial [][]int, for example 
[[1] [2] [3]]
for _, i := range seq[0] {
combSeq = append(combSeq, []int{i})
}

seq = seq[1:] // seq is the [][]slice to combine with combSeq [[4 
5] [6 7 8]]
fmt.Println(seq, len(seq))

// rec recursive funtion
var rec func(int, [][]int, [][]int)
rec = func(i int, seq, combSeq [][]int) {

var temp [][]int // temporary slice to append combinations

last := len(seq) - 1

fmt.Println(combSeq, "-", seq)
for j, c := range combSeq { // for each slice in combSeq slice
for k, s := range seq[i] { // append each element of the 
slice i in seq
c1 := append(c, s)
temp = append(temp, c1)
fmt.Println(i,j,k, "- temp =", temp, " c=", c)
}
combSeq = temp // at this step temp has recorded one round 
of combination
}
if i == last { // if the length of seq is reached, the solution 
is returned
out = combSeq
return
} else {
rec(i+1, seq, combSeq) // if the length of seq is not 
reached, rec is called to perform another step of combinations
}
}
rec(0, seq, combSeq) // start the first step of combinations
return out
}

-- 
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 https://groups.google.com/d/optout.


combin-5.go
Description: Binary data


Re: [go-nuts] Elphaba Chess

2017-12-04 Thread hughaguilar96


On Monday, December 4, 2017 at 7:11:09 AM UTC-7, Gerald wrote:
>
> On Sun, 3 Dec 2017 20:07:45 -0800 (PST), you wrote: 
>
> >I'll bet if Mozilla had used Go to write FireFox, rather than invent 
> their 
> >own language, Google would have done something to stop them. 
>
> You are aware that Google helps fund Firefox (through their agreement 
> to be the default search engine)? 
>

I was not aware of that.

I only recently started using FireFox. Previously I had used Google Chrome.
My new computer crashed after I installed Chrome and I was suspicious that 
Chrome caused this. 
Also, my old computer became very slow and I was suspicious of Chrome being 
the cause of this.
Because of these reasons, I switched to FireFox.

I had liked Chrome though. I especially liked the way that it could 
translate foreign-language web-pages automatically.
I needed that for this site: http://fforum.winglion.ru/index.php
FireFox doesn't seem to do this --- at least, I haven't figured out how to 
do it yet.

I should go back to using Chrome again. I'm not really sure that it was 
causing the problems with the slow-down on the old computer and crash on 
the new computer.
Foreign-language translation is very important to me. There are more 
Russian-speaking Forth programmers than English-speaking nowadays.
Also, the Russians are less fascinated by the ANS-Forth standard --- they 
aren't beholden to any American corporation --- they do their own thing.

Google Translate is a good thing --- communication between different 
nations and different cultures is very important. :-)

I want to switch over to Quark Forth --- the problem though is that most of 
the documentation is in Russian --- it seems to be better in some ways than 
the American offerings, and it is free.

-- 
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 https://groups.google.com/d/optout.


[go-nuts] Re: Should an empty append be an error ?

2017-12-04 Thread Tamás Gulácsi
And along these lines, `append(a, []int{}...)` - appending an empty slice - 
should be flagged too. Which would be a pain in the ass for a lot of use cases!

-- 
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 https://groups.google.com/d/optout.


[go-nuts] Re: Should an empty append be an error ?

2017-12-04 Thread 'Bryan Mills' via golang-nuts
The spec defines `append` as a variadic function, with a type of the form 

append(s S, x ...T) S  // T is the element type of S

Variadic functions, in general, accept zero or more parameters. (Consider 
fmt.Println().)

In order to reject empty appends, append would either have to have its own 
special type structure (not just a variadic function), or it would have to 
be of the form

append(s S, x T, xs ...T) S

The former would increase the complexity of the language spec for little 
benefit. The latter would break call sites that look like

foo = append(foo, bar...)

 
As Axel and Dave suggest, this would probably be reasonable for a linter 
(or cmd/vet) to warn about.


On Sunday, December 3, 2017 at 7:09:39 PM UTC-5, nz wrote:
>
> My point is that it should give an error or refuse to compile.
>
> On Sunday, 3 December 2017 15:10:42 UTC-8, Dave Cheney wrote:
>>
>> What is the error? This construct seems harmless.
>
>

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] Elphaba Chess

2017-12-04 Thread 'David Chase' via golang-nuts
On Sunday, December 3, 2017 at 1:57:58 AM UTC-5, Ian Lance Taylor wrote:
>
> On Sat, Dec 2, 2017 at 11:37 AM,   
> wrote: 
> > 
> > Google is not going to be happy if somebody uses Go to compete against 
> > Google. 
>
> I think that Go is a nice language, but it's not so nice that it would 
> make any difference whether a Google competitor used Go or used some 
> other language.  Google does not compete at the level of programming 
> language choice. 
>

No need for the subjunctive here.  Twitch, owned by (part of?) Amazon,
uses Go, and Twitch competes with some part of Youtube.  Twitch has been
the source of some interesting bugs that we have worked hard to fix, and
some of them we're still working on.  Rhys Hiltner (of Twitch) gave a nice
talk on how he figured out these bugs at GopherCon earlier this year.
My (work, Google-owned) laptop has a Twitch sticker on it.

Beyond that, see Ian's remarks about companies being rational-mostly,
and we've got some history of how other programming languages fared
with open source and/or standardization.  We're trying to only make
new mistakes.

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] Elphaba Chess

2017-12-04 Thread Gerald Henriksen
On Sun, 3 Dec 2017 20:07:45 -0800 (PST), you wrote:

>I'll bet if Mozilla had used Go to write FireFox, rather than invent their 
>own language, Google would have done something to stop them.

You are aware that Google helps fund Firefox (through their agreement
to be the default search engine)?

>By proprietary I didn't necessarily mean closed-source.
>I just meant that Google declares a crippleware version of Go to be the 
>Standard --- possibly pushing it through ANSI so it is written in stone.

And the community would simply ignore the standard - standards only
have meaning if the community agrees that they do.

>Even if there is an open-source version of Go that works well, it would 
>likely die out for lack of interest.

As previously mentioned, there is far too much code (and hence
business) running on Go now for it to die off.

>Being the Standard (with a capital 'S') carries a lot of weight.

No it doesn't.  Market share carries far more influence than a
standard, and the vast amount of Go software already written means the
existing version of Go is the "standard" regardless of what any
official body may say.

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] corrupt stack?

2017-12-04 Thread Jan Mercl
On Mon, Dec 4, 2017 at 1:57 PM  wrote:

> i should have mentioned the race detector found nothing. jan, can you
give an example of a go program
> setting a pointer to -1 without using unsafe? this requires the gc to
have free'd something that is still live,
> doesn't it?

See https://research.swtch.com/gorace, under the tiele "A Race".

I wanted to modify the example to produce the -1 pointer, which would be
rather easy, but to my surprise, the original unmodified code does no more
produce the fail (go version go1.9.2 linux/amd64).

That does not mean the principles discussed the rsc's blog post do no more
apply, it's just something now prevents the fail. But that's not the same
as a guarantee of it not happening.



-- 

-j

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] corrupt stack?

2017-12-04 Thread quanstro
i should have mentioned the race detector found nothing.  jan, can you give 
an example of a go program
setting a pointer to -1 without using unsafe?  this requires the gc to have 
free'd something that is still live,
doesn't it?

- erik

On Monday, December 4, 2017 at 2:58:22 AM UTC-8, Peter Waller wrote:
>
> Some worthwhile reading: 
> https://software.intel.com/en-us/blogs/2013/01/06/benign-data-races-what-could-possibly-go-wrong
>
> Races are important, and if your program has a race, otherwise 
> impossible-seeming things can happen. First ruling out races is a 
> worthwhile activity.
>
> In terms of debugging it, it's difficult, but it will help a lot if you 
> can make it crash predictably. Moreso if you can share a minimum reproducer.
>
> When I've been in such a situation as yours, I've found that once I can 
> get it to crash predictably, it is often a short path from there to a 
> solution.
>
>
> On 4 December 2017 at 06:46,  wrote:
>
>> a program not using unsafe cannot set a pointer to -1, even if there is a 
>> race, right?
>>
>> - erik
>>
>>
>> On Sunday, December 3, 2017 at 10:20:44 PM UTC-8, Jan Mercl wrote:
>>>
>>> On Mon, Dec 4, 2017 at 7:03 AM  wrote:
>>>
>>> > does anyone have any idea what's going on here, or some hints on 
>>> debugging this?
>>>
>>> What does the race detector say?
>>>
>>> -- 
>>>
>>> -j
>>>
>> -- 
>> 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...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 https://groups.google.com/d/optout.


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

2017-12-04 Thread Karan Chaudhary
Great find!

On Saturday, 2 December 2017 15:57:18 UTC+5:30, basti skalendudler wrote:
>
>
> 
> I finally found the problem!!!
>
> Since I am using a custom mux, I needed to register the pprof handler 
> funcs to my custom router
>
> router.HandlerFunc(http.MethodGet, "/debug/pprof/", pprof.Index)
> router.HandlerFunc(http.MethodGet, "/debug/pprof/cmdline", pprof.Cmdline)
> router.HandlerFunc(http.MethodGet, "/debug/pprof/profile", pprof.Profile)
> router.HandlerFunc(http.MethodGet, "/debug/pprof/symbol", pprof.Symbol)
> router.HandlerFunc(http.MethodGet, "/debug/pprof/trace", pprof.Trace)
> router.Handler(http.MethodGet, "/debug/pprof/goroutine", 
> pprof.Handler("goroutine"))
> router.Handler(http.MethodGet, "/debug/pprof/heap", pprof.Handler("heap"))
> router.Handler(http.MethodGet,"/debug/pprof/threadcreate", 
> pprof.Handler("threadcreate"))
> router.Handler(http.MethodGet,"/debug/pprof/block", pprof.Handler("block"))
>
> Then, I started my benchmark (go-wrk) and then I started the pprof tool 
> (go tool pprof http://localhost:4000/debug/pprof/heap)
>
>
> 
> After hitting "web", I was granted this wonderful graph: 
>
>
>
>
>
> Am Freitag, 1. Dezember 2017 18:52:21 UTC+1 schrieb basti skalendudler:
>>
>> Specifically, I wanted to see heap allocations generated by incoming 
>> requests, so I can optimize my handler functions
>>
>> I will write a more basic webserver example to see if I can produce the 
>> result I am expecting
>>
>> Am Donnerstag, 30. November 2017 14:39:56 UTC+1 schrieb Karan Chaudhary:
>>>
>>> Attaching png:
>>>
>>>
>>> 
>>>
>>>
>>> On Thursday, 30 November 2017 19:09:04 UTC+5:30, Karan Chaudhary wrote:

 Are you just trying to see how heap allocation can be seen using 
 debug/pprof?  

 Maybe you're allocating too less.  Try to allocate exponentialy.

 package main

 import (
 "log"
 "net/http"
 "time"

 _ "net/http/pprof"
 )

 func expalloc() {
 x := make([]int, 0)
 for i := 0; i < 10; i++ {
 x = append(x, i)
 x = append(x, x...)
 }

 time.Sleep(10 * time.Second)
 }

 func main() {
 go func() {
 log.Println(http.ListenAndServe("localhost:6060", nil))
 }()

 expalloc()

 }

 Allocations on my machine (reduce 50 to smaller number as the program 
 might go out of memory):


 




 On Wednesday, 29 November 2017 19:47:11 UTC+5:30, basti skalendudler 
 wrote:
>
> 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 
>> benchmark -> nothing changes
>>
>> Am Montag, 27. November 2017 04:37:48 UTC+1 schrieb Karan Chaudhary:
>>>
>>> From the top of my head,  shouldn't the benchmark be done when 
>>> traffic is being sent to the server and not before it is sent?
>>>
>>> On Sunday, 26 November 2017 00:11:40 UTC+5:30, basti skalendudler 
>>> wrote:

 Hey guiys, I posted a StackOF question two days ago, but so far 
 nobody was able to help me!

 I am trying to profile my web server I wrote, but my pprof does not 
 contain any data about the handler func.  
 I am using the httprouter package 
  by julienschmidt, 
 and want to simply benchmark one of my handlers and see the pprof 
 profile 
 for that. For the benchmarking, I am using go-wrk 
   

 I set up my web server and pprof like this:


  // Configure the server
  server := {
  Addr:":4000",
  Handler: router,
  }


  go func() {
  log.Println(http.ListenAndServe(":6060", nil))
  }()


  // Start the server
  err = server.ListenAndServe()
  if err != nil {
  panic(err)
  }


 The router is initialized like this:

   
   // Create the httprouter
  router := httprouter.New()
  // Register 

Re: [go-nuts] corrupt stack?

2017-12-04 Thread Peter Waller
Some worthwhile reading:
https://software.intel.com/en-us/blogs/2013/01/06/benign-data-races-what-could-possibly-go-wrong

Races are important, and if your program has a race, otherwise
impossible-seeming things can happen. First ruling out races is a
worthwhile activity.

In terms of debugging it, it's difficult, but it will help a lot if you can
make it crash predictably. Moreso if you can share a minimum reproducer.

When I've been in such a situation as yours, I've found that once I can get
it to crash predictably, it is often a short path from there to a solution.


On 4 December 2017 at 06:46,  wrote:

> a program not using unsafe cannot set a pointer to -1, even if there is a
> race, right?
>
> - erik
>
>
> On Sunday, December 3, 2017 at 10:20:44 PM UTC-8, Jan Mercl wrote:
>>
>> On Mon, Dec 4, 2017 at 7:03 AM  wrote:
>>
>> > does anyone have any idea what's going on here, or some hints on
>> debugging this?
>>
>> What does the race detector say?
>>
>> --
>>
>> -j
>>
> --
> 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 https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] corrupt stack?

2017-12-04 Thread Jan Mercl
If course it can.

On Mon, Dec 4, 2017, 07:46  wrote:

> a program not using unsafe cannot set a pointer to -1, even if there is a
> race, right?
>
> - erik
>
>
> On Sunday, December 3, 2017 at 10:20:44 PM UTC-8, Jan Mercl wrote:
>
>> On Mon, Dec 4, 2017 at 7:03 AM  wrote:
>>
>> > does anyone have any idea what's going on here, or some hints on
>> debugging this?
>>
>> What does the race detector say?
>>
>> --
>>
>> -j
>>
> --
> 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 https://groups.google.com/d/optout.
>
-- 

-j

-- 
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 https://groups.google.com/d/optout.


[go-nuts] How to add a GUI to your Golang app in 5 easy steps

2017-12-04 Thread Asticode
Hey guys,

I've just written a short article 

 
on how to add a GUI to your Golang app using astilectron 
 and I'm sharing it here: 
https://medium.com/@social_57971/how-to-add-a-gui-to-your-golang-app-in-5-easy-steps-c25c99d4d8e0.

Let me know what you think :)

Cheers

-- 
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 https://groups.google.com/d/optout.