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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to