Re: [go-nuts] Where is the middle of Brazil?

2019-11-30 Thread Liam
"considered making a T-shirt saying "answers rhetorical questions"

Thank you for the LOL :-)

On Saturday, November 30, 2019 at 5:57:32 PM UTC-8, Michael Jones wrote:
>
> Sigh. I overlooked the riddle and took it as a straight question. Typical 
> for me all my life. (once considered making a T-shirt saying "answers 
> rhetorical questions"). Mild chagrin here... (P.S. sorry for bad typing. 
> Keyboard's B and SHIFT keys are roken broken.)
>
> On Sat, Nov 30, 2019 at 5:48 PM andrey mirtchovski  > wrote:
>
>> i think JuciÊ wants us to crack the md5. i'm fresh off a CTF
>> competition so i don't have any more resources to throw at warming the
>> universe and increasing entropy, unfortunately...
>>
>> On Sat, Nov 30, 2019 at 6:43 PM Michael Jones > > wrote:
>> >
>> >
>> > My answer is this place.
>> > 14°35'03.5"S 53°03'51.3"W
>> > -14.584305, -53.064239
>> >
>> > Not an official national answer, just my own. (That said, I invented 
>> Google Earth's technology and was the CTO of Google's Geo team from its 
>> inception...so I have some minor street cred in such things. ;-)
>> >
>> > On Sat, Nov 30, 2019 at 5:30 PM JuciÊ Andrade > > wrote:
>> >>
>> >> When I was a kid I asked my teacher why my country capital had been 
>> moved from Rio de Janeiro to Brasilia. She said the reason was Brasilia is 
>> right in the middle of our territory, that way our president could take 
>> care of our entire country more effectively. I accepted that answer. Many 
>> years later, contemplating a map, I doubted Brasilia is right in the middle.
>> >>
>> >>
>> >> Where is the middle of Brazil?
>> >>
>> >>
>> >> MD5 SHA-1
>> >>
>> >> 
>> >>
>> >> 4c021557d057327f2977dd739b67da6b 
>> b3913154ca0c5f48f3555c536fc987322169e607 ihavetheanswer.txt
>> >>
>> >> --
>> >> 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 golan...@googlegroups.com .
>> >> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/850ccd64-5c85-4c91-9438-bd28c4320b8a%40googlegroups.com
>> .
>> >
>> >
>> >
>> > --
>> > Michael T. Jones
>> > michae...@gmail.com 
>> >
>> > --
>> > 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 golan...@googlegroups.com .
>> > To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/CALoEmQwBJudMkah7eWRG9mhfCLjuJM%2B42LGdnP1BEAayH57EiA%40mail.gmail.com
>> .
>>
>> -- 
>> 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 golan...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/CAK4xykVTe6avmw7%3Dn3WV6PEp2eh1MRN-E%3DVLLMCq3R1RA0PsLw%40mail.gmail.com
>> .
>>
>
>
> -- 
>
> *Michael T. jonesmichae...@gmail.com *
>

-- 
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 
https://groups.google.com/d/msgid/golang-nuts/a1bb63c1-f4ec-4945-996d-0d4c2e5bbc19%40googlegroups.com.


Re: [go-nuts] golang and -buildmode=pie

2019-11-30 Thread Ian Lance Taylor
On Fri, Nov 29, 2019 at 5:09 PM  wrote:
>
> while looking into how alpine linux builds golang I've found that is patches 
> it to make -buildmode=pie the default. I've tried to find why. I've managed 
> to find this thread
>
> 
> https://groups.google.com/forum/#!searchin/golang-nuts/pie|sort:date/golang-nuts/Jd9tlNc6jUE/Z9ldF6vPEAAJ
>
> which seems to conclude that there is very little benefit to use pie in 
> golang. But then I found anothor thread (this time github ticket)
>
> https://github.com/golang/go/issues/35192
>
> that decided to make pie default build mode for windows. If anyone would be 
> so kind to find some time, I have few questions:
>
> 1. Why just windows (and not linux)?

As you can see in the GitHub issue you cite, other Windows compilers
reportedly default to PIE.  The argument was that Go on Windows should
act like other compilers on Windows.

> 2. Is pie useful now even in go? (the first thread is from 2012-2014)

PIE makes certain kinds of attacks on programs significantly more
difficult.  Those attacks must first find a bug in the program,
typically an overflow of a buffer stored on the stack, which lets the
attacker modify the stack in some way.  If such a bug exists, using
PIE makes it harder to exploit the bug.  In Go it is very hard to
write a program that contains such a bug, much much harder than it is
in C.  Therefore, I would say that PIE is much less important for Go
than it is for C.  But it is possible with a fair amount of work to
write a Go program that contains such a bug.  And Go programs can call
C code, and it might be useful to use PIE to make it harder to exploit
any bugs in that C code.  So PIE is not completely useless for Go.

> 3. Quote from 
> https://github.com/golang/go/issues/35192#issuecomment-548028186 :
>
> > The bug says ASLR but really this is just about making a 
> position-independent binary. There are other reasons to have one of those 
> besides ASLR.
>
> what are those reasons?

PIE can be useful for systems like the memory sanitizer
(https://github.com/google/sanitizers/wiki/MemorySanitizer) which need
to allocate large amounts of memory, and need to know that the program
can avoid the memory addresses that MSan wants.

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcWtbn_Ysy%2BX0RwWntV0Z1j4F5BzUbk0x2aReQozdJCGtQ%40mail.gmail.com.


Re: [go-nuts] atomic.Add*() doesn't produce unique values

2019-11-30 Thread Liam
I wrote a less-sophisticated version of your test, then realized I'd 
misspent my time; all I needed was to change the atomic.Add*() to a 
mutex-protected counter, and see whether my app still failed; it did.

But since you took the trouble, I read your code, and would like to 
understand your collision detector. Could you explain this bit?

for _, v := range a {
  mask := byte(1 << (v & (8 - 1))) 
  index := v >> 3

  if tally[index]&mask != 0 { ... }
  ...
}

On Saturday, November 30, 2019 at 5:33:50 PM UTC-8, Michael Jones wrote:
>
> As a follow-up, some more timing:
>
> *47088064 atomic increments/sec (my original email above for heavy 
> synchronization conflict incrementing)*
>
> 142049067 atomic increments/sec when each goroutine has its own atomic 
> update target. (Not testing global synchronization/mutex, just the 
> overhead of congested vs not.)
>
> 426232527 ordinary "x++" increments in the workers.
>
> General idea to remember:
>
> Atomic increment is ~3x slower than simple add when uncontested.
> Highly contested atomic increment is ~3x closer than uncontested, 
> therefore ~9x-10x slower than simple add.
>
> 10x is not insignificant, but is nevertheless remarkable for a reliable 
> atomic operation. This was once, "back in the day", a remarkably expensive 
> operation, an a feat of genius to accomplish (Dekker's Algorithm 
> ). That it is now 
> just a number-of-fingers cycles is fantastic progress!
>
> On Sat, Nov 30, 2019 at 3:38 PM Michael Jones  > wrote:
>
>> Liam,
>>
>> I just wrote a little stress test program for you. Maybe it will make you 
>> less stressed. ;-)
>> https://play.golang.org/p/5_7Geyczd1V
>>
>> 4 CPU 2016 MacBook Pro:
>>
>> *celeste:atom mtj$ go run main.go*
>> *32 concurrent workers*
>> *128 batches of 1048576 atomic increments, 134217728 total increments*
>> *2.850 seconds elapsed, 47088064 atomic increments/sec*
>> *0 collisions*
>>
>>
>> 18 CPU 2019 iMacPro:
>>
>> *plum:atom mtj$ go run main.go*
>> *32 concurrent workers*
>> *128 batches of 1048576 atomic increments, 134217728 total increments*
>> *2.730 seconds elapsed, 49167382 atomic increments/sec*
>> *0 collisions*
>>
>>
>> Exhaustive demonstration is no proof, but changing the parameters here 
>> may increase your comfort.
>>
>> Michael
>>
>> On Sat, Nov 30, 2019 at 1:02 PM Robert Engels > > wrote:
>>
>>> If this was broken I think a lot of things would break. 
>>>
>>> On Nov 30, 2019, at 1:56 PM, Liam > 
>>> wrote:
>>>
>>> 
>>> The stress test for my app fails frequently with what looks like a 
>>> collision in atomic.AddUint64() results, so I wondered whether I had 
>>> misunderstood atomic-add.
>>>
>>> So far I can't reproduce it with a small program, so I've probably 
>>> misunderstood my app :-)
>>>
>>> On Friday, November 29, 2019 at 6:41:39 PM UTC-8, Kurtis Rader wrote:

 On Fri, Nov 29, 2019 at 6:21 PM Liam  wrote:

> Does atomic.AddInt32(&x, 1) always yield unique values for concurrent 
> callers?
>
> I'm guessing not, because (I think) I'm seeing that two callers get 
> x+2, neither gets x+1.
>

 That shouldn't happen, AFAICT. Can you share the code where the 
 incorrect behavior is occurring? Or, preferably, a simple reproducer 
 program?
   

> Is there a way to generate unique values with pkg atomic, or is a 
> mutex required?
>

 Keep in mind that atomic.AddInt32() has the usual two's-complement  
 overflow semantics. If all you want is a generation counter you really 
 should be using a uint32 and atomic.AddUint32(). Also, depending on your 
 preferences and performance considerations you might find it preferable to 
 use a channel that holds a single int, or small number of ints, that is 
 fed 
 by a producer goroutine and consumed by any context needing a uniq ID. 
 That 
 makes it easier to abstract the generation of "unique" ints so that they 
 satisfy other constraints (e.g., they must be even, odd, prime, etc.).

 -- 
 Kurtis Rader
 Caretaker of the exceptional canines Junior and Hank

>>> -- 
>>> 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 golan...@googlegroups.com .
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/golang-nuts/4f62dfff-6895-4aaa-9f0d-b635d5ba7ea7%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>>> -- 
>>> 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 golan...@googlegroups.com .
>>> To view this discussion on the web visit 
>>> https://

[go-nuts] Re: Where is the middle of Brazil?

2019-11-30 Thread Rodolfo Azevedo
Bixo vai dormir, isso né hora pra loucura não...  hehehehehe

Em sábado, 30 de novembro de 2019 21:30:33 UTC-4, JuciÊ Andrade escreveu:
>
> When I was a kid I asked my teacher why my country capital had been moved 
> from Rio de Janeiro to Brasilia. She said the reason was Brasilia is right 
> in the middle of our territory, that way our president could take care of 
> our entire country more effectively. I accepted that answer. Many years 
> later, contemplating a map, I doubted Brasilia is right in the middle.
>
>
> Where is the middle of Brazil?
>
>
> MD5 SHA-1
>
> --
>
> 4c021557d057327f2977dd739b67da6b b3913154ca0c5f48f3555c536fc987322169e607 
> ihavetheanswer.txt
>

-- 
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 
https://groups.google.com/d/msgid/golang-nuts/0ff45383-2d11-44f4-8f01-0e8011398d33%40googlegroups.com.


Re: [go-nuts] C variadic macro equivalent in Golang?

2019-11-30 Thread Bakul Shah
func PR(f string, a ...interface{}) {
if d { return }
fmt.Fprintf(os.Stderr, f, a...)
}

Add appropriate imports. 


> On Nov 30, 2019, at 12:08 PM, minfo...@arcor.de wrote:
> 
> C allows comma-separated argument lists via variadic macros. Whereas AFAIK 
> golang allows only variadic arguments of the same type.
> (Please excuse if I am wrong, I am considering myself a golang newbie)
> 
> C demo program that prints:   -- -- 1 and 1 1 and 1
> 
> // ## C variadic macro test
> 
> #include 
> 
> #define PR(...) if(df){printf(__VA_ARGS__);\
> if(ef)fprintf(stderr,__VA_ARGS__);}
> 
> // Flags
> int df=1, ef=1;
> 
> int main(void) {
>   PR("-- ");
>   PR("%d and %d ",df,ef);
> }
> 
> // ## End
> 
> How would one implement an equivalent PR(...) "function" in 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 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/e36eb032-ffbc-4b26-8c41-f76aa6dcdd00%40googlegroups.com
>  
> .

-- 
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 
https://groups.google.com/d/msgid/golang-nuts/37328E01-C01F-47EE-B4E1-CB7357CD2986%40bitblocks.com.


Re: [go-nuts] Where is the middle of Brazil?

2019-11-30 Thread Michael Jones
Sigh. I overlooked the riddle and took it as a straight question. Typical
for me all my life. (once considered making a T-shirt saying "answers
rhetorical questions"). Mild chagrin here... (P.S. sorry for bad typing.
Keyboard's B and SHIFT keys are roken broken.)

On Sat, Nov 30, 2019 at 5:48 PM andrey mirtchovski 
wrote:

> i think JuciÊ wants us to crack the md5. i'm fresh off a CTF
> competition so i don't have any more resources to throw at warming the
> universe and increasing entropy, unfortunately...
>
> On Sat, Nov 30, 2019 at 6:43 PM Michael Jones 
> wrote:
> >
> >
> > My answer is this place.
> > 14°35'03.5"S 53°03'51.3"W
> > -14.584305, -53.064239
> >
> > Not an official national answer, just my own. (That said, I invented
> Google Earth's technology and was the CTO of Google's Geo team from its
> inception...so I have some minor street cred in such things. ;-)
> >
> > On Sat, Nov 30, 2019 at 5:30 PM JuciÊ Andrade  wrote:
> >>
> >> When I was a kid I asked my teacher why my country capital had been
> moved from Rio de Janeiro to Brasilia. She said the reason was Brasilia is
> right in the middle of our territory, that way our president could take
> care of our entire country more effectively. I accepted that answer. Many
> years later, contemplating a map, I doubted Brasilia is right in the middle.
> >>
> >>
> >> Where is the middle of Brazil?
> >>
> >>
> >> MD5 SHA-1
> >>
> >> 
> >>
> >> 4c021557d057327f2977dd739b67da6b
> b3913154ca0c5f48f3555c536fc987322169e607 ihavetheanswer.txt
> >>
> >> --
> >> 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
> https://groups.google.com/d/msgid/golang-nuts/850ccd64-5c85-4c91-9438-bd28c4320b8a%40googlegroups.com
> .
> >
> >
> >
> > --
> > Michael T. Jones
> > michael.jo...@gmail.com
> >
> > --
> > 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
> https://groups.google.com/d/msgid/golang-nuts/CALoEmQwBJudMkah7eWRG9mhfCLjuJM%2B42LGdnP1BEAayH57EiA%40mail.gmail.com
> .
>
> --
> 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
> https://groups.google.com/d/msgid/golang-nuts/CAK4xykVTe6avmw7%3Dn3WV6PEp2eh1MRN-E%3DVLLMCq3R1RA0PsLw%40mail.gmail.com
> .
>


-- 

*Michael T. jonesmichael.jo...@gmail.com *

-- 
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 
https://groups.google.com/d/msgid/golang-nuts/CALoEmQxffWUG6-mTUojvCFan5vu7uCTu_Npp0%3DOaH7xmSZUb0w%40mail.gmail.com.


Re: [go-nuts] Where is the middle of Brazil?

2019-11-30 Thread andrey mirtchovski
i think JuciÊ wants us to crack the md5. i'm fresh off a CTF
competition so i don't have any more resources to throw at warming the
universe and increasing entropy, unfortunately...

On Sat, Nov 30, 2019 at 6:43 PM Michael Jones  wrote:
>
>
> My answer is this place.
> 14°35'03.5"S 53°03'51.3"W
> -14.584305, -53.064239
>
> Not an official national answer, just my own. (That said, I invented Google 
> Earth's technology and was the CTO of Google's Geo team from its 
> inception...so I have some minor street cred in such things. ;-)
>
> On Sat, Nov 30, 2019 at 5:30 PM JuciÊ Andrade  wrote:
>>
>> When I was a kid I asked my teacher why my country capital had been moved 
>> from Rio de Janeiro to Brasilia. She said the reason was Brasilia is right 
>> in the middle of our territory, that way our president could take care of 
>> our entire country more effectively. I accepted that answer. Many years 
>> later, contemplating a map, I doubted Brasilia is right in the middle.
>>
>>
>> Where is the middle of Brazil?
>>
>>
>> MD5 SHA-1
>>
>> 
>>
>> 4c021557d057327f2977dd739b67da6b b3913154ca0c5f48f3555c536fc987322169e607 
>> ihavetheanswer.txt
>>
>> --
>> 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 
>> https://groups.google.com/d/msgid/golang-nuts/850ccd64-5c85-4c91-9438-bd28c4320b8a%40googlegroups.com.
>
>
>
> --
> Michael T. Jones
> michael.jo...@gmail.com
>
> --
> 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 
> https://groups.google.com/d/msgid/golang-nuts/CALoEmQwBJudMkah7eWRG9mhfCLjuJM%2B42LGdnP1BEAayH57EiA%40mail.gmail.com.

-- 
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 
https://groups.google.com/d/msgid/golang-nuts/CAK4xykVTe6avmw7%3Dn3WV6PEp2eh1MRN-E%3DVLLMCq3R1RA0PsLw%40mail.gmail.com.


Re: [go-nuts] Where is the middle of Brazil?

2019-11-30 Thread Michael Jones
My answer is this place

.
14°35'03.5"S 53°03'51.3"W
-14.584305, -53.064239

Not an official national answer, just my own. (That said, I invented Google
Earth's technology and was the CTO of Google's Geo team from its
inception...so I have some minor street cred in such things. ;-)

On Sat, Nov 30, 2019 at 5:30 PM JuciÊ Andrade  wrote:

> When I was a kid I asked my teacher why my country capital had been moved
> from Rio de Janeiro to Brasilia. She said the reason was Brasilia is right
> in the middle of our territory, that way our president could take care of
> our entire country more effectively. I accepted that answer. Many years
> later, contemplating a map, I doubted Brasilia is right in the middle.
>
>
> Where is the middle of Brazil?
>
>
> MD5 SHA-1
>
> --
>
> 4c021557d057327f2977dd739b67da6b b3913154ca0c5f48f3555c536fc987322169e607
> ihavetheanswer.txt
>
> --
> 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
> https://groups.google.com/d/msgid/golang-nuts/850ccd64-5c85-4c91-9438-bd28c4320b8a%40googlegroups.com
> 
> .
>


-- 

*Michael T. jonesmichael.jo...@gmail.com *

-- 
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 
https://groups.google.com/d/msgid/golang-nuts/CALoEmQwBJudMkah7eWRG9mhfCLjuJM%2B42LGdnP1BEAayH57EiA%40mail.gmail.com.


Re: [go-nuts] atomic.Add*() doesn't produce unique values

2019-11-30 Thread Michael Jones
As a follow-up, some more timing:

*47088064 atomic increments/sec (my original email above for heavy
synchronization conflict incrementing)*

142049067 atomic increments/sec when each goroutine has its own atomic
update target. (Not testing global synchronization/mutex, just the
overhead of congested vs not.)

426232527 ordinary "x++" increments in the workers.

General idea to remember:

Atomic increment is ~3x slower than simple add when uncontested.
Highly contested atomic increment is ~3x closer than uncontested, therefore
~9x-10x slower than simple add.

10x is not insignificant, but is nevertheless remarkable for a reliable
atomic operation. This was once, "back in the day", a remarkably expensive
operation, an a feat of genius to accomplish (Dekker's Algorithm
). That it is now just
a number-of-fingers cycles is fantastic progress!

On Sat, Nov 30, 2019 at 3:38 PM Michael Jones 
wrote:

> Liam,
>
> I just wrote a little stress test program for you. Maybe it will make you
> less stressed. ;-)
> https://play.golang.org/p/5_7Geyczd1V
>
> 4 CPU 2016 MacBook Pro:
>
> *celeste:atom mtj$ go run main.go*
> *32 concurrent workers*
> *128 batches of 1048576 atomic increments, 134217728 total increments*
> *2.850 seconds elapsed, 47088064 atomic increments/sec*
> *0 collisions*
>
>
> 18 CPU 2019 iMacPro:
>
> *plum:atom mtj$ go run main.go*
> *32 concurrent workers*
> *128 batches of 1048576 atomic increments, 134217728 total increments*
> *2.730 seconds elapsed, 49167382 atomic increments/sec*
> *0 collisions*
>
>
> Exhaustive demonstration is no proof, but changing the parameters here may
> increase your comfort.
>
> Michael
>
> On Sat, Nov 30, 2019 at 1:02 PM Robert Engels 
> wrote:
>
>> If this was broken I think a lot of things would break.
>>
>> On Nov 30, 2019, at 1:56 PM, Liam  wrote:
>>
>> 
>> The stress test for my app fails frequently with what looks like a
>> collision in atomic.AddUint64() results, so I wondered whether I had
>> misunderstood atomic-add.
>>
>> So far I can't reproduce it with a small program, so I've probably
>> misunderstood my app :-)
>>
>> On Friday, November 29, 2019 at 6:41:39 PM UTC-8, Kurtis Rader wrote:
>>>
>>> On Fri, Nov 29, 2019 at 6:21 PM Liam  wrote:
>>>
 Does atomic.AddInt32(&x, 1) always yield unique values for concurrent
 callers?

 I'm guessing not, because (I think) I'm seeing that two callers get
 x+2, neither gets x+1.

>>>
>>> That shouldn't happen, AFAICT. Can you share the code where the
>>> incorrect behavior is occurring? Or, preferably, a simple reproducer
>>> program?
>>>
>>>
 Is there a way to generate unique values with pkg atomic, or is a mutex
 required?

>>>
>>> Keep in mind that atomic.AddInt32() has the usual two's-complement
>>> overflow semantics. If all you want is a generation counter you really
>>> should be using a uint32 and atomic.AddUint32(). Also, depending on your
>>> preferences and performance considerations you might find it preferable to
>>> use a channel that holds a single int, or small number of ints, that is fed
>>> by a producer goroutine and consumed by any context needing a uniq ID. That
>>> makes it easier to abstract the generation of "unique" ints so that they
>>> satisfy other constraints (e.g., they must be even, odd, prime, etc.).
>>>
>>> --
>>> Kurtis Rader
>>> Caretaker of the exceptional canines Junior and Hank
>>>
>> --
>> 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
>> https://groups.google.com/d/msgid/golang-nuts/4f62dfff-6895-4aaa-9f0d-b635d5ba7ea7%40googlegroups.com
>> 
>> .
>>
>> --
>> 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
>> https://groups.google.com/d/msgid/golang-nuts/C7B99DEA-D183-44EF-9EDA-0B1841AB9DE5%40ix.netcom.com
>> 
>> .
>>
>
>
> --
>
> *Michael T. jonesmichael.jo...@gmail.com *
>


-- 

*Michael T. jonesmichael.jo...@gmail.com *

-- 
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 
https://groups.google.com/d/msgid/golang-nuts/CALoEmQzMdG%2BVavTK1Eqg2LS1tPVRn3GbS7Cgv22UxpVofQM3uw

[go-nuts] Where is the middle of Brazil?

2019-11-30 Thread JuciÊ Andrade


When I was a kid I asked my teacher why my country capital had been moved 
from Rio de Janeiro to Brasilia. She said the reason was Brasilia is right 
in the middle of our territory, that way our president could take care of 
our entire country more effectively. I accepted that answer. Many years 
later, contemplating a map, I doubted Brasilia is right in the middle.


Where is the middle of Brazil?


MD5 SHA-1

--

4c021557d057327f2977dd739b67da6b b3913154ca0c5f48f3555c536fc987322169e607 
ihavetheanswer.txt

-- 
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 
https://groups.google.com/d/msgid/golang-nuts/850ccd64-5c85-4c91-9438-bd28c4320b8a%40googlegroups.com.


Re: [go-nuts] C variadic macro equivalent in Golang?

2019-11-30 Thread Michael Jones
You might refer to...

https://blog.learngoprogramming.com/golang-variadic-funcs-how-to-patterns-369408f19085

...to better appreciate Robert's advice. As he suggested, a variadic Go
function accepting a slice of the special, magic "empty interface" type
("interface{}") can indeed do anything. The downside is that you have to do
the anything yourself...validating the types of the unknown and mysterious
arguments at run time rather than the compiler validating it for you at
compile time.

For moral support, fmt.Printf is a popular example of this API structure.

On Sat, Nov 30, 2019 at 4:20 PM  wrote:

> Thanks, but then you would have to define the interface beforehand for any
> argument type. And there are a lot:
> format strings, strings, characters, integers of different size,
> floating-pont numbers, file-ids
>
> Meanwhile I found this discussion:
> https://github.com/golang/go/issues/18605
> which hints that comma-separated variadic arguments might come with Go 2.x
> in some unknown future.
>
>
> Am Samstag, 30. November 2019 22:00:52 UTC+1 schrieb Robert Engels:
>
>> Make the type interface{} and you can pass anything and use reflect
>>
>> On Nov 30, 2019, at 2:08 PM, minf...@arcor.de wrote:
>>
>> 
>> C allows comma-separated argument lists via variadic macros. Whereas
>> AFAIK golang allows only variadic arguments of the same type.
>> (Please excuse if I am wrong, I am considering myself a golang newbie)
>>
>> C demo program that prints:   -- -- 1 and 1 1 and 1
>>
>> // ## C variadic macro test
>>
>> #include 
>>
>> #define PR(...) if(df){printf(__VA_ARGS__);\
>> if(ef)fprintf(stderr,__VA_ARGS__);}
>>
>> // Flags
>> int df=1, ef=1;
>>
>> int main(void) {
>>   PR("-- ");
>>   PR("%d and %d ",df,ef);
>> }
>>
>> // ## End
>>
>> How would one implement an equivalent PR(...) "function" in 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 golan...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/golang-nuts/e36eb032-ffbc-4b26-8c41-f76aa6dcdd00%40googlegroups.com
>> 
>> .
>>
>> --
> 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
> https://groups.google.com/d/msgid/golang-nuts/181a2df8-f5a2-4a35-9d34-6645d2b1356a%40googlegroups.com
> 
> .
>


-- 

*Michael T. jonesmichael.jo...@gmail.com *

-- 
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 
https://groups.google.com/d/msgid/golang-nuts/CALoEmQxDG%2BSXeatp9CRB9O1x6woiGoHsFFYFrxmMaXktYWzpsg%40mail.gmail.com.


Re: [go-nuts] C variadic macro equivalent in Golang?

2019-11-30 Thread minforth
Thanks, but then you would have to define the interface beforehand for any 
argument type. And there are a lot:
format strings, strings, characters, integers of different size, 
floating-pont numbers, file-ids

Meanwhile I found this discussion:
https://github.com/golang/go/issues/18605
which hints that comma-separated variadic arguments might come with Go 2.x 
in some unknown future.


Am Samstag, 30. November 2019 22:00:52 UTC+1 schrieb Robert Engels:

> Make the type interface{} and you can pass anything and use reflect
>
> On Nov 30, 2019, at 2:08 PM, minf...@arcor.de  wrote:
>
> 
> C allows comma-separated argument lists via variadic macros. Whereas AFAIK 
> golang allows only variadic arguments of the same type.
> (Please excuse if I am wrong, I am considering myself a golang newbie)
>
> C demo program that prints:   -- -- 1 and 1 1 and 1
>
> // ## C variadic macro test
>
> #include 
>
> #define PR(...) if(df){printf(__VA_ARGS__);\
> if(ef)fprintf(stderr,__VA_ARGS__);}
>
> // Flags
> int df=1, ef=1;
>
> int main(void) {
>   PR("-- ");
>   PR("%d and %d ",df,ef);
> }
>
> // ## End
>
> How would one implement an equivalent PR(...) "function" in 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 golan...@googlegroups.com .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/e36eb032-ffbc-4b26-8c41-f76aa6dcdd00%40googlegroups.com
>  
> 
> .
>
>

-- 
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 
https://groups.google.com/d/msgid/golang-nuts/181a2df8-f5a2-4a35-9d34-6645d2b1356a%40googlegroups.com.


Re: [go-nuts] atomic.Add*() doesn't produce unique values

2019-11-30 Thread Michael Jones
Liam,

I just wrote a little stress test program for you. Maybe it will make you
less stressed. ;-)
https://play.golang.org/p/5_7Geyczd1V

4 CPU 2016 MacBook Pro:

*celeste:atom mtj$ go run main.go*
*32 concurrent workers*
*128 batches of 1048576 atomic increments, 134217728 total increments*
*2.850 seconds elapsed, 47088064 atomic increments/sec*
*0 collisions*


18 CPU 2019 iMacPro:

*plum:atom mtj$ go run main.go*
*32 concurrent workers*
*128 batches of 1048576 atomic increments, 134217728 total increments*
*2.730 seconds elapsed, 49167382 atomic increments/sec*
*0 collisions*


Exhaustive demonstration is no proof, but changing the parameters here may
increase your comfort.

Michael

On Sat, Nov 30, 2019 at 1:02 PM Robert Engels  wrote:

> If this was broken I think a lot of things would break.
>
> On Nov 30, 2019, at 1:56 PM, Liam  wrote:
>
> 
> The stress test for my app fails frequently with what looks like a
> collision in atomic.AddUint64() results, so I wondered whether I had
> misunderstood atomic-add.
>
> So far I can't reproduce it with a small program, so I've probably
> misunderstood my app :-)
>
> On Friday, November 29, 2019 at 6:41:39 PM UTC-8, Kurtis Rader wrote:
>>
>> On Fri, Nov 29, 2019 at 6:21 PM Liam  wrote:
>>
>>> Does atomic.AddInt32(&x, 1) always yield unique values for concurrent
>>> callers?
>>>
>>> I'm guessing not, because (I think) I'm seeing that two callers get x+2,
>>> neither gets x+1.
>>>
>>
>> That shouldn't happen, AFAICT. Can you share the code where the incorrect
>> behavior is occurring? Or, preferably, a simple reproducer program?
>>
>>
>>> Is there a way to generate unique values with pkg atomic, or is a mutex
>>> required?
>>>
>>
>> Keep in mind that atomic.AddInt32() has the usual two's-complement
>> overflow semantics. If all you want is a generation counter you really
>> should be using a uint32 and atomic.AddUint32(). Also, depending on your
>> preferences and performance considerations you might find it preferable to
>> use a channel that holds a single int, or small number of ints, that is fed
>> by a producer goroutine and consumed by any context needing a uniq ID. That
>> makes it easier to abstract the generation of "unique" ints so that they
>> satisfy other constraints (e.g., they must be even, odd, prime, etc.).
>>
>> --
>> Kurtis Rader
>> Caretaker of the exceptional canines Junior and Hank
>>
> --
> 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
> https://groups.google.com/d/msgid/golang-nuts/4f62dfff-6895-4aaa-9f0d-b635d5ba7ea7%40googlegroups.com
> 
> .
>
> --
> 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
> https://groups.google.com/d/msgid/golang-nuts/C7B99DEA-D183-44EF-9EDA-0B1841AB9DE5%40ix.netcom.com
> 
> .
>


-- 

*Michael T. jonesmichael.jo...@gmail.com *

-- 
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 
https://groups.google.com/d/msgid/golang-nuts/CALoEmQxm4LHW4n5Gs223X2UzVQ0QqBD6ZAx48_jYwve-QjXwmg%40mail.gmail.com.


Re: [go-nuts] atomic.Add*() doesn't produce unique values

2019-11-30 Thread Robert Engels
If this was broken I think a lot of things would break. 

> On Nov 30, 2019, at 1:56 PM, Liam  wrote:
> 
> 
> The stress test for my app fails frequently with what looks like a collision 
> in atomic.AddUint64() results, so I wondered whether I had misunderstood 
> atomic-add.
> 
> So far I can't reproduce it with a small program, so I've probably 
> misunderstood my app :-)
> 
>> On Friday, November 29, 2019 at 6:41:39 PM UTC-8, Kurtis Rader wrote:
>>> On Fri, Nov 29, 2019 at 6:21 PM Liam  wrote:
>> 
>>> Does atomic.AddInt32(&x, 1) always yield unique values for concurrent 
>>> callers?
>>> 
>>> I'm guessing not, because (I think) I'm seeing that two callers get x+2, 
>>> neither gets x+1.
>> 
>> That shouldn't happen, AFAICT. Can you share the code where the incorrect 
>> behavior is occurring? Or, preferably, a simple reproducer program?
>>   
>>> Is there a way to generate unique values with pkg atomic, or is a mutex 
>>> required?
>> 
>> Keep in mind that atomic.AddInt32() has the usual two's-complement  overflow 
>> semantics. If all you want is a generation counter you really should be 
>> using a uint32 and atomic.AddUint32(). Also, depending on your preferences 
>> and performance considerations you might find it preferable to use a channel 
>> that holds a single int, or small number of ints, that is fed by a producer 
>> goroutine and consumed by any context needing a uniq ID. That makes it 
>> easier to abstract the generation of "unique" ints so that they satisfy 
>> other constraints (e.g., they must be even, odd, prime, etc.).
>> 
>> -- 
>> Kurtis Rader
>> Caretaker of the exceptional canines Junior and Hank
> 
> -- 
> 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 
> https://groups.google.com/d/msgid/golang-nuts/4f62dfff-6895-4aaa-9f0d-b635d5ba7ea7%40googlegroups.com.

-- 
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 
https://groups.google.com/d/msgid/golang-nuts/C7B99DEA-D183-44EF-9EDA-0B1841AB9DE5%40ix.netcom.com.


Re: [go-nuts] C variadic macro equivalent in Golang?

2019-11-30 Thread Robert Engels
Make the type interface{} and you can pass anything and use reflect

> On Nov 30, 2019, at 2:08 PM, minfo...@arcor.de wrote:
> 
> 
> C allows comma-separated argument lists via variadic macros. Whereas AFAIK 
> golang allows only variadic arguments of the same type.
> (Please excuse if I am wrong, I am considering myself a golang newbie)
> 
> C demo program that prints:   -- -- 1 and 1 1 and 1
> 
> // ## C variadic macro test
> 
> #include 
> 
> #define PR(...) if(df){printf(__VA_ARGS__);\
> if(ef)fprintf(stderr,__VA_ARGS__);}
> 
> // Flags
> int df=1, ef=1;
> 
> int main(void) {
>   PR("-- ");
>   PR("%d and %d ",df,ef);
> }
> 
> // ## End
> 
> How would one implement an equivalent PR(...) "function" in 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/e36eb032-ffbc-4b26-8c41-f76aa6dcdd00%40googlegroups.com.

-- 
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 
https://groups.google.com/d/msgid/golang-nuts/E0C24B80-31F4-4A6C-AEAD-DB0FA533C595%40ix.netcom.com.


[go-nuts] C variadic macro equivalent in Golang?

2019-11-30 Thread minforth
C allows comma-separated argument lists via variadic macros. Whereas AFAIK 
golang allows only variadic arguments of the same type.
(Please excuse if I am wrong, I am considering myself a golang newbie)

C demo program that prints:   -- -- 1 and 1 1 and 1

// ## C variadic macro test

#include 

#define PR(...) if(df){printf(__VA_ARGS__);\
if(ef)fprintf(stderr,__VA_ARGS__);}

// Flags
int df=1, ef=1;

int main(void) {
  PR("-- ");
  PR("%d and %d ",df,ef);
}

// ## End

How would one implement an equivalent PR(...) "function" in 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e36eb032-ffbc-4b26-8c41-f76aa6dcdd00%40googlegroups.com.


Re: [go-nuts] atomic.Add*() doesn't produce unique values

2019-11-30 Thread Liam
The stress test for my app fails frequently with what looks like a 
collision in atomic.AddUint64() results, so I wondered whether I had 
misunderstood atomic-add.

So far I can't reproduce it with a small program, so I've probably 
misunderstood my app :-)

On Friday, November 29, 2019 at 6:41:39 PM UTC-8, Kurtis Rader wrote:
>
> On Fri, Nov 29, 2019 at 6:21 PM Liam > 
> wrote:
>
>> Does atomic.AddInt32(&x, 1) always yield unique values for concurrent 
>> callers?
>>
>> I'm guessing not, because (I think) I'm seeing that two callers get x+2, 
>> neither gets x+1.
>>
>
> That shouldn't happen, AFAICT. Can you share the code where the incorrect 
> behavior is occurring? Or, preferably, a simple reproducer program?
>   
>
>> Is there a way to generate unique values with pkg atomic, or is a mutex 
>> required?
>>
>
> Keep in mind that atomic.AddInt32() has the usual two's-complement  
> overflow semantics. If all you want is a generation counter you really 
> should be using a uint32 and atomic.AddUint32(). Also, depending on your 
> preferences and performance considerations you might find it preferable to 
> use a channel that holds a single int, or small number of ints, that is fed 
> by a producer goroutine and consumed by any context needing a uniq ID. That 
> makes it easier to abstract the generation of "unique" ints so that they 
> satisfy other constraints (e.g., they must be even, odd, prime, etc.).
>
> -- 
> Kurtis Rader
> Caretaker of the exceptional canines Junior and Hank
>

-- 
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 
https://groups.google.com/d/msgid/golang-nuts/4f62dfff-6895-4aaa-9f0d-b635d5ba7ea7%40googlegroups.com.