func main() {

        profiler := profile.Start()

        var (
               id int32 = 0
               connCount int32 = 0

        c := make(chan os.Signal, 1)
        signal.Notify(c, os.Interrupt)
        signal.Notify(c, syscall.SIGTERM)
        go func() {
               fmt.Println("total messages received:", totalMsgCount)

I did something like this.
On Wednesday, May 18, 2016 at 2:02:50 PM UTC+3, Dave Cheney wrote:

You've used the profile package incorrectly. The examples show how to use
it correctly.

import "github.com/pkg/profile"
func main() {
defer profile.Start().Stop()

On Wednesday, 18 May 2016 17:27:13 UTC+10, Rayland wrote:

I used the profiler correctly but the profile output file is empty.
On Tuesday, May 17, 2016 at 7:06:30 PM UTC+3, Manlio Perillo wrote:

Il giorno martedì 17 maggio 2016 17:58:07 UTC+2, Manlio Perillo ha
Il giorno martedì 17 maggio 2016 16:36:07 UTC+2, Rayland ha scritto:
I have a TCP server saving messages received from clients to a
Coucbase DB. Besides this I also increase a counter for each inserted

The insert and counter update are done in goroutines.

I see very big differences between the number of messages I get on
server and the number of messages inserted in Couchbase DB.

If I use only one Couchbase bucket connection the difference is much

How can I ensure that all messages are saved?
1) You should check all the errors returned by Couchbase.
2) Are you sure you are using counters correctly?
The function signature is:
func (b *Bucket <https://godoc.org/github.com/couchbase/gocb#Bucket>)
Counter(key string <https://godoc.org/builtin#string>, delta, initial
int64 <https://godoc.org/builtin#int64>, expiry uint32
<https://godoc.org/builtin#uint32>) (uint64
<https://godoc.org/builtin#uint64>, Cas
<https://godoc.org/github.com/couchbase/gocb#Cas>, error

In your code you are setting expiry to 1 second, AFAIK.
This means that the counter is reset every seconds (again, AFAIK).
3) Do not call the Insert and Counter methods in separate goroutine.
Start with a simple implementation, and only use additional
goroutines if necessary.
4) You are using the profiler incorrectly.

The Start method should be called at the start of the program,
and Stop and the end.
The package README suggests:

func main() {
defer profile.Start().Stop()

but your code is wrong, since you are calling Start and Stop
at the same time, at the end of the program!

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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 10 of 15 | next ›
Discussion Overview
groupgolang-nuts @
postedMay 17, '16 at 2:36p
activeMay 20, '16 at 1:17p



site design / logo © 2021 Grokbase