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

ctx creation and customition #108

Open
clor09 opened this issue Nov 2, 2021 · 3 comments
Open

ctx creation and customition #108

clor09 opened this issue Nov 2, 2021 · 3 comments

Comments

@clor09
Copy link

clor09 commented Nov 2, 2021

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.15.9 linux/amd64

What operating system and processor architecture are you using (go env)?

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/xx/.cache/go-build"
GOENV="/home/xx/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/xx/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/xx/go"
GOPRIVATE=""
GOPROXY=""
GOROOT="/usr/lib/go-1.15"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.15/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build605241201=/tmp/go-build -gno-record-gcc-switches"

What did you do?

m wondering if we could export the ctx creation to the users so that they can make some customition, i have noticed the very early issue #17 and i did it myself by adding the following code to zstd_streaming.go, but maybe it's really not a good impl.

#cgo CPPFLAGS: -DZSTD_MULTITHREAD
#cgo CFLAGS: -pthread

func (w *Writer) SetNbWorkers(n int) error {
	if w.firstError != nil {
		return w.firstError
	}
	if err := getError(int(C.ZSTD_CCtx_setParameter(w.ctx, C.ZSTD_c_nbWorkers, C.int(n)))); err != nil {
		w.firstError = err
		return err
	}
	return nil
}

What did you expect to see?

compress&decompress ctx creation & customition avaliable

What did you see instead?

ctx created by the lib internally and it's not accessable outside

@Viq111
Copy link
Collaborator

Viq111 commented Nov 24, 2021

Thanks! Yes defitely feel free to create a PR for this.
We could either expose ctx via a method to allow arbitrary customization or do as you showed, create methods for each common customization (and I'm guessing, that's probably what most users will want)

@bsergean
Copy link
Contributor

bsergean commented May 5, 2022

A SetNbWorkers api would be really awesome, we are compressing large (10+Gig) files and it would help a lot to have it.

@bsergean
Copy link
Contributor

bsergean commented May 5, 2022

I see a few NewWriter functions (with a compression level, with a dictionary). There could also be one NewWriter that takes a number of workers as its input.

Viq111 added a commit that referenced this issue Jun 6, 2022
Add SetNbWorkers api to the writer code (see #108)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants