Skip to content

codec support#42

Open
Carbrex wants to merge 4 commits intojoncrlsn:v2from
Carbrex:feature/codec-support-2
Open

codec support#42
Carbrex wants to merge 4 commits intojoncrlsn:v2from
Carbrex:feature/codec-support-2

Conversation

@Carbrex
Copy link

@Carbrex Carbrex commented Feb 26, 2026

No description provided.

@Carbrex Carbrex marked this pull request as draft February 26, 2026 21:35
@Carbrex
Copy link
Author

Carbrex commented Mar 4, 2026

@joncrlsn

@Carbrex Carbrex marked this pull request as ready for review March 4, 2026 22:23
@Carbrex
Copy link
Author

Carbrex commented Mar 4, 2026

@joncrlsn We have found heavy impact of dque on our systems cpu, because of expensive gob encoding. This pr is to add support for a user provided codec like msgPack or protobuf for cheaper encoding to bytes.

@Carbrex
Copy link
Author

Carbrex commented Mar 4, 2026

I can add an example to show how to use the codec, if needed.

@Carbrex
Copy link
Author

Carbrex commented Mar 4, 2026

 go test -bench=. -benchtime=4s
goos: linux
goarch: amd64
pkg: carbrex.dev/dque-testing/helper
cpu: 11th Gen Intel(R) Core(TM) i5-1155G7 @ 2.50GHz
BenchmarkGobCodec_Complete-8              323029             14146 ns/op
BenchmarkMsgPackCodec_Complete-8          578898              7987 ns/op
BenchmarkProtoCodec_Complete-8            657218              7207 ns/op
PASS
ok      carbrex.dev/dque-testing/helper 16.452s

go bench results for testing done on a simple User struct

type User struct {
	ID   int
	Name string
}

bench snippet

	for n := 0; n < b.N; n++ {
		err := q.Enqueue(&helper.User{n, "UserIHelping"})
		if err != nil {
			b.Fatal("Error enqueuing to dque:", err)
		}
		if decode {
			_, err = q.Dequeue()
			if err != nil {
				b.Fatal(err)
			}
		}

	}

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.

1 participant