Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bring loong64 support #154

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

Conversation

abner-chenc
Copy link

No description provided.

The purpose of this is to be portable to more architectures.

Signed-off-by: Guoqi Chen <[email protected]>
go get -d golang.org/x/sys@latest
go mod tidy

This brings in loong64 support.

Signed-off-by: Guoqi Chen <[email protected]>
@abner-chenc
Copy link
Author

go version go1.19 linux/loong64
go test -v ./...

=== RUN   TestGetOK
--- PASS: TestGetOK (1.50s)
=== RUN   TestGetErr
--- PASS: TestGetErr (1.51s)
=== RUN   TestGetOrSetOK
--- PASS: TestGetOrSetOK (1.50s)
=== RUN   TestGetOrSetErr
--- PASS: TestGetOrSetErr (2.00s)
=== RUN   TestSetDefault
--- PASS: TestSetDefault (0.00s)
=== RUN   TestDeleteIf
--- PASS: TestDeleteIf (0.00s)
=== RUN   TestClose
--- PASS: TestClose (0.30s)
=== RUN   TestExpire
--- PASS: TestExpire (0.00s)
PASS
ok  	github.com/bytedance/gopkg/cache/asynccache	(cached)
=== RUN   TestBreakerConsecutiveTrip
--- PASS: TestBreakerConsecutiveTrip (0.12s)
=== RUN   TestBreakerThresholdTrip
--- PASS: TestBreakerThresholdTrip (0.00s)
=== RUN   TestBreakerInstanceTrip
--- PASS: TestBreakerInstanceTrip (3.00s)
=== RUN   TestBreakerRateTrip
--- PASS: TestBreakerRateTrip (0.05s)
=== RUN   TestBreakerRateTrip2
--- PASS: TestBreakerRateTrip2 (9.77s)
=== RUN   TestBreakerReset
--- PASS: TestBreakerReset (0.00s)
=== RUN   TestBreakerConcurrent
--- PASS: TestBreakerConcurrent (0.10s)
=== RUN   TestPerPCounter
--- PASS: TestPerPCounter (0.04s)
=== RUN   TestMetricser1
--- PASS: TestMetricser1 (0.55s)
=== RUN   TestMetricser2
--- PASS: TestMetricser2 (2.51s)
=== RUN   TestPanel
--- PASS: TestPanel (0.02s)
=== RUN   TestPerPMetricser1
--- PASS: TestPerPMetricser1 (0.56s)
=== RUN   TestPerPMetricser2
--- PASS: TestPerPMetricser2 (2.51s)
PASS
ok  	github.com/bytedance/gopkg/cloud/circuitbreaker	(cached)
=== RUN   TestWithBackwardValues
--- PASS: TestWithBackwardValues (0.00s)
=== RUN   TestWithBackwardValues2
--- PASS: TestWithBackwardValues2 (0.00s)
=== RUN   TestWithBackwardValues3
--- PASS: TestWithBackwardValues3 (0.00s)
=== RUN   TestWithBackwardValues4
--- PASS: TestWithBackwardValues4 (0.00s)
=== RUN   TestWithBackwardValues5
--- PASS: TestWithBackwardValues5 (0.00s)
=== RUN   TestHTTPHeaderToCGIVariable
--- PASS: TestHTTPHeaderToCGIVariable (0.00s)
=== RUN   TestCGIVariableToHTTPHeader
--- PASS: TestCGIVariableToHTTPHeader (0.00s)
=== RUN   TestFromHTTPHeader
--- PASS: TestFromHTTPHeader (0.00s)
=== RUN   TestFromHTTPHeaderKeepPreviousData
--- PASS: TestFromHTTPHeaderKeepPreviousData (0.00s)
=== RUN   TestToHTTPHeader
--- PASS: TestToHTTPHeader (0.00s)
=== RUN   TestHTTPHeader
--- PASS: TestHTTPHeader (0.00s)
=== RUN   TestWithValue
--- PASS: TestWithValue (0.00s)
=== RUN   TestWithEmpty
--- PASS: TestWithEmpty (0.00s)
=== RUN   TestDelValue
--- PASS: TestDelValue (0.00s)
=== RUN   TestGetAll
--- PASS: TestGetAll (0.00s)
=== RUN   TestRangeValues
--- PASS: TestRangeValues (0.00s)
=== RUN   TestGetAll2
--- PASS: TestGetAll2 (0.00s)
=== RUN   TestWithPersistentValue
--- PASS: TestWithPersistentValue (0.00s)
=== RUN   TestWithPersistentEmpty
--- PASS: TestWithPersistentEmpty (0.00s)
=== RUN   TestDelPersistentValue
--- PASS: TestDelPersistentValue (0.00s)
=== RUN   TestGetAllPersistent
--- PASS: TestGetAllPersistent (0.00s)
=== RUN   TestRangePersistent
--- PASS: TestRangePersistent (0.00s)
=== RUN   TestGetAllPersistent2
--- PASS: TestGetAllPersistent2 (0.00s)
=== RUN   TestNilSafty
--- PASS: TestNilSafty (0.00s)
=== RUN   TestTransitAndPersistent
--- PASS: TestTransitAndPersistent (0.00s)
=== RUN   TestTransferForward
--- PASS: TestTransferForward (0.00s)
=== RUN   TestOverride
--- PASS: TestOverride (0.00s)
=== RUN   TestHasMetaInfo
--- PASS: TestHasMetaInfo (0.00s)
=== RUN   TestSetMetaInfoFromMap
--- PASS: TestSetMetaInfoFromMap (0.00s)
=== RUN   TestSetMetaInfoFromMapKeepPreviousData
--- PASS: TestSetMetaInfoFromMapKeepPreviousData (0.00s)
=== RUN   TestSaveMetaInfoToMap
--- PASS: TestSaveMetaInfoToMap (0.00s)
PASS
ok  	github.com/bytedance/gopkg/cloud/metainfo	(cached)
=== RUN   TestIntSet
--- PASS: TestIntSet (0.00s)
PASS
ok  	github.com/bytedance/gopkg/collection/hashset	(cached)
=== RUN   TestBoundedQueue
--- PASS: TestBoundedQueue (1.70s)
=== RUN   TestUnboundedQueue
--- PASS: TestUnboundedQueue (0.31s)
=== RUN   TestPointerQueue
--- PASS: TestPointerQueue (0.00s)
PASS
ok  	github.com/bytedance/gopkg/collection/lscq	(cached)
=== RUN   TestOpArray
--- PASS: TestOpArray (0.00s)
=== RUN   TestStringMap
--- PASS: TestStringMap (0.00s)
=== RUN   TestSkipMap
--- PASS: TestSkipMap (0.20s)
=== RUN   TestSkipMapDesc
--- PASS: TestSkipMapDesc (0.00s)
=== RUN   TestConcurrentRange
--- PASS: TestConcurrentRange (0.38s)
PASS
ok  	github.com/bytedance/gopkg/collection/skipmap	(cached)
=== RUN   TestFlag
--- PASS: TestFlag (0.00s)
=== RUN   TestOpArray
--- PASS: TestOpArray (0.00s)
=== RUN   TestIntSet
--- PASS: TestIntSet (1.17s)
=== RUN   TestIntSetDesc
--- PASS: TestIntSetDesc (0.00s)
=== RUN   TestStringSet
--- PASS: TestStringSet (0.00s)
PASS
ok  	github.com/bytedance/gopkg/collection/skipset	(cached)
=== RUN   TestFloat64Set
--- PASS: TestFloat64Set (0.00s)
=== RUN   TestFloat64SetAdd
--- PASS: TestFloat64SetAdd (0.00s)
=== RUN   TestFloat64SetContains
--- PASS: TestFloat64SetContains (0.00s)
=== RUN   TestFloat64SetScore
--- PASS: TestFloat64SetScore (0.00s)
=== RUN   TestFloat64SetIncr
--- PASS: TestFloat64SetIncr (0.00s)
=== RUN   TestFloat64SetRemove
--- PASS: TestFloat64SetRemove (0.00s)
=== RUN   TestFloat64SetRank
--- PASS: TestFloat64SetRank (0.00s)
=== RUN   TestFloat64SetRank_Many
--- PASS: TestFloat64SetRank_Many (0.02s)
=== RUN   TestFloat64SetRank_UpdateScore
--- PASS: TestFloat64SetRank_UpdateScore (0.00s)
=== RUN   TestFloat64SetIsSorted
--- PASS: TestFloat64SetIsSorted (0.06s)
=== RUN   TestFloat64SetRange
--- PASS: TestFloat64SetRange (0.00s)
=== RUN   TestFloat64SetRevRange
--- PASS: TestFloat64SetRevRange (0.00s)
=== RUN   TestFloat64SetRange_Negative
--- PASS: TestFloat64SetRange_Negative (0.00s)
=== RUN   TestFloat64SetRevRange_Negative
--- PASS: TestFloat64SetRevRange_Negative (0.00s)
=== RUN   TestFloat64SetRangeByScore
--- PASS: TestFloat64SetRangeByScore (0.00s)
=== RUN   TestFloat64SetRangeByScoreWithOpt
--- PASS: TestFloat64SetRangeByScoreWithOpt (0.00s)
=== RUN   TestFloat64SetRevRangeByScoreWithOpt
--- PASS: TestFloat64SetRevRangeByScoreWithOpt (0.00s)
=== RUN   TestFloat64SetRevRangeByScore
--- PASS: TestFloat64SetRevRangeByScore (0.00s)
=== RUN   TestFloat64SetCountWithOpt
--- PASS: TestFloat64SetCountWithOpt (0.02s)
=== RUN   TestFloat64SetRemoveRangeByRank
--- PASS: TestFloat64SetRemoveRangeByRank (0.00s)
=== RUN   TestFloat64SetRemoveRangeByScoreWithOpt
--- PASS: TestFloat64SetRemoveRangeByScoreWithOpt (0.01s)
=== RUN   TestUnionFloat64
--- PASS: TestUnionFloat64 (0.00s)
=== RUN   TestUnionFloat64_Empty
--- PASS: TestUnionFloat64_Empty (0.00s)
=== RUN   TestInterFloat64
--- PASS: TestInterFloat64 (0.00s)
=== RUN   TestInterFloat64_Empty
--- PASS: TestInterFloat64_Empty (0.00s)
=== RUN   TestInterFloat64_Simple
--- PASS: TestInterFloat64_Simple (0.00s)
PASS
ok  	github.com/bytedance/gopkg/collection/zset	(cached)
?   	github.com/bytedance/gopkg/internal/benchmark/linkedq	[no test files]
?   	github.com/bytedance/gopkg/internal/benchmark/msq	[no test files]
?   	github.com/bytedance/gopkg/internal/hack	[no test files]
=== RUN   TestPin
    ppin_test.go:26: 0
    ppin_test.go:33: 0
    ppin_test.go:33: 0
    ppin_test.go:33: 0
    ppin_test.go:33: 0
--- PASS: TestPin (0.00s)
PASS
ok  	github.com/bytedance/gopkg/internal/runtimex	(cached)
=== RUN   TestDigest
--- PASS: TestDigest (1.72s)
PASS
ok  	github.com/bytedance/gopkg/internal/wyhash	(cached)
=== RUN   TestAll
--- PASS: TestAll (0.00s)
PASS
ok  	github.com/bytedance/gopkg/lang/fastrand	(cached)
=== RUN   TestMalloc
    mcache_test.go:21: 4096
--- PASS: TestMalloc (0.00s)
=== RUN   TestBsr
--- PASS: TestBsr (0.00s)
PASS
ok  	github.com/bytedance/gopkg/lang/mcache	(cached)
=== RUN   TestIs
--- PASS: TestIs (0.00s)
=== RUN   TestPad
--- PASS: TestPad (0.00s)
=== RUN   TestRemove
--- PASS: TestRemove (0.00s)
=== RUN   TestRepeat
--- PASS: TestRepeat (0.00s)
=== RUN   TestRotate
--- PASS: TestRotate (0.00s)
=== RUN   TestReverse
--- PASS: TestReverse (0.00s)
=== RUN   TestSub
--- PASS: TestSub (0.00s)
=== RUN   TestContainsAnySubstrings
--- PASS: TestContainsAnySubstrings (0.00s)
=== RUN   TestShuffle
--- PASS: TestShuffle (0.00s)
=== RUN   Example_sub
--- PASS: Example_sub (0.00s)
=== RUN   Example_substart
--- PASS: Example_substart (0.00s)
=== RUN   Example_pad
--- PASS: Example_pad (0.00s)
PASS
ok  	github.com/bytedance/gopkg/lang/stringx	(cached)
=== RUN   TestSyncXPool
--- PASS: TestSyncXPool (0.37s)
=== RUN   TestRaceSyncXPool
--- PASS: TestRaceSyncXPool (0.02s)
PASS
ok  	github.com/bytedance/gopkg/lang/syncx	(cached)
=== RUN   TestFinalizer
--- PASS: TestFinalizer (0.01s)
=== RUN   TestMem
    mem_test.go:29: mem inuse: 100 MB
--- PASS: TestMem (0.00s)
=== RUN   TestTuner
--- PASS: TestTuner (0.23s)
=== RUN   TestCalcGCPercent
--- PASS: TestCalcGCPercent (0.00s)
=== RUN   TestChangeGCPercent
--- PASS: TestChangeGCPercent (0.00s)
PASS
ok  	github.com/bytedance/gopkg/util/gctuner	0.245s
=== RUN   TestPool
--- PASS: TestPool (0.00s)
=== RUN   TestPoolPanic
--- PASS: TestPoolPanic (0.00s)
PASS
ok  	github.com/bytedance/gopkg/util/gopool	(cached)
?   	github.com/bytedance/gopkg/util/logger	[no test files]
=== RUN   TestLen0_16
--- PASS: TestLen0_16 (0.00s)
=== RUN   TestLen17_128
--- PASS: TestLen17_128 (0.00s)
=== RUN   TestLen129_240
--- PASS: TestLen129_240 (0.00s)
=== RUN   TestLen240_1024
--- PASS: TestLen240_1024 (0.00s)
=== RUN   TestLen1025_1048576_scalar
--- PASS: TestLen1025_1048576_scalar (0.00s)
=== RUN   TestLen1024_1048576_AVX2
--- PASS: TestLen1024_1048576_AVX2 (0.00s)
=== RUN   TestLen1024_1048576_SSE2
--- PASS: TestLen1024_1048576_SSE2 (0.00s)
=== RUN   TestLen128_0_16
--- PASS: TestLen128_0_16 (0.00s)
=== RUN   TestLen128_17_128
--- PASS: TestLen128_17_128 (0.00s)
=== RUN   TestLen128_129_240
--- PASS: TestLen128_129_240 (0.00s)
=== RUN   TestLen128_240_1024
--- PASS: TestLen128_240_1024 (0.00s)
=== RUN   TestLen128_1025_1048576_scalar
--- PASS: TestLen128_1025_1048576_scalar (0.00s)
=== RUN   TestLen128_1024_1048576_AVX2
--- PASS: TestLen128_1024_1048576_AVX2 (0.00s)
=== RUN   TestLen128_1024_1048576_SSE2
--- PASS: TestLen128_1024_1048576_SSE2 (0.00s)
PASS
ok  	github.com/bytedance/gopkg/util/xxhash3	(cached)
?   	github.com/bytedance/gopkg/util/xxhash3/internal/xxh3_raw	[no test files]

Copy link
Collaborator

@PureWhiteWu PureWhiteWu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

非常感谢你的贡献!
总体来看没有大问题,不过我们没有龙芯的环境因此无法进行测试。
还有两个小问题需要确认一下。

@@ -0,0 +1,90 @@
// Copyright 2022 Loongson Inc.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

要不改成这样"Copyright 2022 Loongson Inc. and ByteDance Inc."避免一下后续的法务风险?

@@ -0,0 +1,88 @@
// Copyright 2022 Loongson Inc.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里也是

@@ -131,6 +131,8 @@ type pointerSCQ struct {
type scqNodePointer struct {
flags uint64 // isSafe 1-bit + isEmpty 1-bit + cycle 62-bit
data unsafe.Pointer
_ sync.Mutex // Only for architectures that do not support 128bit atomic operations
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里增加两个字段,把 scqNodePointer 的长度从 128 增加到了 256,会不会影响 cacheline 的利用进而影响性能? @zhangyunhao116

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, added a comment below :)

@@ -131,6 +131,8 @@ type uint64SCQ struct {
type scqNodeUint64 struct {
flags uint64 // isSafe 1-bit + isEmpty 1-bit + cycle 62-bit
data uint64
_ sync.Mutex // Only for architectures that do not support 128bit atomic operations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need to support architectures that don't support 128-bit CAS. Adding a sync.Mutex usually comes with performance losses. It would be nice if you could run the benchmark to see the diff :)

Copy link
Member

@zhangyunhao116 zhangyunhao116 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this work!
The main concern I have is that loong64 doesn't support 128-bit CAS. I'm not familiar with loong64. Is there any way to support this instruction?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants