You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@inlong.apache.org by "davendu (via GitHub)" <gi...@apache.org> on 2024/12/13 09:16:51 UTC

[I] [Improve]Speed up UUID generate for Golang SDK [inlong]

davendu opened a new issue, #11597:
URL: https://github.com/apache/inlong/issues/11597

   ### Description
   
   Currently the Golang SDK use `github.com/gofrs/uuid` for UUIDv4 generation. Due to randomness requirement of UUIDv4, the performance is decided by the entropy pool of runtime, which usually means a IO bottleneck.
   
   Another package `github.com/google/uuid` could provide better performance by optionally enable the random pool. Here is the benchmark on my server running Linux :
   
   ```
   > go test -bench=. -test.count=16 ./uuid_benchmark_test.go | summary
   goos: linux
   goarch: amd64
   cpu: Intel(R) Xeon(R) Gold 6133 CPU @ 2.50GHz
   Name                               Count-Avg (N)   AvgTime - Avg,Max,Min,Stdeva (ns/op)
   BenchmarkGofrsUUID-8               1408388.188	  845.35	854	840.6	3.63
   BenchmarkGoogleUUIDEnablePool-8    9252526.375	  129.15	133.2	128.2	1.35
   BenchmarkGoogleUUIDDisablePool-8   1408379.063	  853.21	865.5	845	6.29
   ```
   
   Here is the test code:
   
   ```golang
   package uuid_benchmark
   
   import (
   	"testing"
   
   	gofrs "github.com/gofrs/uuid"     // using v4.4.0+incompatible
   	google "github.com/google/uuid"   // using v1.3.0
   )
   
   func BenchmarkGofrsUUID(b *testing.B) {
   	for i := 0; i < b.N; i++ {
   		_, err := gofrs.NewV4()
   		if err != nil {
   			b.Error(err)
   		}
   	}
   }
   
   func BenchmarkGoogleUUIDEnablePool(b *testing.B) {
   	google.EnableRandPool()
   	for i := 0; i < b.N; i++ {
   		_ = google.New()
   	}
   }
   
   func BenchmarkGoogleUUIDDisablePool(b *testing.B) {
   	google.DisableRandPool()
   	for i := 0; i < b.N; i++ {
   		_ = google.New()
   	}
   }
   ```
   
   Note that users should enable the feature by calling `google.EnableRandPool()` manually, which does not provides concurrent safety.
   
   
   ### InLong Component
   
   InLong SDK
   
   ### Are you willing to submit PR?
   
   - [X] Yes, I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@inlong.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Improve]Optimize the generation speed of UUIDv4 for Golang SDK [inlong]

Posted by "dockerzhang (via GitHub)" <gi...@apache.org>.
dockerzhang closed issue #11597: [Improve]Optimize the generation speed of UUIDv4 for Golang SDK
URL: https://github.com/apache/inlong/issues/11597


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Improve]Speed up UUID generate for Golang SDK [inlong]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #11597:
URL: https://github.com/apache/inlong/issues/11597#issuecomment-2540955033

   Hello @davendu, thank you for opening your first issue in InLong ๐Ÿงก We will respond as soon as possible โณ
   If this is a bug report, please provide screenshots or error logs for us to reproduce your issue, so we can do our best to fix it.
   If you have any questions in the meantime, you can also ask us on the [InLong Discussions](https://github.com/apache/inlong/discussions) ๐Ÿ”


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org