<pre class="notranslate">reported via private email

g% cat &gt;/tmp/x.go
package main

import (
    "time"
)

// fatal error: unexpected signal during runtime execution
func main() {
    ch := make(chan struct{})

    go func() {
        t := time.Timer{}
        t.Reset(1)
        &lt;-ch
    }()

    ch &lt;- struct{}{}
}
g% go run /tmp/x.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x13f46]

goroutine 5 [running]:
runtime.gopanic(0x5b6c0, 0x2080d2060)
    /Users/rsc/g/go/src/runtime/panic.go:426 +0x2a3
runtime.panicmem()
    /Users/rsc/g/go/src/runtime/panic.go:42 +0x4e
runtime.sigpanic()
    /Users/rsc/g/go/src/runtime/sigpanic_unix.go:26 +0x270
runtime.timerproc()
    /Users/rsc/g/go/src/runtime/time.go:194 +0x216
runtime.goexit()
    /Users/rsc/g/go/src/runtime/proc.c:1651

goroutine 1 [runnable]:
main.main()
    /tmp/x.go:17 +0xe3
exit status 2
g%</pre>
<p dir="auto">by <strong>raheelgup</strong>:</p>
<pre class="notranslate">Hi,

This is in reference to the crypto/tls package which is very slow and CPU intensive than
it should be.
I had been discussing this here :
<a href="https://groups.google.com/forum/?fromgroups=#" rel="nofollow">https://groups.google.com/forum/?fromgroups=#</a>!topic/golang-nuts/QTDzrcDQmmw

I am using the following example as on the main go docs :
<a href="http://golang.org/pkg/net/http/#ListenAndServeTLS" rel="nofollow">http://golang.org/pkg/net/http/#ListenAndServeTLS</a>

I did a performance check on Windows 7 64 Bit for HTTPS connections and it is surprising
that it really performs badly.
My test methodology is simple, press F5 continously in chrome.
The CPU shot to 25-50% and the RAM also kept on increasing.
During the constant refresh, there are many "Connection was reset" messages. 

As against this the normal ListenAndServe example is very stable. I did an ab.exe -n
10000 -c 1000 <a href="http://127.0.0.1:PORT/index.html" rel="nofollow">http://127.0.0.1:PORT/index.html</a> and it completes it in 60-70 seconds. The
MAX CPU touches 9-10% and RAM usage increases a little BIT and after the requests are
complete, it reaches near the previous RAM usage.

Adam from Golang also did a profiling :
(pprof) top10 -cum
Total: 1075 samples
       0   0.0%   0.0%      827  76.9% schedunlock
       0   0.0%   0.0%      822  76.5% net/http.(*conn).serve
       0   0.0%   0.0%      813  75.6% crypto/tls.(*Conn).Handshake
       0   0.0%   0.0%      813  75.6% crypto/tls.(*Conn).serverHandshake
       2   0.2%   0.2%      578  53.8% crypto/elliptic.(*CurveParams).ScalarMult
       0   0.0%   0.2%      495  46.0% crypto/tls.(*ecdheRSAKeyAgreement).generateServerKeyExchange
       9   0.8%   1.0%      449  41.8% math/big.nat.div
     135  12.6%  13.6%      431  40.1% math/big.nat.divLarge
       8   0.7%  14.3%      347  32.3% math/big.(*Int).Mod
       2   0.2%  14.5%      343  31.9% math/big.(*Int).QuoRem

So 75% of the time is being taken in handshaking and the rest is probably taken in
dealing with the garbage from that.

SO I am wondering if this can be fixed in the next GO Version.

Regards,
R</pre>