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

about fasthttp.appendArg #1913

Open
lxj15398019970 opened this issue Dec 9, 2024 · 5 comments
Open

about fasthttp.appendArg #1913

lxj15398019970 opened this issue Dec 9, 2024 · 5 comments

Comments

@lxj15398019970
Copy link

WechatIMG767

why has so much fasthttp.appendArg obj

@erikdubbelboer
Copy link
Collaborator

Is this a problem? Can you show your code and examples that cause this?

@lxj15398019970
Copy link
Author

Is this a problem? Can you show your code and examples that cause this?

server := &fasthttp.Server{
	Handler: requestHandler,
	ErrorHandler: func(ctx *fasthttp.RequestCtx, err error) {
		logging.Println("http>error:" + err.Error() + ";path:" + string(ctx.Path()) + ";" + string(ctx.RequestURI()) + ";" + string(ctx.UserAgent()))
		logging.Println("http>error:" + string(ctx.Request.Body()))
		ctx.Response.Header.Set(common.HTTP_Head_Err_Key, err.Error())
		ctx.Response.Header.Set(common.HTTP_Content_Type, "text/plain")
		ctx.Response.SetStatusCode(413)
		ctx.Request.Reset()
	},
	IdleTimeout:        time.Second * 5,
	ReadTimeout:        2 * time.Second,
	WriteTimeout:       2 * time.Second,
	MaxRequestBodySize: 25 * 1024,
	ReadBufferSize:     10 * 1024,
	WriteBufferSize:    10 * 1024,
	Logger:             fhlogger,
	TCPKeepalive:       true,
	TCPKeepalivePeriod: 15 * time.Second,
	DisableKeepalive:   false,
}
fmt.Println(server.ListenAndServe(":8080"))

for this,when concurrency is high, a large number of objects are generated,so gc cost much time。How can i reduce these objects fasthttp.appendArg

@erikdubbelboer
Copy link
Collaborator

Need to see your handler, it's probably something you call in there.

@lxj15398019970
Copy link
Author

Need to see your handler, it's probably something you call in there.

image
from this chain,seems there is no call by business code

@erikdubbelboer
Copy link
Collaborator

Seems that everything that isn't allocating is missing in that trace. serveConn never calls appendArgBytes directly.

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

No branches or pull requests

2 participants