[go-nuts] Re: Go Optimizations for IO Intensive programs

2017-02-11 Thread maciej . lisiewski
1. Decompression:
- Try https://github.com/klauspost/pgzip - it's a drop-in replacement for 
compress/gzip and the author claims that is has twice the decompression 
speed due to better buffering (lower IO wait)
- Gzip decompression is single threaded - to use all cores decode multiple 
files at the same time
- Your storage (EBS g2) has max throughput of 160MB/s per volume 
(see https://aws.amazon.com/ebs/details/ ) - assuming you get max 
throughput (which is not guaranteed) just reading 5GB and writing 20GB will 
take almost 3 minutes. When downloading you only have to write 5GB, which 
is why it's faster. To get better speeds use a ram drive (hey, you have 
122GB of RAM), use st1 EBS or multiple EBS volumes in RAID0

2. Upload
- If you're using AWS SDK with chunked uploads then stop - it will fist 
load the entire file into memory (so read + allocate...), then calculates 
hash of the whole file (and not a "cheap one") and then a signs each part 
of the file, eventually sending it over https (so +encryption...)
- https://docs.aws.amazon.com/sdk-for-go/api/service/s3/s3manager/ with 
multi-part uploads. Experiment with part size to find the sweet spot (most 
likely somewhere between the minimum 5MB and 64MB), use higher concurrency 
value - default is 5 and that often is 10-50 times too low, YMWV


On Friday, February 10, 2017 at 7:58:50 PM UTC-5, mukund@gmail.com 
wrote:
>
> Hello,
>
> I have written a GO program which downloads a 5G compressed CSV from 
> Amazon S3, decompresses it and uploads the decompressed CSV (20G) to Amazon 
> S3.
>
> Amazon S3 provides a default concurrent uploader/downloader and I am using 
> a multithreaded approach to download files in parallel, decompress and 
> upload. The program seems to work fine, however I believe the program could 
> be optimized further. And not all the cores are used though I have 
> parallelized for the no. of CPUs available . The CPU usage is only around 
> 30-40% . I see a IO wait around 30/40% percent. 
>
> The download happens faster, The decompression takes 5-6 minutes and the 
> upload happens in parallel but takes almost an hour to upload  a set of 8 
> files. 
>
> For decompression, I use 
> reader, err := gzip.NewReader(gzipfile)
> writer, err := os.Create(outputFile)
> err = io.Copy(writer, reader)
>
> I use a 16CPU, 122 GB RAM, 500 GB SSD instance
>
> Are there any other methodologies where I can optimize compresssion part 
> and upload part
>
> I am pretty new to Golang.  Any guidance is very much appreciated.
>
> Regards
> Mukund
>
>
>
>
>
>
>

-- 
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] Go Optimizations for IO Intensive programs

2017-02-11 Thread krolaw
Just confirming, you are uploading each file as you're downloading it.  Not 
downloading completely, then decompressing completely, followed by uploading.

-- 
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] Panic in go1.8rc3 using cgo to get binary data from database

2017-02-11 Thread Mark Crook
Hello,

I'm seeing a panic in go version go1.8rc3 linux/amd64 while trying to write 
a database driver using cgo. The go code runs in a docker container, the 
database in another.

Generally it works reliably, but occasionally, during repeated retrieval of 
binary data (photos approx 100K to 2M), the code panics.

I haven't isolated a reproducible example, but I think it's related to this 
code:


value := new(C.a_sqlany_data_value)

//load the column value binary data into value.buffer

C.sqlany_get_column(r.stmt.ptr, C.sacapi_u32(i), value)


//copy the value buffer from C to Go

val = C.GoBytes(unsafe.Pointer(value.buffer), C.int(value.length))


I haven't seen the panic if the last line is commented out.

Below is a stack trace. Perhaps it panics when a garbage collection is 
triggered while waiting for C.GoBytes to return?

Any suggestions?

Thank you,
Mark

 

runtime: unexpected return pc for runtime.sigpanic called from 0xc420e1a000
fatal error: unknown caller pc

runtime stack:
runtime.throw(0x59a90e, 0x11)
/go/src/runtime/panic.go:596 +0x95
runtime.gentraceback(0x, 0xc42002a5d8, 0x0, 0xc4200c49c0, 
0x0, 0x0, 0x7fff, 0x7fb675ad5cb8, 0x0, 0x0, ...)
/go/src/runtime/traceback.go:317 +0x13ea
runtime.scanstack(0xc4200c49c0, 0xc420021828)
/go/src/runtime/mgcmark.go:842 +0x265
runtime.newstack(0x0)
/go/src/runtime/stack.go:1064 +0x41e
runtime.morestack()
/go/src/runtime/asm_amd64.s:398 +0x86

goroutine 11 [GC worker (idle) (scan)]:
runtime.assertE2I2(0x56c220, 0x569e20, 0x841d20, 0xc42002a6b0, 
0xc4200c49e0, 0xc42002a640)
/go/src/runtime/iface.go:289 +0xb2 fp=0xc42002a5e0 sp=0xc42002a5d8
runtime.preprintpanics(0xc42002a6b0)
/go/src/runtime/panic.go:389 +0x9f fp=0xc42002a650 sp=0xc42002a5e0
panic(0x569e20, 0x841d20)
/go/src/runtime/panic.go:528 +0x1ab fp=0xc42002a6e8 sp=0xc42002a650
runtime.panicmem()
/go/src/runtime/panic.go:63 +0x5e fp=0xc42002a708 sp=0xc42002a6e8
runtime.sigpanic()
/go/src/runtime/signal_unix.go:290 +0x29f fp=0xc42002a758 sp=0xc42002a708
created by runtime.gcBgMarkStartWorkers
/go/src/runtime/mgc.go:1410 +0x98

goroutine 1 [chan receive]:
testing.(*T).Run(0xc420072820, 0x598622, 0x8, 0x5a3718, 0xc420051d01)
/go/src/testing/testing.go:698 +0x2f4
testing.runTests.func1(0xc420072820)
/go/src/testing/testing.go:881 +0x67
testing.tRunner(0xc420072820, 0xc420051de0)
/go/src/testing/testing.go:657 +0x96
testing.runTests(0xc42000cb60, 0x8461e0, 0x4, 0x4, 0xc420051ef8)
/go/src/testing/testing.go:887 +0x2c1
testing.(*M).Run(0xc420051f20, 0xc420051f20)
/go/src/testing/testing.go:822 +0xfc
main.main()
github.com/mdcnz/sqlanywhere/_test/_testmain.go:48 +0xf7

goroutine 17 [syscall, 6 minutes, locked to thread]:
runtime.goexit()
/go/src/runtime/asm_amd64.s:2197 +0x1

goroutine 231 [GC assist wait]:
database/sql.convertAssign(0x5517a0, 0xc4200c20a0, 0x55a040, 0xc42000c0e0, 
0x85b5c0, 0x4535c0)
/go/src/database/sql/convert.go:161 +0x1a22
database/sql.(*Rows).Scan(0xc42001c6c0, 0xc420041f68, 0x1, 0x1, 0x0, 0x0)
/go/src/database/sql/sql.go:2342 +0xca
github.com/mdcnz/sqlanywhere.TestBlob(0xc4200728f0)
/root/gome/src/github.com/mdcnz/sqlanywhere/test.go:26 +0x2a5
testing.tRunner(0xc4200728f0, 0x5a3718)
/go/src/testing/testing.go:657 +0x96
created by testing.(*T).Run
/go/src/testing/testing.go:697 +0x2ca

goroutine 233 [chan receive]:
database/sql.(*Rows).awaitDone(0xc42001c6c0, 0x84b240, 0xc42047e080)
/go/src/database/sql/sql.go:2091 +0x54
created by database/sql.(*Rows).initContextClose
/go/src/database/sql/sql.go:2086 +0x92

goroutine 232 [chan receive]:
database/sql.(*DB).connectionOpener(0xc42008c210)
/go/src/database/sql/sql.go:835 +0x4a
created by database/sql.Open
/go/src/database/sql/sql.go:580 +0x1c8
exit status 2

-- 
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] Go support in MIPS platform

2017-02-11 Thread Steve Phillips

>
> Do you need gccgo, cgo or cross compiling?
>

Cross-compiling.  I'm trying to cross-compile Go programs from an x86_64 
Linux machine to run on a MIPS (32-bit) target machine with no software and 
no hardware FPU.


Without FPU however you will get "illegal instruction" when running the 
> binary.
>

I am indeed getting the "Illegal instruction" error... but I'm compiling 
using gccgo, and I thought that would work?  Will it not since there's no 
FPU?


[Either w]ait for vstefanovic to submit his changes promised in issue 18162
>

I've pinged him and mentioned this thread 
at https://github.com/golang/go/issues/18162 ; thanks!

 

> or compile a kernel with FPU emulation support.
>

I'll look more into doing exactly this, thank you.

--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.


[go-nuts] Re: Struggling with working directory

2017-02-11 Thread Diego Medina
Hi,

you were very close, instead of

go install github.com/mortalcatalyst/xml/xml.go

do

go install github.com/mortalcatalyst/xml


In go, you don't install the particular file, you install the program as a 
whole (which in many cases, it involves more than one file)

And as a side note, normally you would 

$ cd $GOPATH/src/github.com/mortalcatalyst/xml
$ go install


so you don't have to specify the whole path to the project every time.

Hope that helps

P.S. as you work with Go more and more, you'll want to add these lines to 
~/.bash_profile:

CDPATH=.:$GOPATH/src/github.com:$GOPATH/src/bitbucket.org #you may add more 
domains here if you host your proejct(s) somewhere else
export CDPATH

that let's you, form anywhere in your terminal, to type:

$ cd mor 

Then press tab and the terminal will autocomplete mortalcatalyst

P.S. source of the 
tip https://twitter.com/rob_pike/status/467367507305574400

Diego





On Saturday, February 11, 2017 at 7:12:38 AM UTC-5, Sayth Renshaw wrote:
>
> Hi All
>
> I installed go on a new linux mint laptop and followed the standard go 
> guide and it works fine with the hello world example.
>
> Today i came back to work on go and cannot seem to do the install step to 
> run my script.
>
> sayth@sayth-E6410 ~ $ mkdir -p work/src/github.com/mortalcatalyst/xml
> sayth@sayth-E6410 ~ $ code ~/work/src/github.com/mortalcatalyst/xml/xml.go
> sayth@sayth-E6410 ~ $ go install github.com/mortalcatalyst/xml/xml.go
> stat github.com/mortalcatalyst/xml/xml.go: no such file or directory
>
> sayth@sayth-E6410 ~ $ cd $GOPATH
> sayth@sayth-E6410 ~/work $ go install github.com/mortalcatalyst/xml/xml.go
> stat github.com/mortalcatalyst/xml/xml.go: no such file or directory
>
> Now I am a little confused, how should I easily come in every day fire up 
> a project and get it to work and get the file to run and install?
>
> Cheers
>
> Sayth
>

-- 
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] CodeReviewComments: Recommendation of gofmt

2017-02-11 Thread Jan Mercl
On Sat, Feb 11, 2017 at 5:07 PM Axel Wagner 
wrote:

> What about a) vs. c)?

c) is fine, but as it's a matter of personal taste, ie. it's IMO more or
less bike shedding. IOW, whatever choice as long as it's a single one.
Actually, the split goimports bring to the one-true-gofmt-style is another,
although minor, point I dislike. (Don't get me wrong, I would as well
prefer some details of gofmt done differently, but that's not making the
value of a single style any lower for me.)

> Side-note: I don't think goimports can actually do what you are saying,
can it? Because, if you run goimports on a valid program, it won't actually
*change* any imports, it might just reformat it. For goimports to change
anything semantically, the program would need to have missing imports to
begin with.

Of course, you're right. I should have said: It can silently turn an
invalid program into a valid one with different than intended/assumed
semantics. Security implications, however, remain.

-- 

-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] CodeReviewComments: Recommendation of gofmt

2017-02-11 Thread 'Axel Wagner' via golang-nuts
Which is a strong opinion against b). What about a) vs. c)?

Side-note: I don't think goimports can actually do what you are saying, can
it? Because, if you run goimports on a valid program, it won't actually
*change* any imports, it might just reformat it. For goimports to change
anything semantically, the program would need to have missing imports to
begin with.

On Sat, Feb 11, 2017 at 4:57 PM, Jan Mercl <0xj...@gmail.com> wrote:

>
> On Sat, Feb 11, 2017 at 4:30 PM 'Axel Wagner' via golang-nuts <
> golang-nuts@googlegroups.com> wrote:
>
> > Am I alone in being bothered by this? ^^
>
> My personal opinion is that a tool that can, even potentially, turn a
> valid program into an invalid one, or worse, silently into another valid
> program with different semantics, should be considered an easily avoidable
> security risk.
>
> --
>
> -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] CodeReviewComments: Recommendation of gofmt

2017-02-11 Thread Jan Mercl
On Sat, Feb 11, 2017 at 4:30 PM 'Axel Wagner' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> Am I alone in being bothered by this? ^^

My personal opinion is that a tool that can, even potentially, turn a valid
program into an invalid one, or worse, silently into another valid program
with different semantics, should be considered an easily avoidable security
risk.

-- 

-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] still without a CUDA binding/package for Go?

2017-02-11 Thread Germán Meléndrez Carballo
Hi everyone:

I wonder if still are no CUDA bindings or packages for Go?
I have seen some post about that, but no more updates. Also, I see mumax3, 
but it says that supports CUDA 7.5, are there a CUDA 8 package/binding?


Thanks in advance.

-- 
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] CodeReviewComments: Recommendation of gofmt

2017-02-11 Thread 'Axel Wagner' via golang-nuts
Hi,

(disclaimer: This is a nit)

in the Code Review Comments
, we are
recommending that people use gofmt, giving goimports as an alternative.
That makes me somewhat uncomfortable, as while each itself is idempotent,
gofmt clean code might be reformatted by goimports. For example, this code
 will not be reformatted by gofmt,
but will be by goimports. Thus, someone might do everything "right", but
still unintentionally cause a whitespace-only change in a later commit. I
see three possibilities:
a) leave it up to individual repo owners to decide whether to enforce gofmt
or the stricter goimports (or enforce neither)
b) recommend goimports universally
c) add goimports regrouping of imports to gofmt

a) makes the me queasy. I understand why b) is not necessarily desirable,
as organizations with large GOPATHs might cause goimports to have
false-positive replacements. Personally, I'd like c).
Am I alone in being bothered by this? ^^

-- 
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: about the memclr optimization

2017-02-11 Thread 'Axel Wagner' via golang-nuts
That is currently the case for the mainline implementations, AFAIK, but it
really shouldn't matter, unless you are hacking on the runtime/compiler.

On Sat, Feb 11, 2017 at 3:36 PM, T L  wrote:

>
>
> On Saturday, February 11, 2017 at 1:49:58 PM UTC+8, T L wrote:
>>
>> https://github.com/golang/go/issues/5373
>>
>
>
> btw, does this optimization imply that the zero value of any type is
> composed by zero bytes?
> At least for all current supported ARCHes.
>
>
>>
>>
>> I made a test
>>
>> package main
>>
>> import (
>> "testing"
>> )
>>
>> const N = 1024 * 100
>> var a [N]int
>>
>> func BenchmarkArrayPtr(b *testing.B) {
>> for i := 0; i < b.N; i++ {
>> for i := range  {
>> a[i] = 0
>> }
>> }
>> }
>>
>> func BenchmarkArray(b *testing.B) {
>> for i := 0; i < b.N; i++ {
>> for i := range a {
>> a[i] = 0
>> }
>> }
>> }
>>
>> func BenchmarkArrayB(b *testing.B) {
>> var k int
>> go func() {
>> k = 123
>> }()
>> for i := 0; i < b.N; i++ {
>> for k = range a {
>> a[k] = 0
>> }
>> }
>> }
>>
>> /*
>> Outputs:
>> BenchmarkArrayPtr-4  5 90457 ns/op
>> BenchmarkArray-410 49656 ns/op
>> BenchmarkArrayB-4   10 49628 ns/op
>> */
>>
>> it looks the loop in the BenchmarkArrayB is also optimized as a memclr
>> call, but I can't make sure it is true.
>> If it is true, it is over-optimized.
>> Anyone can confirm it is over-optimized or not?
>>
> --
> 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: about the memclr optimization

2017-02-11 Thread T L


On Saturday, February 11, 2017 at 1:49:58 PM UTC+8, T L wrote:
>
> https://github.com/golang/go/issues/5373
>


btw, does this optimization imply that the zero value of any type is 
composed by zero bytes?
At least for all current supported ARCHes.
 

>
>
> I made a test
>
> package main
>
> import (
> "testing"
> )
>
> const N = 1024 * 100
> var a [N]int
>
> func BenchmarkArrayPtr(b *testing.B) {
> for i := 0; i < b.N; i++ {
> for i := range  {
> a[i] = 0
> }
> }
> }
>
> func BenchmarkArray(b *testing.B) {
> for i := 0; i < b.N; i++ {
> for i := range a {
> a[i] = 0
> }
> }
> }
>
> func BenchmarkArrayB(b *testing.B) {
> var k int
> go func() {
> k = 123
> }()
> for i := 0; i < b.N; i++ {
> for k = range a {
> a[k] = 0
> }
> }
> }
>
> /*
> Outputs:
> BenchmarkArrayPtr-4  5 90457 ns/op
> BenchmarkArray-410 49656 ns/op
> BenchmarkArrayB-4   10 49628 ns/op
> */
>
> it looks the loop in the BenchmarkArrayB is also optimized as a memclr 
> call, but I can't make sure it is true.
> If it is true, it is over-optimized.
> Anyone can confirm it is over-optimized or not?
>

-- 
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] Go support in MIPS platform

2017-02-11 Thread ktye78
Do you need gccgo, cgo or cross compiling?
I don't know about that, but otherwise  the default compiler should work for
mipsle (32 bit little endian)  "since" go 1.8.

Without FPU however you will get "illegal instruction" when running the 
binary.

There are 2 possibilities:
Wait for vstefanovic to submit his changes promised in issue 18162
or compile a kernel with FPU emulation support.

The latter worked for me on a vocore2 pc.

-- 
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: Dead link on page https://blog.golang.org/go-fmt-your-code

2017-02-11 Thread alb . donizetti
Thanks for the report. I opened 
https://github.com/golang/go/issues/19036

A.

Il giorno venerdì 10 febbraio 2017 21:51:20 UTC+1, Константин Изюмов ha 
scritto:
>
> Please pay your attention on page https://blog.golang.org/go-fmt-your-code 
> with dead link under word "Vim plugin for Go", because page 
> http://tip.golang.org/misc/vim/readme.txt is found. 
> Like I understood, correct link is 
> https://github.com/golang/go/wiki/IDEsAndTextEditorPlugins

-- 
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] Struggling with working directory

2017-02-11 Thread Sayth Renshaw
Hi All

I installed go on a new linux mint laptop and followed the standard go 
guide and it works fine with the hello world example.

Today i came back to work on go and cannot seem to do the install step to 
run my script.

sayth@sayth-E6410 ~ $ mkdir -p work/src/github.com/mortalcatalyst/xml
sayth@sayth-E6410 ~ $ code ~/work/src/github.com/mortalcatalyst/xml/xml.go
sayth@sayth-E6410 ~ $ go install github.com/mortalcatalyst/xml/xml.go
stat github.com/mortalcatalyst/xml/xml.go: no such file or directory

sayth@sayth-E6410 ~ $ cd $GOPATH
sayth@sayth-E6410 ~/work $ go install github.com/mortalcatalyst/xml/xml.go
stat github.com/mortalcatalyst/xml/xml.go: no such file or directory

Now I am a little confused, how should I easily come in every day fire up a 
project and get it to work and get the file to run and install?

Cheers

Sayth

-- 
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] The feature I want most, weak *

2017-02-11 Thread Wojciech S. Czarnecki
Dnia 2017-02-11, o godz. 17:04:58
Keynan Pratt  napisał(a):

> On the other hand what is the cost of adding this?
> I suspect it is (very) small

I suspect it is (very) easy to assess: simply clone 
the go repo and do implement weak as you sketched it.

See e.g. https://github.com/waterlink/go

Hope this helps,
TC

-- 
Wojciech S. Czarnecki
   ^oo^ OHIR-RIPE

-- 
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] about the memclr optimization

2017-02-11 Thread T L


On Saturday, February 11, 2017 at 4:23:07 PM UTC+8, Axel Wagner wrote:
>
> To expand on Dave's point: Your function has a data race (reads/writes 
> concurrent with writes in different goroutines) and thus its behavior is 
> not defined. Run with the benchmark with -race to confirm. The compiler can 
> pretty much do, what it wants in that case.
>
> You need to add synchronization to eliminate the race. If you try, you'll 
> see that it will behave correctly.
>

ok, not a big problem anyway.
 

>
> On Sat, Feb 11, 2017 at 8:17 AM, Dave Cheney  > wrote:
>
>> It's neither, its undefined.
>>
>> --
>> 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] about the memclr optimization

2017-02-11 Thread 'Axel Wagner' via golang-nuts
To expand on Dave's point: Your function has a data race (reads/writes
concurrent with writes in different goroutines) and thus its behavior is
not defined. Run with the benchmark with -race to confirm. The compiler can
pretty much do, what it wants in that case.

You need to add synchronization to eliminate the race. If you try, you'll
see that it will behave correctly.

On Sat, Feb 11, 2017 at 8:17 AM, Dave Cheney  wrote:

> It's neither, its undefined.
>
> --
> 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.