[go-nuts] about golang escape analysis

2017-12-02 Thread 刘桂祥
package main

import "testing"

var gbuf []byte
var gi int

func BenchmarkCopy1(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
m := make(map[string]int, 5)
for i := 0; i < 5; i++ {
m["100"] = i
}
for key := range m {
copyIface1(key, key)
}

}
}

func BenchmarkCopy2(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
m := make(map[string]int, 5)
for i := 0; i < 5; i++ {
m["100"] = i
}
for key := range m {
copyIface2(key, key)
}

}
}

func copyIface1(a ...interface{}) {
if gi > 0 {
copy(gbuf, a[0].(string))
copy(gbuf, a[1].(string))
}
}

func copyIface2(a interface{}, b interface{}) {
if gi > 0 {
copy(gbuf, a.(string))
copy(gbuf, b.(string))
}
}
BenchmarkCopy1-4300452 ns/op   32 B/op2 
allocs/op
BenchmarkCopy2-4500323 ns/op0 B/op0 
allocs/op

BenchmarkCopy1 key escapes to heap
BenchmarkCopy2 key does not escape
why ??? 


-- 
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-02 Thread Hugh S. Myers
yeah I guess, sick transom gloria monday and such…

On Sat, Dec 2, 2017 at 11:57 PM, 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.
>
>
> > Most likely, Google made Go public because they wanted enthusiastic
> > contributors to help them develop Go --- hiring programmers is expensive.
> > After Go is settled though, Google may make it proprietary again. The
> > enthusiasts will succeed so well that no further contribution from them
> is
> > needed.
>
> The Go team released Go as open source because proprietary programming
> languages make no sense.  Since all programming languages have
> equivalent power, proprietary languages bring you no advantage.  It
> would never make sense for Google to make some new version of Go
> proprietary.
>
> I appreciate your skepticism of corporations, and that can be a
> reasonable stance, but you should also expect large successful
> corporations to act more or less rationally.  Google might conceivably
> some day decide that it's not worth paying people to support Go, but
> Google would never decide to make a proprietary version of Go.
>
> 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.
>

-- 
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-02 Thread Ian Lance Taylor
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.


> Most likely, Google made Go public because they wanted enthusiastic
> contributors to help them develop Go --- hiring programmers is expensive.
> After Go is settled though, Google may make it proprietary again. The
> enthusiasts will succeed so well that no further contribution from them is
> needed.

The Go team released Go as open source because proprietary programming
languages make no sense.  Since all programming languages have
equivalent power, proprietary languages bring you no advantage.  It
would never make sense for Google to make some new version of Go
proprietary.

I appreciate your skepticism of corporations, and that can be a
reasonable stance, but you should also expect large successful
corporations to act more or less rationally.  Google might conceivably
some day decide that it's not worth paying people to support Go, but
Google would never decide to make a proprietary version of Go.

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] Dangers of package renaming

2017-12-02 Thread Lars Seipel
On Sat, Dec 02, 2017 at 07:33:05AM -0800, Jonathan Hall wrote:
> I maintain an open-source Go package with a few dozen followers.  
> (github.com/flimzy/kivik)
> 
> I'm planning to transfer/rename the package to a new organization (new 
> package name to be: github.com/go-kivik/kivik).
> 
> I understand that GitHub will maintain a redirect from the old location to 
> the new one, so in theory, old imports will continue working.

This can be very intrusive for users of your package. Problems are wont
to occur as soon as there is code importing the package under different
names (actually turning them into distinct packages). This also applies
to code living in the same repo such as the "sub-packages" you mention.

If those are imported by another package in the same repo (using the new
name) and directly by users of your library as well (using the old
name), you'll end up with distinct packages and thus incompatible types,
a distinct set of package-level variables and so on.

You might be able to prevent some of that pain with a different
approach, by keeping the existing package alive but turning it into a
forwarder to the new package. Use type aliases for re-exporting types.

This is approximately what was done for the x/net/context package when
context was imported into the standard library. It only started to work
well once type aliases were available 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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: Elphaba Chess

2017-12-02 Thread as
Transitive property abused for emphasis.

On Saturday, December 2, 2017 at 7:06:15 PM UTC-8, hsmyers wrote:
>
> err…wouldn't that be "C an Bell product…" Bell Labs and all.
>
> On Sat, Dec 2, 2017 at 7:12 PM, as  wrote:
>
>> Calling Go a Google product makes as much sense as calling C a Nokia 
>> product. 
>>
>>
>> On Friday, November 24, 2017 at 7:23:06 PM UTC-8, Hugh Aguilar wrote:
>>>
>>> I invented a chess variation called: Elphaba Chess
>>> This is just like International Chess except that the queen can't 
>>> capture the opponent's pieces and it can't be captured --- it is just used 
>>> for blocking.
>>>
>>> I would like to write a program to play this game, but writing that from 
>>> scratch is beyond me. 
>>> Perhaps I could find a public-domain open-source chess program and 
>>> modify it to use my rules. I would have to change the legal-move code to 
>>> eliminate captures by the queen or captures of the queen.
>>> Other than that, the program should work fine. Check-mate is still the 
>>> goal. The queen is still worth 9 points, but that is irrelevant, so you 
>>> might as well say that it is worth 0 points.
>>> I would not expect the point values for the other pieces to change --- 
>>> they might though --- this would have to be determined by experimentation 
>>> (by stronger players than myself).
>>>
>>> I would prefer to do this in Go as I'm learning Go and this would be a 
>>> good learning exercise.
>>> If there are no such programs available in Go however, then I could use 
>>> another language --- I know C, C++ and Pascal, but not very well, and I 
>>> don't like them much.
>>> My background is in Forth (I've done that professionally), but ANS-Forth 
>>> killed Forth in 1994, so nobody really uses Forth anymore.
>>>
>>> thanks for any links --- Hugh
>>>
>>> My ultimate goal with Go is to write a program to "understand" the Ido 
>>> language, at least insomuch as generating a grammar diagram for a sentence 
>>> and determining if the sentence is grammatical.
>>> It could go from there to generating an English or Spanish translation. 
>>> I have a lot to learn about Go before I tackle such a program however.
>>>
>>> Does Go run on smart-phones? I have only heard of Java and Objective-C 
>>> being used. I have no interest in learning Java, and not much interest in 
>>> Objective-C.
>>>
>>> This program lends itself well to parallel processing. The meaning and 
>>> part-of-speech (POS) of each word in an Ido sentence is 
>>> context-insensitive, so the words can be analyzed in parallel.
>>> I have designed a multi-core Forth processor that can be built into an 
>>> FPGA --- that is what I would like to use --- build a handheld device to do 
>>> the translation.
>>>
>>> -- 
>> 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: Elphaba Chess

2017-12-02 Thread Hugh S. Myers
err…wouldn't that be "C an Bell product…" Bell Labs and all.

On Sat, Dec 2, 2017 at 7:12 PM, as  wrote:

> Calling Go a Google product makes as much sense as calling C a Nokia
> product.
>
>
> On Friday, November 24, 2017 at 7:23:06 PM UTC-8, Hugh Aguilar wrote:
>>
>> I invented a chess variation called: Elphaba Chess
>> This is just like International Chess except that the queen can't capture
>> the opponent's pieces and it can't be captured --- it is just used for
>> blocking.
>>
>> I would like to write a program to play this game, but writing that from
>> scratch is beyond me.
>> Perhaps I could find a public-domain open-source chess program and modify
>> it to use my rules. I would have to change the legal-move code to eliminate
>> captures by the queen or captures of the queen.
>> Other than that, the program should work fine. Check-mate is still the
>> goal. The queen is still worth 9 points, but that is irrelevant, so you
>> might as well say that it is worth 0 points.
>> I would not expect the point values for the other pieces to change ---
>> they might though --- this would have to be determined by experimentation
>> (by stronger players than myself).
>>
>> I would prefer to do this in Go as I'm learning Go and this would be a
>> good learning exercise.
>> If there are no such programs available in Go however, then I could use
>> another language --- I know C, C++ and Pascal, but not very well, and I
>> don't like them much.
>> My background is in Forth (I've done that professionally), but ANS-Forth
>> killed Forth in 1994, so nobody really uses Forth anymore.
>>
>> thanks for any links --- Hugh
>>
>> My ultimate goal with Go is to write a program to "understand" the Ido
>> language, at least insomuch as generating a grammar diagram for a sentence
>> and determining if the sentence is grammatical.
>> It could go from there to generating an English or Spanish translation. I
>> have a lot to learn about Go before I tackle such a program however.
>>
>> Does Go run on smart-phones? I have only heard of Java and Objective-C
>> being used. I have no interest in learning Java, and not much interest in
>> Objective-C.
>>
>> This program lends itself well to parallel processing. The meaning and
>> part-of-speech (POS) of each word in an Ido sentence is
>> context-insensitive, so the words can be analyzed in parallel.
>> I have designed a multi-core Forth processor that can be built into an
>> FPGA --- that is what I would like to use --- build a handheld device to do
>> the translation.
>>
>> --
> 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: Elphaba Chess

2017-12-02 Thread as
Calling Go a Google product makes as much sense as calling C a Nokia 
product. 

On Friday, November 24, 2017 at 7:23:06 PM UTC-8, Hugh Aguilar wrote:
>
> I invented a chess variation called: Elphaba Chess
> This is just like International Chess except that the queen can't capture 
> the opponent's pieces and it can't be captured --- it is just used for 
> blocking.
>
> I would like to write a program to play this game, but writing that from 
> scratch is beyond me. 
> Perhaps I could find a public-domain open-source chess program and modify 
> it to use my rules. I would have to change the legal-move code to eliminate 
> captures by the queen or captures of the queen.
> Other than that, the program should work fine. Check-mate is still the 
> goal. The queen is still worth 9 points, but that is irrelevant, so you 
> might as well say that it is worth 0 points.
> I would not expect the point values for the other pieces to change --- 
> they might though --- this would have to be determined by experimentation 
> (by stronger players than myself).
>
> I would prefer to do this in Go as I'm learning Go and this would be a 
> good learning exercise.
> If there are no such programs available in Go however, then I could use 
> another language --- I know C, C++ and Pascal, but not very well, and I 
> don't like them much.
> My background is in Forth (I've done that professionally), but ANS-Forth 
> killed Forth in 1994, so nobody really uses Forth anymore.
>
> thanks for any links --- Hugh
>
> My ultimate goal with Go is to write a program to "understand" the Ido 
> language, at least insomuch as generating a grammar diagram for a sentence 
> and determining if the sentence is grammatical.
> It could go from there to generating an English or Spanish translation. I 
> have a lot to learn about Go before I tackle such a program however.
>
> Does Go run on smart-phones? I have only heard of Java and Objective-C 
> being used. I have no interest in learning Java, and not much interest in 
> Objective-C.
>
> This program lends itself well to parallel processing. The meaning and 
> part-of-speech (POS) of each word in an Ido sentence is 
> context-insensitive, so the words can be analyzed in parallel.
> I have designed a multi-core Forth processor that can be built into an 
> FPGA --- that is what I would like to use --- build a handheld device to do 
> the translation.
>
>

-- 
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-02 Thread matthewjuran
That math is wrong, doing a three-depth search would take more like 250 
seconds, not half a second. My next level of computer player would maybe do 
a one-depth search for about 250 milliseconds.

Matt

On Saturday, December 2, 2017 at 6:13:34 PM UTC-6, matthe...@gmail.com 
wrote:
>
> The plan for my variation is to extend my "easy computer" move rating 
> system into traversing the tree of possible positions, maybe something like 
> three deep which would take about half a second to compute with my 
> unoptimized engine. Stockfish probably has much more effort put into such a 
> thing (like you pointed out, it's probably better to go many deep in one 
> path and ignore most of the other branches) and understanding those 
> algorithms will take some work.
>
> Writing an opponent with some basic character and variation isn't 
> difficult in your own engine once you have a call to get possible moves for 
> a position. Is your primary goal to make a strong opponent for your 
> variation, or just to have a computer game to play with others?
>
> Those special cases (promotion, en passant, and castling) break some 
> assumptions that a person may make when starting to design a chess engine. 
> Specifically, promotion causes two moves in a row and requires an interface 
> to choose the piece, en passant is the only move that lasts for a single 
> turn even if the two interacting pieces don't move, and castling is the 
> only move that moves two pieces.
>
> I appreciate that Go is not a commercial product even though I have 
> concerns for collective use, and hopefully it doesn't require forks 
> eventually. Thanks for sharing your story.
>
> Matt
>
> On Saturday, December 2, 2017 at 1:38:23 PM UTC-6, Hugh Aguilar wrote:
>>
>>
>>
>> On Saturday, December 2, 2017 at 7:00:55 AM UTC-7, matthe...@gmail.com 
>> wrote:
>>>
>>> Writing a chess engine is easier than you may think, those algorithms 
>>> are meant to speed up computer moves and computer analysis, neither of 
>>> which are necessary to play the game. My engine has none of that and is not 
>>> optimized at all and doesn't do any caching between the database and still 
>>> responds to making a move or calculating all moves for a position within 5 
>>> milliseconds. Just be ready to hack a little for promotion, en passant, and 
>>> castling.
>>>
>>
>> My Reversi program was weak because it searched to a fixed depth. For a 
>> game to be strong, it needs to search the more volatile paths deeper than 
>> the quiet paths. 
>> In chess this means that exchanges of pieces have to be completed. The 
>> search should terminate on a board position that is "settled."
>> I don't know how to do this. What does "settled" mean, exactly.
>> Are there any books available on the Alpha-Beta algorithm, or anything on 
>> the web? 
>> That book I had was a TAB book bought in the 1980s --- it discussed 
>> pretty simple games --- my understanding of the Alpha-Beta algorithm is 
>> pretty weak.
>>
>> I don't know why you keep mentioning promotion, en passant and castling. 
>> This is the same in Elphaba Chess as in International Chess.
>> The only difference about Elphaba Chess is that the queen can't capture 
>> and can't be captured. The queen just gets in the way!
>>  
>>
>>> I think what I was getting to earlier is that Go would benefit from 
>>> official corporate and academic partners (that foundation) because if 
>>> Google goes then probably Go does too, for any significant commercial or 
>>> academic use at least.
>>>
>>
>> Well, just be aware that a corporation typically sees the rest of the 
>> world as competition to be crushed. This means you!
>>
>> Google is not going to be happy if somebody uses Go to compete against 
>> Google. AFAIK, most if not all of Google's money comes from selling 
>> advertising on their 
>> search-engine. Theirs isn't the only search-engine though. Another 
>> example is Bing. There may be others, but it takes a pretty big server.
>> If people use Go to compete against Google, then Google will pull the rug 
>> out from under their feet! 
>> Writing a chess program is non-threatening though --- there is no money 
>> to be made --- this is just hobbyist programming.
>>
>> I mentioned the ANS-Forth standard of 1994, which is truly awful from a 
>> technical stand-point. The author of ANS-Forth was Elizabeth Rather, the 
>> owner of Forth Inc..
>> Charles Moore, the inventor of Forth left Forth Inc. in 1982, and he 
>> abandoned ANS-Forth in 1989. He says that ANS-Forth is not Forth at all.
>> Elizabeth Rather is unconcerned that ANS-Forth has technical problems. 
>> She says that the purpose of ANS-Forth is "portable programmers." 
>> Apparently Forth Inc. was tired of hiring programmers who know nothing 
>> about Forth, and training them from the ground up.
>> She wants programmers to learn the rudiments of Forth first, before they 
>> apply for work at Forth Inc..
>> ANS-Forth is adequate for writing trivial programs, for learning the 
>> 

Re: [go-nuts] Elphaba Chess

2017-12-02 Thread matthewjuran
The plan for my variation is to extend my "easy computer" move rating 
system into traversing the tree of possible positions, maybe something like 
three deep which would take about half a second to compute with my 
unoptimized engine. Stockfish probably has much more effort put into such a 
thing (like you pointed out, it's probably better to go many deep in one 
path and ignore most of the other branches) and understanding those 
algorithms will take some work.

Writing an opponent with some basic character and variation isn't difficult 
in your own engine once you have a call to get possible moves for a 
position. Is your primary goal to make a strong opponent for your 
variation, or just to have a computer game to play with others?

Those special cases (promotion, en passant, and castling) break some 
assumptions that a person may make when starting to design a chess engine. 
Specifically, promotion causes two moves in a row and requires an interface 
to choose the piece, en passant is the only move that lasts for a single 
turn even if the two interacting pieces don't move, and castling is the 
only move that moves two pieces.

I appreciate that Go is not a commercial product even though I have 
concerns for collective use, and hopefully it doesn't require forks 
eventually. Thanks for sharing your story.

Matt

On Saturday, December 2, 2017 at 1:38:23 PM UTC-6, Hugh Aguilar wrote:
>
>
>
> On Saturday, December 2, 2017 at 7:00:55 AM UTC-7, matthe...@gmail.com 
> wrote:
>>
>> Writing a chess engine is easier than you may think, those algorithms are 
>> meant to speed up computer moves and computer analysis, neither of which 
>> are necessary to play the game. My engine has none of that and is not 
>> optimized at all and doesn't do any caching between the database and still 
>> responds to making a move or calculating all moves for a position within 5 
>> milliseconds. Just be ready to hack a little for promotion, en passant, and 
>> castling.
>>
>
> My Reversi program was weak because it searched to a fixed depth. For a 
> game to be strong, it needs to search the more volatile paths deeper than 
> the quiet paths. 
> In chess this means that exchanges of pieces have to be completed. The 
> search should terminate on a board position that is "settled."
> I don't know how to do this. What does "settled" mean, exactly.
> Are there any books available on the Alpha-Beta algorithm, or anything on 
> the web? 
> That book I had was a TAB book bought in the 1980s --- it discussed pretty 
> simple games --- my understanding of the Alpha-Beta algorithm is pretty 
> weak.
>
> I don't know why you keep mentioning promotion, en passant and castling. 
> This is the same in Elphaba Chess as in International Chess.
> The only difference about Elphaba Chess is that the queen can't capture 
> and can't be captured. The queen just gets in the way!
>  
>
>> I think what I was getting to earlier is that Go would benefit from 
>> official corporate and academic partners (that foundation) because if 
>> Google goes then probably Go does too, for any significant commercial or 
>> academic use at least.
>>
>
> Well, just be aware that a corporation typically sees the rest of the 
> world as competition to be crushed. This means you!
>
> Google is not going to be happy if somebody uses Go to compete against 
> Google. AFAIK, most if not all of Google's money comes from selling 
> advertising on their 
> search-engine. Theirs isn't the only search-engine though. Another example 
> is Bing. There may be others, but it takes a pretty big server.
> If people use Go to compete against Google, then Google will pull the rug 
> out from under their feet! 
> Writing a chess program is non-threatening though --- there is no money to 
> be made --- this is just hobbyist programming.
>
> I mentioned the ANS-Forth standard of 1994, which is truly awful from a 
> technical stand-point. The author of ANS-Forth was Elizabeth Rather, the 
> owner of Forth Inc..
> Charles Moore, the inventor of Forth left Forth Inc. in 1982, and he 
> abandoned ANS-Forth in 1989. He says that ANS-Forth is not Forth at all.
> Elizabeth Rather is unconcerned that ANS-Forth has technical problems. She 
> says that the purpose of ANS-Forth is "portable programmers." 
> Apparently Forth Inc. was tired of hiring programmers who know nothing 
> about Forth, and training them from the ground up.
> She wants programmers to learn the rudiments of Forth first, before they 
> apply for work at Forth Inc..
> ANS-Forth is adequate for writing trivial programs, for learning the 
> rudiments of Forth --- learn how DUP OVER SWAP ROT etc. work.
> ANS-Forth was purposely crippled though, to prevent it from being used for 
> writing non-trivial programs in competition with Forth Inc..
>
> In 1994 I wrote the MFX Forth cross-compiler using UR/Forth. This targeted 
> the MiniForth processor, which was built on a Lattice isp1048 PLD. The 
> MiniForth was used in the motion-control 

Re: [go-nuts] Elphaba Chess

2017-12-02 Thread Dave Cheney
Jan your message is unwelcoming and unwarranted. Please refrain from ad hominem 
arguments in the future. 

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


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

2017-12-02 Thread rlh via golang-nuts
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.


Re: [go-nuts] Elphaba Chess

2017-12-02 Thread Jan Mercl
On Sat, Dec 2, 2017, 20:38  wrote:

>
> Google is not going to be happy if somebody uses Go to compete against
> Google.
>

This is where I stopped considering any of your future posts worth my
attention.

Disclaimer: I'm not affiliated with Google in any way except programming in
Go.
-- 

-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] Elphaba Chess

2017-12-02 Thread hughaguilar96


On Saturday, December 2, 2017 at 7:00:55 AM UTC-7, matthe...@gmail.com 
wrote:
>
> Writing a chess engine is easier than you may think, those algorithms are 
> meant to speed up computer moves and computer analysis, neither of which 
> are necessary to play the game. My engine has none of that and is not 
> optimized at all and doesn't do any caching between the database and still 
> responds to making a move or calculating all moves for a position within 5 
> milliseconds. Just be ready to hack a little for promotion, en passant, and 
> castling.
>

My Reversi program was weak because it searched to a fixed depth. For a 
game to be strong, it needs to search the more volatile paths deeper than 
the quiet paths. 
In chess this means that exchanges of pieces have to be completed. The 
search should terminate on a board position that is "settled."
I don't know how to do this. What does "settled" mean, exactly.
Are there any books available on the Alpha-Beta algorithm, or anything on 
the web? 
That book I had was a TAB book bought in the 1980s --- it discussed pretty 
simple games --- my understanding of the Alpha-Beta algorithm is pretty 
weak.

I don't know why you keep mentioning promotion, en passant and castling. 
This is the same in Elphaba Chess as in International Chess.
The only difference about Elphaba Chess is that the queen can't capture and 
can't be captured. The queen just gets in the way!
 

> I think what I was getting to earlier is that Go would benefit from 
> official corporate and academic partners (that foundation) because if 
> Google goes then probably Go does too, for any significant commercial or 
> academic use at least.
>

Well, just be aware that a corporation typically sees the rest of the world 
as competition to be crushed. This means you!

Google is not going to be happy if somebody uses Go to compete against 
Google. AFAIK, most if not all of Google's money comes from selling 
advertising on their 
search-engine. Theirs isn't the only search-engine though. Another example 
is Bing. There may be others, but it takes a pretty big server.
If people use Go to compete against Google, then Google will pull the rug 
out from under their feet! 
Writing a chess program is non-threatening though --- there is no money to 
be made --- this is just hobbyist programming.

I mentioned the ANS-Forth standard of 1994, which is truly awful from a 
technical stand-point. The author of ANS-Forth was Elizabeth Rather, the 
owner of Forth Inc..
Charles Moore, the inventor of Forth left Forth Inc. in 1982, and he 
abandoned ANS-Forth in 1989. He says that ANS-Forth is not Forth at all.
Elizabeth Rather is unconcerned that ANS-Forth has technical problems. She 
says that the purpose of ANS-Forth is "portable programmers." 
Apparently Forth Inc. was tired of hiring programmers who know nothing 
about Forth, and training them from the ground up.
She wants programmers to learn the rudiments of Forth first, before they 
apply for work at Forth Inc..
ANS-Forth is adequate for writing trivial programs, for learning the 
rudiments of Forth --- learn how DUP OVER SWAP ROT etc. work.
ANS-Forth was purposely crippled though, to prevent it from being used for 
writing non-trivial programs in competition with Forth Inc..

In 1994 I wrote the MFX Forth cross-compiler using UR/Forth. This targeted 
the MiniForth processor, which was built on a Lattice isp1048 PLD. The 
MiniForth was used in the motion-control board for a laser-etching machine.
This was obviously not ANS-Forth compliant, because ANS-Forth came out in 
the same year. 
UR/Forth was Forth-83 compliant, but MFX was not Forth-83 compliant --- 
Forth-83 had technical problems too --- it wasn't adequate for what I 
needed.
The purpose of ANS-Forth was to give Forth Inc. the high-ground --- they 
can denounce all the competitors' accomplishments as being non-standard.
LMI, the company that sold UR/Forth, went out of business when ANS-Forth 
became the standard. LMI went from being industry leader to being a 
wanna-bee.
This is the danger of allowing a corporation to define a 
programming-language standard --- competitors will be non-standard --- all 
programmers are competitors.

Most likely, Google made Go public because they wanted enthusiastic 
contributors to help them develop Go --- hiring programmers is expensive. 
After Go is settled though, Google may make it proprietary again. The 
enthusiasts will succeed so well that no further contribution from them is 
needed.
Google could kill Go by pushing a crippleware version through ANSI and 
calling that the "Standard" so nobody can use Go to write non-trivial 
programs.
This trick works very well! This pulls the rug out from under the 
programmers --- dumps them on their non-standard butts --- they don't rise 
again.

>From a legal perspective, a corporation is the same as a person, although 
most people don't think of a corporation as being a "person."
If it were a person, it would be a sociopath!

[go-nuts] Dangers of package renaming

2017-12-02 Thread Jonathan Hall
I maintain an open-source Go package with a few dozen followers.  
(github.com/flimzy/kivik)

I'm planning to transfer/rename the package to a new organization (new 
package name to be: github.com/go-kivik/kivik).

I understand that GitHub will maintain a redirect from the old location to 
the new one, so in theory, old imports will continue working.

But my question is: Are there any dangers I need to consider when making 
this change, and is there anything I can do to help mitigate such dangers?  
I ask mainly because I've read of some nightmares related to package 
renaming 
(example: 
https://github.com/sirupsen/logrus/issues/570#issuecomment-313933276), 
and want to do everything possible to prevent such problems for my own 
package.  (To be clear: I don't think the Sirupsen problem in particular 
will affect me, since it's not just a capitalization change).

Keep in mind that the package has sub-packages as a dependencies (i.e. 
github.com/flimzy/kivik dependson github.com/flimzy/kivik/errors), in case 
this complicates things.

Thank you,

Jonathan

-- 
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-02 Thread matthewjuran
Stockfish, not Clownfish - sorry.

An option is hosting the Stockfish engine over HTTP or TCP, that way Go can 
be used for calling into Stockfish (cgo), you get experience with Go 
networking (the use case with likely the best online support), and your 
interface can be anything that does HTTP or TCP.

Writing a chess engine is easier than you may think, those algorithms are 
meant to speed up computer moves and computer analysis, neither of which 
are necessary to play the game. My engine has none of that and is not 
optimized at all and doesn't do any caching between the database and still 
responds to making a move or calculating all moves for a position within 5 
milliseconds. Just be ready to hack a little for promotion, en passant, and 
castling.

I think what I was getting to earlier is that Go would benefit from 
official corporate and academic partners (that foundation) because if 
Google goes then probably Go does too, for any significant commercial or 
academic use at least.

Matt

On Friday, December 1, 2017 at 10:11:43 PM UTC-6, Hugh Aguilar wrote:
>
>
>
> On Friday, December 1, 2017 at 8:47:50 PM UTC-7, Bakul Shah wrote:
>
>> There seem to be many chess related  packages: 
>> https://golanglibs.com/top?q=chess 
>>
>
> I'll look into these --- thanks --- I was not aware of this golanglibs 
> website.
>  
>

-- 
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-02 Thread skaldendudler



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 all handlers
>>>  router.GET("/entities/:type/map", h.UseHandler(
>>> ApiGetEntitiesMapRequest{}, p))
>>>
>>>
>>> And my handler looks like this:
>>>
>>>
>>>  func (req ApiGetEntitiesMapRequest) Handle(r *http.Request, hrp 

Re: [go-nuts] aws lambda native support for go in a few weeks

2017-12-02 Thread Henrik Johansson
Now we have to rewrite all our apps to use Lambda :D

Joking aside, it is cool and good news!

lör 2 dec. 2017 kl 00:38 skrev JM :

> just announced this week at re:invent. also cloud 9 the new dev ide also
> supports go.
>
> In case anyone cares ^^^
>
> --
> 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] GC SW times on Heroku (Beta metrics)

2017-12-02 Thread Henrik Johansson
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.