Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

The study of non-linear physics is like the study of non-elephant biology.


devel / comp.lang.mumps / Why Go wrapper for YottaDB so slow?

SubjectAuthor
* Why Go wrapper for YottaDB so slow?Сергей Каменев
`* Re: Why Go wrapper for YottaDB so slow?K.S. Bhaskar
 `* Re: Why Go wrapper for YottaDB so slow?Сергей Каменев
  `* Re: Why Go wrapper for YottaDB so slow?K.S. Bhaskar
   `* Re: Why Go wrapper for YottaDB so slow?Сергей Каменев
    `* Re: Why Go wrapper for YottaDB so slow?K.S. Bhaskar
     `* Re: Why Go wrapper for YottaDB so slow?Сергей Каменев
      `- Re: Why Go wrapper for YottaDB so slow?K.S. Bhaskar

1
Why Go wrapper for YottaDB so slow?

<b487638d-d1fa-49ae-b41e-a57fe35d5c82n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=205&group=comp.lang.mumps#205

  copy link   Newsgroups: comp.lang.mumps
X-Received: by 2002:a05:620a:170d:: with SMTP id az13mr14694408qkb.505.1635184078327;
Mon, 25 Oct 2021 10:47:58 -0700 (PDT)
X-Received: by 2002:a05:620a:2889:: with SMTP id j9mr15146365qkp.135.1635184077948;
Mon, 25 Oct 2021 10:47:57 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.mumps
Date: Mon, 25 Oct 2021 10:47:57 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=193.107.193.43; posting-account=eaShnQoAAABLy95ZTEb7H0YHkVXcD4qO
NNTP-Posting-Host: 193.107.193.43
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b487638d-d1fa-49ae-b41e-a57fe35d5c82n@googlegroups.com>
Subject: Why Go wrapper for YottaDB so slow?
From: sukamenev@gmail.com (Сергей Каменев)
Injection-Date: Mon, 25 Oct 2021 17:47:58 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 70
 by: Сергей Кам - Mon, 25 Oct 2021 17:47 UTC

Hi!

Inserts through the Go wrapper are about 10 times slower comparing with M.
By inserting 1M of values.

time ./speedYotta

real 0m13,728s
user 0m18,737s
sys 0m0,914s

time yottadb -run ^speedYotta

real 0m1,617s
user 0m1,326s
sys 0m0,278s

time ./sY1

real 0m13,075s
user 0m18,786s
sys 0m0,751s

Source codes:
=== speedYotta.go ===
-------------------
package main

import (
"lang.yottadb.com/go/yottadb"
"strconv"
)

func main() {

defer yottadb.Exit()

s := ""
for i := 1; i < 1000000; i++ {
s = strconv.Itoa(i)
yottadb.SetValE(yottadb.NOTTP, nil, s, "^hello", []string{s})
}
} -------------------------

=== speedYotta.m ===
---------------------------
speedYotta

for i=0:1:1000000 do
. set ^a(i)=i
---------------------------

=== sY1.go ===
---------------------------
package main

import (
"lang.yottadb.com/go/yottadb"
"strconv"
)

func main() {
defer yottadb.Exit()

s := strconv.Itoa(5)
for i := 1; i < 1000000; i++ {
yottadb.SetValE(yottadb.NOTTP, nil, s, "^hello", []string{s})
}
} ---------------------------

Re: Why Go wrapper for YottaDB so slow?

<d43aeb03-df58-4982-9b40-29bcbc0325d8n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=206&group=comp.lang.mumps#206

  copy link   Newsgroups: comp.lang.mumps
X-Received: by 2002:a05:6214:4112:: with SMTP id kc18mr17447700qvb.11.1635187483654;
Mon, 25 Oct 2021 11:44:43 -0700 (PDT)
X-Received: by 2002:a05:622a:ca:: with SMTP id p10mr18874782qtw.207.1635187483415;
Mon, 25 Oct 2021 11:44:43 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.mumps
Date: Mon, 25 Oct 2021 11:44:43 -0700 (PDT)
In-Reply-To: <b487638d-d1fa-49ae-b41e-a57fe35d5c82n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=71.162.243.192; posting-account=zTPg1AoAAABx_LtAQ3dW6FBnU1dwmSvl
NNTP-Posting-Host: 71.162.243.192
References: <b487638d-d1fa-49ae-b41e-a57fe35d5c82n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d43aeb03-df58-4982-9b40-29bcbc0325d8n@googlegroups.com>
Subject: Re: Why Go wrapper for YottaDB so slow?
From: ksbhaskar@gmail.com (K.S. Bhaskar)
Injection-Date: Mon, 25 Oct 2021 18:44:43 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 85
 by: K.S. Bhaskar - Mon, 25 Oct 2021 18:44 UTC

On Monday, October 25, 2021 at 1:47:58 PM UTC-4, suka...@gmail.com wrote:
> Hi!
>
> Inserts through the Go wrapper are about 10 times slower comparing with M..
> By inserting 1M of values.
>
> time ./speedYotta
>
> real 0m13,728s
> user 0m18,737s
> sys 0m0,914s
>
> time yottadb -run ^speedYotta
>
> real 0m1,617s
> user 0m1,326s
> sys 0m0,278s
>
> time ./sY1
>
> real 0m13,075s
> user 0m18,786s
> sys 0m0,751s
>
> Source codes:
> === speedYotta.go ===
> -------------------
> package main
>
> import (
> "lang.yottadb.com/go/yottadb"
> "strconv"
> )
>
> func main() {
>
> defer yottadb.Exit()
>
> s := ""
> for i := 1; i < 1000000; i++ {
> s = strconv.Itoa(i)
> yottadb.SetValE(yottadb.NOTTP, nil, s, "^hello", []string{s})
> }
> }
> -------------------------
>
> === speedYotta.m ===
> ---------------------------
> speedYotta
>
> for i=0:1:1000000 do
> . set ^a(i)=i
> ---------------------------
>
> === sY1.go ===
> ---------------------------
> package main
>
> import (
> "lang.yottadb.com/go/yottadb"
> "strconv"
> )
>
> func main() {
> defer yottadb.Exit()
>
> s := strconv.Itoa(5)
> for i := 1; i < 1000000; i++ {
> yottadb.SetValE(yottadb.NOTTP, nil, s, "^hello", []string{s})
> }
> }
> ---------------------------

There are two reasons. The biggest one is that CGO is heavyweight. A much smaller one is the way Go does garbage collection emphasizes predictable response time, the way that YottaDB does garbage collection is to minimize CPU usage. You are basically doing what I'd call a “point” benchmark. In the context of a complete application, where an application executes business logic interspersed with database accesses, you are likely to find different performance characteristics. For example, Go's applications using Goroutines may execute business logic faster than M's single flow-of-control code execution.

Regards
– Bhaskar

Re: Why Go wrapper for YottaDB so slow?

<602c695b-e4b4-4628-911a-5f9725e043can@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=207&group=comp.lang.mumps#207

  copy link   Newsgroups: comp.lang.mumps
X-Received: by 2002:ac8:3d49:: with SMTP id u9mr20195101qtf.264.1635188419447;
Mon, 25 Oct 2021 12:00:19 -0700 (PDT)
X-Received: by 2002:a05:620a:448e:: with SMTP id x14mr14843745qkp.406.1635188419084;
Mon, 25 Oct 2021 12:00:19 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.mumps
Date: Mon, 25 Oct 2021 12:00:18 -0700 (PDT)
In-Reply-To: <d43aeb03-df58-4982-9b40-29bcbc0325d8n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=193.107.193.43; posting-account=eaShnQoAAABLy95ZTEb7H0YHkVXcD4qO
NNTP-Posting-Host: 193.107.193.43
References: <b487638d-d1fa-49ae-b41e-a57fe35d5c82n@googlegroups.com> <d43aeb03-df58-4982-9b40-29bcbc0325d8n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <602c695b-e4b4-4628-911a-5f9725e043can@googlegroups.com>
Subject: Re: Why Go wrapper for YottaDB so slow?
From: sukamenev@gmail.com (Сергей Каменев)
Injection-Date: Mon, 25 Oct 2021 19:00:19 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 87
 by: Сергей Кам - Mon, 25 Oct 2021 19:00 UTC

Is it potentially possible to increase the speed of the CGO wrapper?

Sergey.

> > Hi!
> >
> > Inserts through the Go wrapper are about 10 times slower comparing with M.
> > By inserting 1M of values.
> >
> > time ./speedYotta
> >
> > real 0m13,728s
> > user 0m18,737s
> > sys 0m0,914s
> >
> > time yottadb -run ^speedYotta
> >
> > real 0m1,617s
> > user 0m1,326s
> > sys 0m0,278s
> >
> > time ./sY1
> >
> > real 0m13,075s
> > user 0m18,786s
> > sys 0m0,751s
> >
> > Source codes:
> > === speedYotta.go ===
> > -------------------
> > package main
> >
> > import (
> > "lang.yottadb.com/go/yottadb"
> > "strconv"
> > )
> >
> > func main() {
> >
> > defer yottadb.Exit()
> >
> > s := ""
> > for i := 1; i < 1000000; i++ {
> > s = strconv.Itoa(i)
> > yottadb.SetValE(yottadb.NOTTP, nil, s, "^hello", []string{s})
> > }
> > }
> > -------------------------
> >
> > === speedYotta.m ===
> > ---------------------------
> > speedYotta
> >
> > for i=0:1:1000000 do
> > . set ^a(i)=i
> > ---------------------------
> >
> > === sY1.go ===
> > ---------------------------
> > package main
> >
> > import (
> > "lang.yottadb.com/go/yottadb"
> > "strconv"
> > )
> >
> > func main() {
> > defer yottadb.Exit()
> >
> > s := strconv.Itoa(5)
> > for i := 1; i < 1000000; i++ {
> > yottadb.SetValE(yottadb.NOTTP, nil, s, "^hello", []string{s})
> > }
> > }
> > ---------------------------
> There are two reasons. The biggest one is that CGO is heavyweight. A much smaller one is the way Go does garbage collection emphasizes predictable response time, the way that YottaDB does garbage collection is to minimize CPU usage. You are basically doing what I'd call a “point” benchmark. In the context of a complete application, where an application executes business logic interspersed with database accesses, you are likely to find different performance characteristics. For example, Go's applications using Goroutines may execute business logic faster than M's single flow-of-control code execution.
>
> Regards
> – Bhaskar

Re: Why Go wrapper for YottaDB so slow?

<1d93b744-089a-4667-a91d-e8abf3122365n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=208&group=comp.lang.mumps#208

  copy link   Newsgroups: comp.lang.mumps
X-Received: by 2002:aed:2791:: with SMTP id a17mr19900585qtd.34.1635190224854;
Mon, 25 Oct 2021 12:30:24 -0700 (PDT)
X-Received: by 2002:ac8:7d87:: with SMTP id c7mr19886202qtd.413.1635190224642;
Mon, 25 Oct 2021 12:30:24 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.mumps
Date: Mon, 25 Oct 2021 12:30:24 -0700 (PDT)
In-Reply-To: <602c695b-e4b4-4628-911a-5f9725e043can@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=71.162.243.192; posting-account=zTPg1AoAAABx_LtAQ3dW6FBnU1dwmSvl
NNTP-Posting-Host: 71.162.243.192
References: <b487638d-d1fa-49ae-b41e-a57fe35d5c82n@googlegroups.com>
<d43aeb03-df58-4982-9b40-29bcbc0325d8n@googlegroups.com> <602c695b-e4b4-4628-911a-5f9725e043can@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1d93b744-089a-4667-a91d-e8abf3122365n@googlegroups.com>
Subject: Re: Why Go wrapper for YottaDB so slow?
From: ksbhaskar@gmail.com (K.S. Bhaskar)
Injection-Date: Mon, 25 Oct 2021 19:30:24 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 97
 by: K.S. Bhaskar - Mon, 25 Oct 2021 19:30 UTC

On Monday, October 25, 2021 at 3:00:19 PM UTC-4, suka...@gmail.com wrote:
> Is it potentially possible to increase the speed of the CGO wrapper?
>
> Sergey.
> > > Hi!
> > >
> > > Inserts through the Go wrapper are about 10 times slower comparing with M.
> > > By inserting 1M of values.
> > >
> > > time ./speedYotta
> > >
> > > real 0m13,728s
> > > user 0m18,737s
> > > sys 0m0,914s
> > >
> > > time yottadb -run ^speedYotta
> > >
> > > real 0m1,617s
> > > user 0m1,326s
> > > sys 0m0,278s
> > >
> > > time ./sY1
> > >
> > > real 0m13,075s
> > > user 0m18,786s
> > > sys 0m0,751s
> > >
> > > Source codes:
> > > === speedYotta.go ===
> > > -------------------
> > > package main
> > >
> > > import (
> > > "lang.yottadb.com/go/yottadb"
> > > "strconv"
> > > )
> > >
> > > func main() {
> > >
> > > defer yottadb.Exit()
> > >
> > > s := ""
> > > for i := 1; i < 1000000; i++ {
> > > s = strconv.Itoa(i)
> > > yottadb.SetValE(yottadb.NOTTP, nil, s, "^hello", []string{s})
> > > }
> > > }
> > > -------------------------
> > >
> > > === speedYotta.m ===
> > > ---------------------------
> > > speedYotta
> > >
> > > for i=0:1:1000000 do
> > > . set ^a(i)=i
> > > ---------------------------
> > >
> > > === sY1.go ===
> > > ---------------------------
> > > package main
> > >
> > > import (
> > > "lang.yottadb.com/go/yottadb"
> > > "strconv"
> > > )
> > >
> > > func main() {
> > > defer yottadb.Exit()
> > >
> > > s := strconv.Itoa(5)
> > > for i := 1; i < 1000000; i++ {
> > > yottadb.SetValE(yottadb.NOTTP, nil, s, "^hello", []string{s})
> > > }
> > > }
> > > ---------------------------
> > There are two reasons. The biggest one is that CGO is heavyweight. A much smaller one is the way Go does garbage collection emphasizes predictable response time, the way that YottaDB does garbage collection is to minimize CPU usage. You are basically doing what I'd call a “point” benchmark. In the context of a complete application, where an application executes business logic interspersed with database accesses, you are likely to find different performance characteristics. For example, Go's applications using Goroutines may execute business logic faster than M's single flow-of-control code execution.
> >
> > Regards
> > – Bhaskar

There has been much discussion of CGO overhead on the golang-nuts discussion group.

Incidentally, you are using the YottaDB Go Easy API. You may find the Go Simple API to be a bit faster, although I don't know how much faster it will be for you.

Regards
– Bhaskar

Re: Why Go wrapper for YottaDB so slow?

<6281719d-db22-43a9-86ca-0d524e1316e2n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=212&group=comp.lang.mumps#212

  copy link   Newsgroups: comp.lang.mumps
X-Received: by 2002:a05:620a:5e4:: with SMTP id z4mr18998575qkg.395.1635257069518;
Tue, 26 Oct 2021 07:04:29 -0700 (PDT)
X-Received: by 2002:a37:6801:: with SMTP id d1mr18789925qkc.526.1635257069154;
Tue, 26 Oct 2021 07:04:29 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.mumps
Date: Tue, 26 Oct 2021 07:04:28 -0700 (PDT)
In-Reply-To: <1d93b744-089a-4667-a91d-e8abf3122365n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=193.107.193.43; posting-account=eaShnQoAAABLy95ZTEb7H0YHkVXcD4qO
NNTP-Posting-Host: 193.107.193.43
References: <b487638d-d1fa-49ae-b41e-a57fe35d5c82n@googlegroups.com>
<d43aeb03-df58-4982-9b40-29bcbc0325d8n@googlegroups.com> <602c695b-e4b4-4628-911a-5f9725e043can@googlegroups.com>
<1d93b744-089a-4667-a91d-e8abf3122365n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6281719d-db22-43a9-86ca-0d524e1316e2n@googlegroups.com>
Subject: Re: Why Go wrapper for YottaDB so slow?
From: sukamenev@gmail.com (Сергей Каменев)
Injection-Date: Tue, 26 Oct 2021 14:04:29 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 201
 by: Сергей Кам - Tue, 26 Oct 2021 14:04 UTC

> > Is it potentially possible to increase the speed of the CGO wrapper?
> >
> > Sergey.
> > > > Hi!
> > > >
> > > > Inserts through the Go wrapper are about 10 times slower comparing with M.
> > > > By inserting 1M of values.
> > > >
> > > > time ./speedYotta
> > > >
> > > > real 0m13,728s
> > > > user 0m18,737s
> > > > sys 0m0,914s
> > > >
> > > > time yottadb -run ^speedYotta
> > > >
> > > > real 0m1,617s
> > > > user 0m1,326s
> > > > sys 0m0,278s
> > > >
> > > > time ./sY1
> > > >
> > > > real 0m13,075s
> > > > user 0m18,786s
> > > > sys 0m0,751s
> > > >
> > > > Source codes:
> > > > === speedYotta.go ===
> > > > -------------------
> > > > package main
> > > >
> > > > import (
> > > > "lang.yottadb.com/go/yottadb"
> > > > "strconv"
> > > > )
> > > >
> > > > func main() {
> > > >
> > > > defer yottadb.Exit()
> > > >
> > > > s := ""
> > > > for i := 1; i < 1000000; i++ {
> > > > s = strconv.Itoa(i)
> > > > yottadb.SetValE(yottadb.NOTTP, nil, s, "^hello", []string{s})
> > > > }
> > > > }
> > > > -------------------------
> > > >
> > > > === speedYotta.m ===
> > > > ---------------------------
> > > > speedYotta
> > > >
> > > > for i=0:1:1000000 do
> > > > . set ^a(i)=i
> > > > ---------------------------
> > > >
> > > > === sY1.go ===
> > > > ---------------------------
> > > > package main
> > > >
> > > > import (
> > > > "lang.yottadb.com/go/yottadb"
> > > > "strconv"
> > > > )
> > > >
> > > > func main() {
> > > > defer yottadb.Exit()
> > > >
> > > > s := strconv.Itoa(5)
> > > > for i := 1; i < 1000000; i++ {
> > > > yottadb.SetValE(yottadb.NOTTP, nil, s, "^hello", []string{s})
> > > > }
> > > > }
> > > > ---------------------------
> > > There are two reasons. The biggest one is that CGO is heavyweight. A much smaller one is the way Go does garbage collection emphasizes predictable response time, the way that YottaDB does garbage collection is to minimize CPU usage. You are basically doing what I'd call a “point” benchmark. In the context of a complete application, where an application executes business logic interspersed with database accesses, you are likely to find different performance characteristics. For example, Go's applications using Goroutines may execute business logic faster than M's single flow-of-control code execution.
> > >
> > > Regards
> > > – Bhaskar
> There has been much discussion of CGO overhead on the golang-nuts discussion group.
>
> Incidentally, you are using the YottaDB Go Easy API. You may find the Go Simple API to be a bit faster, although I don't know how much faster it will be for you.
>
> Regards
> – Bhaskar

Thank you, Bhaskar!

Yes, Go Simple API 3 times faster comparing with Go Easy API.
And Go Simple API 3 times slower comparing with native M code for inserting..

time ./speedYSimple

real 0m4,391s
user 0m4,250s
sys 0m0,570s

If we move some operations per cycle, then

time ./speedYSimple1

real 0m3,425s
user 0m3,296s
sys 0m0,458s

=== Code of speedYSimple.go: ====
package main

import (
"lang.yottadb.com/go/yottadb"
"strconv"
)

const maxglnamelen uint32 = 8
const maxglsubscount uint32 = 1
const maxglsubslen uint32 = 10 //128
const tptoken uint64 = yottadb.NOTTP

func main() {
var glname yottadb.KeyT
var errstr, value yottadb.BufferT

value.Alloc(maxglsubslen)
errstr.Alloc(yottadb.YDB_MAX_ERRORMSG)
glname.Alloc(maxglnamelen, maxglsubscount, maxglsubslen)

defer yottadb.Exit()

defer glname.Free()
defer errstr.Free()
defer value.Free()

s := ""
for i := 1; i < 1000000; i++ {
s = strconv.Itoa(i)

glname.Varnm.SetValStr(tptoken, &errstr, "^hello")
glname.Subary.SetElemUsed(tptoken, &errstr, maxglsubscount)
glname.Subary.SetValStr(tptoken, &errstr, 0, s)

value.SetValStr(tptoken, &errstr, s)

glname.SetValST(tptoken, &errstr, &value)
}
}

=== Code of speedYSimple1.go: ====
package main

import (
"lang.yottadb.com/go/yottadb"
"strconv"
)

const maxglnamelen uint32 = 8
const maxglsubscount uint32 = 1
const maxglsubslen uint32 = 10 //128
const tptoken uint64 = yottadb.NOTTP

func main() {
var glname yottadb.KeyT
var errstr, value yottadb.BufferT

value.Alloc(maxglsubslen)
errstr.Alloc(yottadb.YDB_MAX_ERRORMSG)
glname.Alloc(maxglnamelen, maxglsubscount, maxglsubslen)

defer yottadb.Exit()

defer glname.Free()
defer errstr.Free()
defer value.Free()

glname.Varnm.SetValStr(tptoken, &errstr, "^hello")
glname.Subary.SetElemUsed(tptoken, &errstr, maxglsubscount)

s := ""
for i := 1; i < 1000000; i++ {
s = strconv.Itoa(i)

glname.Subary.SetValStr(tptoken, &errstr, 0, s)

value.SetValStr(tptoken, &errstr, s)

glname.SetValST(tptoken, &errstr, &value)
}
}

Re: Why Go wrapper for YottaDB so slow?

<fe1137ef-0fd2-4f6f-befa-3e7b0fffde43n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=213&group=comp.lang.mumps#213

  copy link   Newsgroups: comp.lang.mumps
X-Received: by 2002:ae9:ebc2:: with SMTP id b185mr19280697qkg.491.1635263892048;
Tue, 26 Oct 2021 08:58:12 -0700 (PDT)
X-Received: by 2002:a05:6214:21a5:: with SMTP id t5mr15646562qvc.35.1635263891816;
Tue, 26 Oct 2021 08:58:11 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.mumps
Date: Tue, 26 Oct 2021 08:58:11 -0700 (PDT)
In-Reply-To: <6281719d-db22-43a9-86ca-0d524e1316e2n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=108.52.84.50; posting-account=zTPg1AoAAABx_LtAQ3dW6FBnU1dwmSvl
NNTP-Posting-Host: 108.52.84.50
References: <b487638d-d1fa-49ae-b41e-a57fe35d5c82n@googlegroups.com>
<d43aeb03-df58-4982-9b40-29bcbc0325d8n@googlegroups.com> <602c695b-e4b4-4628-911a-5f9725e043can@googlegroups.com>
<1d93b744-089a-4667-a91d-e8abf3122365n@googlegroups.com> <6281719d-db22-43a9-86ca-0d524e1316e2n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fe1137ef-0fd2-4f6f-befa-3e7b0fffde43n@googlegroups.com>
Subject: Re: Why Go wrapper for YottaDB so slow?
From: ksbhaskar@gmail.com (K.S. Bhaskar)
Injection-Date: Tue, 26 Oct 2021 15:58:12 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 199
 by: K.S. Bhaskar - Tue, 26 Oct 2021 15:58 UTC

On Tuesday, October 26, 2021 at 10:04:30 AM UTC-4, suka...@gmail.com wrote:
> > > Is it potentially possible to increase the speed of the CGO wrapper?
> > >
> > > Sergey.
> > > > > Hi!
> > > > >
> > > > > Inserts through the Go wrapper are about 10 times slower comparing with M.
> > > > > By inserting 1M of values.
> > > > >
> > > > > time ./speedYotta
> > > > >
> > > > > real 0m13,728s
> > > > > user 0m18,737s
> > > > > sys 0m0,914s
> > > > >
> > > > > time yottadb -run ^speedYotta
> > > > >
> > > > > real 0m1,617s
> > > > > user 0m1,326s
> > > > > sys 0m0,278s
> > > > >
> > > > > time ./sY1
> > > > >
> > > > > real 0m13,075s
> > > > > user 0m18,786s
> > > > > sys 0m0,751s
> > > > >
> > > > > Source codes:
> > > > > === speedYotta.go ===
> > > > > -------------------
> > > > > package main
> > > > >
> > > > > import (
> > > > > "lang.yottadb.com/go/yottadb"
> > > > > "strconv"
> > > > > )
> > > > >
> > > > > func main() {
> > > > >
> > > > > defer yottadb.Exit()
> > > > >
> > > > > s := ""
> > > > > for i := 1; i < 1000000; i++ {
> > > > > s = strconv.Itoa(i)
> > > > > yottadb.SetValE(yottadb.NOTTP, nil, s, "^hello", []string{s})
> > > > > }
> > > > > }
> > > > > -------------------------
> > > > >
> > > > > === speedYotta.m ===
> > > > > ---------------------------
> > > > > speedYotta
> > > > >
> > > > > for i=0:1:1000000 do
> > > > > . set ^a(i)=i
> > > > > ---------------------------
> > > > >
> > > > > === sY1.go ===
> > > > > ---------------------------
> > > > > package main
> > > > >
> > > > > import (
> > > > > "lang.yottadb.com/go/yottadb"
> > > > > "strconv"
> > > > > )
> > > > >
> > > > > func main() {
> > > > > defer yottadb.Exit()
> > > > >
> > > > > s := strconv.Itoa(5)
> > > > > for i := 1; i < 1000000; i++ {
> > > > > yottadb.SetValE(yottadb.NOTTP, nil, s, "^hello", []string{s})
> > > > > }
> > > > > }
> > > > > ---------------------------
> > > > There are two reasons. The biggest one is that CGO is heavyweight. A much smaller one is the way Go does garbage collection emphasizes predictable response time, the way that YottaDB does garbage collection is to minimize CPU usage. You are basically doing what I'd call a “point” benchmark. In the context of a complete application, where an application executes business logic interspersed with database accesses, you are likely to find different performance characteristics. For example, Go's applications using Goroutines may execute business logic faster than M's single flow-of-control code execution.
> > > >
> > > > Regards
> > > > – Bhaskar
> > There has been much discussion of CGO overhead on the golang-nuts discussion group.
> >
> > Incidentally, you are using the YottaDB Go Easy API. You may find the Go Simple API to be a bit faster, although I don't know how much faster it will be for you.
> >
> > Regards
> > – Bhaskar
> Thank you, Bhaskar!
>
> Yes, Go Simple API 3 times faster comparing with Go Easy API.
> And Go Simple API 3 times slower comparing with native M code for inserting.
>
> time ./speedYSimple
>
> real 0m4,391s
> user 0m4,250s
> sys 0m0,570s
>
> If we move some operations per cycle, then
>
> time ./speedYSimple1
>
> real 0m3,425s
> user 0m3,296s
> sys 0m0,458s
>
> === Code of speedYSimple.go: ====> package main
>
> import (
> "lang.yottadb.com/go/yottadb"
> "strconv"
> )
> const maxglnamelen uint32 = 8
> const maxglsubscount uint32 = 1
> const maxglsubslen uint32 = 10 //128
> const tptoken uint64 = yottadb.NOTTP
>
> func main() {
> var glname yottadb.KeyT
> var errstr, value yottadb.BufferT
>
> value.Alloc(maxglsubslen)
> errstr.Alloc(yottadb.YDB_MAX_ERRORMSG)
> glname.Alloc(maxglnamelen, maxglsubscount, maxglsubslen)
>
> defer yottadb.Exit()
>
> defer glname.Free()
> defer errstr.Free()
> defer value.Free()
> s := ""
> for i := 1; i < 1000000; i++ {
> s = strconv.Itoa(i)
> glname.Varnm.SetValStr(tptoken, &errstr, "^hello")
> glname.Subary.SetElemUsed(tptoken, &errstr, maxglsubscount)
> glname.Subary.SetValStr(tptoken, &errstr, 0, s)
>
> value.SetValStr(tptoken, &errstr, s)
>
> glname.SetValST(tptoken, &errstr, &value)
> }
> }
>
>
> === Code of speedYSimple1.go: ====> package main
>
> import (
> "lang.yottadb.com/go/yottadb"
> "strconv"
> )
> const maxglnamelen uint32 = 8
> const maxglsubscount uint32 = 1
> const maxglsubslen uint32 = 10 //128
> const tptoken uint64 = yottadb.NOTTP
>
> func main() {
> var glname yottadb.KeyT
> var errstr, value yottadb.BufferT
>
> value.Alloc(maxglsubslen)
> errstr.Alloc(yottadb.YDB_MAX_ERRORMSG)
> glname.Alloc(maxglnamelen, maxglsubscount, maxglsubslen)
>
> defer yottadb.Exit()
>
> defer glname.Free()
> defer errstr.Free()
> defer value.Free()
>
> glname.Varnm.SetValStr(tptoken, &errstr, "^hello")
> glname.Subary.SetElemUsed(tptoken, &errstr, maxglsubscount)
> s := ""
> for i := 1; i < 1000000; i++ {
> s = strconv.Itoa(i)
> glname.Subary.SetValStr(tptoken, &errstr, 0, s)
>
> value.SetValStr(tptoken, &errstr, s)
>
> glname.SetValST(tptoken, &errstr, &value)
> }
> }

Thanks for the update. I'm glad you found the simple API to be faster.

Regards
– Bhaskar

Re: Why Go wrapper for YottaDB so slow?

<7e453d58-154d-4657-9248-a44120b99797n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=215&group=comp.lang.mumps#215

  copy link   Newsgroups: comp.lang.mumps
X-Received: by 2002:a05:622a:11d6:: with SMTP id n22mr32164997qtk.337.1635342355863; Wed, 27 Oct 2021 06:45:55 -0700 (PDT)
X-Received: by 2002:a0c:f646:: with SMTP id s6mr976637qvm.1.1635342355609; Wed, 27 Oct 2021 06:45:55 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.mumps
Date: Wed, 27 Oct 2021 06:45:55 -0700 (PDT)
In-Reply-To: <fe1137ef-0fd2-4f6f-befa-3e7b0fffde43n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=193.107.193.43; posting-account=eaShnQoAAABLy95ZTEb7H0YHkVXcD4qO
NNTP-Posting-Host: 193.107.193.43
References: <b487638d-d1fa-49ae-b41e-a57fe35d5c82n@googlegroups.com> <d43aeb03-df58-4982-9b40-29bcbc0325d8n@googlegroups.com> <602c695b-e4b4-4628-911a-5f9725e043can@googlegroups.com> <1d93b744-089a-4667-a91d-e8abf3122365n@googlegroups.com> <6281719d-db22-43a9-86ca-0d524e1316e2n@googlegroups.com> <fe1137ef-0fd2-4f6f-befa-3e7b0fffde43n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7e453d58-154d-4657-9248-a44120b99797n@googlegroups.com>
Subject: Re: Why Go wrapper for YottaDB so slow?
From: sukamenev@gmail.com (Сергей Каменев)
Injection-Date: Wed, 27 Oct 2021 13:45:55 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 38
 by: Сергей Кам - Wed, 27 Oct 2021 13:45 UTC

Very good speed and very simple interface have "mg_go" extension.
https://github.com/chrisemunt/mg_go

I'm not sure if he knows how to handle Go-multithreading and parallel transactions correctly. But using it is very simple and pleasant.

time ./speedYMG

real 0m3,196s
user 0m3,069s
sys 0m0,326s

=== Code speedYMG.go ===
package main

import (
"mg_go"
)

func main() {
db := mg_go.New("YottaDB")
db.APImodule = "/usr/local/lib64/mg_dba.so"
db.Path = "/opt/yottadb/r1.32"
db.EnvVars = db.EnvVars + "ydb_dir=/home/inetstar/.yottadb\n"
db.EnvVars = db.EnvVars + "ydb_rel=r1.32_x86_64\n"
db.EnvVars = db.EnvVars + "ydb_gbldir=/home/inetstar/.yottadb/r1.32_x86_64/g/yottadb.gld\n"
db.EnvVars = db.EnvVars + "ydb_routines=/home/inetstar/.yottadb/r1.32_x86_64/o*(/root/.yottadb/r1.32_x86_64/r /home/inetstar/.yottadb/r) /opt/yottadb/r1.32/libyottadbutil.so\n"
db.EnvVars = db.EnvVars + "ydb_ci=/opt/yottadb/r1.32/zmgci.ci\n"
db.EnvVars = db.EnvVars + "\n"

db.Open()

defer db.Close()

gHello := db.Global("^hello")

for i := 1; i < 1000000; i++ {
gHello.Set(i, i)
}
}

Re: Why Go wrapper for YottaDB so slow?

<1dd2f096-95e8-4612-9c35-b68b7a4b72d6n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=216&group=comp.lang.mumps#216

  copy link   Newsgroups: comp.lang.mumps
X-Received: by 2002:a0c:80ec:: with SMTP id 99mr29602083qvb.53.1635344848869; Wed, 27 Oct 2021 07:27:28 -0700 (PDT)
X-Received: by 2002:a05:620a:2782:: with SMTP id g2mr8843169qkp.398.1635344848629; Wed, 27 Oct 2021 07:27:28 -0700 (PDT)
Path: i2pn2.org!rocksolid2!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.mumps
Date: Wed, 27 Oct 2021 07:27:28 -0700 (PDT)
In-Reply-To: <7e453d58-154d-4657-9248-a44120b99797n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=108.52.84.50; posting-account=zTPg1AoAAABx_LtAQ3dW6FBnU1dwmSvl
NNTP-Posting-Host: 108.52.84.50
References: <b487638d-d1fa-49ae-b41e-a57fe35d5c82n@googlegroups.com> <d43aeb03-df58-4982-9b40-29bcbc0325d8n@googlegroups.com> <602c695b-e4b4-4628-911a-5f9725e043can@googlegroups.com> <1d93b744-089a-4667-a91d-e8abf3122365n@googlegroups.com> <6281719d-db22-43a9-86ca-0d524e1316e2n@googlegroups.com> <fe1137ef-0fd2-4f6f-befa-3e7b0fffde43n@googlegroups.com> <7e453d58-154d-4657-9248-a44120b99797n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1dd2f096-95e8-4612-9c35-b68b7a4b72d6n@googlegroups.com>
Subject: Re: Why Go wrapper for YottaDB so slow?
From: ksbhaskar@gmail.com (K.S. Bhaskar)
Injection-Date: Wed, 27 Oct 2021 14:27:28 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 50
 by: K.S. Bhaskar - Wed, 27 Oct 2021 14:27 UTC

On Wednesday, October 27, 2021 at 9:45:56 AM UTC-4, suka...@gmail.com wrote:
> Very good speed and very simple interface have "mg_go" extension.
> https://github.com/chrisemunt/mg_go
>
> I'm not sure if he knows how to handle Go-multithreading and parallel transactions correctly. But using it is very simple and pleasant.
>
> time ./speedYMG
>
> real 0m3,196s
> user 0m3,069s
> sys 0m0,326s
>
> === Code speedYMG.go ===
> package main
>
> import (
> "mg_go"
> )
>
> func main() {
> db := mg_go.New("YottaDB")
> db.APImodule = "/usr/local/lib64/mg_dba.so"
> db.Path = "/opt/yottadb/r1.32"
> db.EnvVars = db.EnvVars + "ydb_dir=/home/inetstar/.yottadb\n"
> db.EnvVars = db.EnvVars + "ydb_rel=r1.32_x86_64\n"
> db.EnvVars = db.EnvVars + "ydb_gbldir=/home/inetstar/.yottadb/r1.32_x86_64/g/yottadb.gld\n"
> db.EnvVars = db.EnvVars + "ydb_routines=/home/inetstar/.yottadb/r1.32_x86_64/o*(/root/.yottadb/r1.32_x86_64/r /home/inetstar/.yottadb/r) /opt/yottadb/r1.32/libyottadbutil.so\n"
> db.EnvVars = db.EnvVars + "ydb_ci=/opt/yottadb/r1.32/zmgci.ci\n"
> db.EnvVars = db.EnvVars + "\n"
>
> db.Open()
>
> defer db.Close()
>
> gHello := db.Global("^hello")
> for i := 1; i < 1000000; i++ {
> gHello.Set(i, i)
> }
> }

That's good news, and if that works for you, please use it. Chris Munt does good work. The only thing to check is to make sure that it works well with Goroutines if your application uses them, as most applications do.

Regards
– Bhaskar

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor