Linked by Thom Holwerda on Wed 28th Mar 2012 19:22 UTC
General Development "Today marks a major milestone in the development of the Go programming language. We're announcing Go version 1, or Go 1 for short, which defines a language and a set of core libraries to provide a stable foundation for creating reliable products, projects, and publications. Go 1 is the first release of Go that is available in supported binary distributions. They are available for Linux, FreeBSD, Mac OS X and, we are thrilled to announce, Windows."
Thread beginning with comment 512375
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[3]: Too bad it is so slow
by voidlogic on Thu 29th Mar 2012 22:22 UTC in reply to "RE[2]: Too bad it is so slow"
voidlogic
Member since:
2005-09-03

So I'm looking at your programs, are they both being called when someone navigates to the URL? Or are you just statically servering the .c file (which would make no sense)?

If some kind of CGI is running your C program, then it is doing less work:

puts("Hello World!\n");
VS.
fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])

Your Go program should be:
fmt.Print("Hello World!\n")

Also, I assume whatever CGI is running your C program is not using chunking, so you should set your Go response to also not use chunking... I also assume the C CGI is not putting the date/time in the response header, go is by default to you should tell it not to.

Reply Parent Score: 2

RE[4]: Too bad it is so slow
by kalcytriol on Thu 29th Mar 2012 23:19 in reply to "RE[3]: Too bad it is so slow"
kalcytriol Member since:
2011-04-23

Sorry posted a wrong code the correct one is:

fmt.Fprintf(w, "Hello World")


Result is correct. You can see it in this line:
Document Length: 11 bytes

fmt.Pritf() prints into terminal, not to response string.

I run test again with original hello code and result was (req per second):
10441.31 [#/sec] (mean)
VS
10038.96 [#/sec] (mean) (old)

Almost the same.

Im using http://gwan.ch/ (G-WAN) as a C servlet server.

Edited 2012-03-29 23:36 UTC

Reply Parent Score: 1

RE[4]: Too bad it is so slow
by kalcytriol on Fri 30th Mar 2012 01:35 in reply to "RE[3]: Too bad it is so slow"
kalcytriol Member since:
2011-04-23

Without chunking:
19k RPS. not bad, but still below level of ecceptance.
330% diference. I could accept 50% max
Incresed CPU time = wasted money.


Both response headers:
--------------------------------------------------- C Serv
HTTP/1.1 200 OK
Server: G-WAN
Date: Thu, 29 Mar 2012 23:47:36 GMT
Last-Modified: Thu, 29 Mar 2012 23:47:36 GMT
Etag: "441d9cc1-4f74f498-b"
Vary: Accept-Encoding
Accept-Ranges: bytes
Content-Type: text/html; charset=UTF-8
Content-Length: 11
Connection: Keep-Alive
---------------------------------------------------- Go
HTTP/1.1 200 OK
Content-Length: 11
Content-Type: text/plain
Date: Fri, 30 Mar 2012 01:16:24 GMT
----------------------------------------------------------

BTW do you know any other optimization tricks?

Another thing is a heavy lack of documentation. I wasted a lot of time just to find how to write to header. Yes, Id found it but in some other part of internet. At least their search engine is fine (Google).

Reply Parent Score: 1

RE[5]: Too bad it is so slow
by voidlogic on Fri 30th Mar 2012 18:34 in reply to "RE[4]: Too bad it is so slow"
voidlogic Member since:
2005-09-03

"BTW do you know any other optimization tricks?"
I'd be happy to take a look, can you post a link to your latest code?

As far as documentation, check out http://golang.org/pkg/

Specifically regarding headers: http://golang.org/pkg/net/http/#Header

Reply Parent Score: 2