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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 c.JSON() takes much time to serialize data and response. #1708

Closed
shahriar350 opened this issue Jan 11, 2022 · 12 comments 路 Fixed by #1851
Closed

馃悰 c.JSON() takes much time to serialize data and response. #1708

shahriar350 opened this issue Jan 11, 2022 · 12 comments 路 Fixed by #1851

Comments

@shahriar350
Copy link

shahriar350 commented Jan 11, 2022

func GetShopCategory(c *fiber.Ctx) error {
	shopCategories, err := db.Client.ShopCategory.Query().Where(shopcategory.DeletedAtIsNil()).All(context.Background())
	if err != nil {
		return err
	}
	shopTrashCategories, errData := db.Client.ShopCategory.Query().Where(shopcategory.DeletedAtNotNil()).All(context.Background())
	if errData != nil {
		return err
	}
	fmt.Println("data: got in : ",time.Now())

	return c.Status(200).JSON(fiber.Map{
		"shop_categories":       shopCategories,
		"shop_categories_trash": shopTrashCategories,
	})
}

Here the result:

data: got in :  2022-01-11 17:41:04.1690737 +0600 +06 m=+7.977232901
17:41:18 | 200 | 14.175s |       127.0.0.1 | GET     | /api/admin/shop/categories/all

But @ReneWerner87 gives a solution to add this to my code

func main() {
	app := fiber.New(fiber.Config{
		JSONEncoder: json.Marshal,
		JSONDecoder: json.Unmarshal,
	})
}

now It takes:

data: got in :  2022-01-11 17:43:47.9628746 +0600 +06 m=+25.338688701
17:43:47 | 200 |    11ms |       127.0.0.1 | GET     | /api/admin/shop/categories/all

c.JSON() works faster than before.

@welcome
Copy link

welcome bot commented Jan 11, 2022

Thanks for opening your first issue here! 馃帀 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@ReneWerner87
Copy link
Member

initial implementation in #1563
we use https://github.com/goccy/go-json as the default encoder and decode

@hi019
Copy link
Contributor

hi019 commented Jan 12, 2022

What is shopCategories and shopTrashCategories? Can you put together a small reproduction encoding them (just define them in a variable, no need to do any actual data fetching)?

@ReneWerner87
Copy link
Member

he sent me the data, but could not yet prepare and test it
data+structs.zip

they are in the zip

@ReneWerner87
Copy link
Member

@shahriar350 is it still a problem or had you found the cause ?

@shahriar350
Copy link
Author

@shahriar350 is it still a problem or had you found the cause ?

not really. I use ffjson instant of go-json. I check my code manually but always go-json failed to Marshal/Unmarshal my struct. but other package like fastjson/std json/ffjson works fine. As you recommend me to use this

import json "github.com/pquerna/ffjson/ffjson"
app := fiber.New(fiber.Config{
		JSONEncoder: json.Marshal,
		JSONDecoder: json.Unmarshal,
	})

i use this to my code and code works fine. Otherwise it send me some error like this:

fatal error: out of memory allocating heap arena metadata
runtime: VirtualAlloc of 4956160 bytes failed with errno=1455
fatal error: out of memory

runtime stack:
runtime.throw({0x112aaa0, 0x0})
        C:/Program Files/Go/src/runtime/panic.go:1198 +0x76
runtime.(*mheap).sysAlloc(0x192c2a0, 0x629fa0)
        C:/Program Files/Go/src/runtime/malloc.go:750 +0x2f8
runtime.(*mheap).grow(0x192c2a0, 0x25d)
        C:/Program Files/Go/src/runtime/mheap.go:1347 +0x73
runtime.(*mheap).allocSpan(0x192c2a0, 0x25d, 0x0, 0x0)
        C:/Program Files/Go/src/runtime/mheap.go:1179 +0x165
runtime.(*mheap).alloc.func1()
        C:/Program Files/Go/src/runtime/mheap.go:913 +0x69
runtime.systemstack()
        C:/Program Files/Go/src/runtime/asm_amd64.s:383 +0x4e

goroutine 103 [running]:
runtime.systemstack_switch()
        C:/Program Files/Go/src/runtime/asm_amd64.s:350 fp=0xc01c2f6fc8 sp=0xc01c2f6fc0 pc=0x6617a0
runtime.(*mheap).alloc(0xc65abc2000, 0xc65abe7d00, 0xf0, 0x1)
        C:/Program Files/Go/src/runtime/mheap.go:907 +0x73 fp=0xc01c2f7018 sp=0xc01c2f6fc8 pc=0x6261d3
runtime.(*mcache).allocLarge(0x8, 0x4b86e0, 0x0, 0x0)
        C:/Program Files/Go/src/runtime/mcache.go:227 +0x89 fp=0xc01c2f7078 sp=0xc01c2f7018 pc=0x616a49
runtime.mallocgc(0x4b86e0, 0x10d3440, 0x1)
        C:/Program Files/Go/src/runtime/malloc.go:1082 +0x5c5 fp=0xc01c2f70f8 sp=0xc01c2f7078 pc=0x60d145
runtime.makeslice(0xffffffffffffffff, 0x70794f, 0x111336e)
        C:/Program Files/Go/src/runtime/slice.go:98 +0x52 fp=0xc01c2f7120 sp=0xc01c2f70f8 pc=0x6499d2
github.com/gofiber/fiber/v2/internal/go-json/encoder.copyOpcode(0xc34a6d5f80)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encoder/opcode.go:322 +0x4a fp=0xc01c2f71f8 sp=0xc01c2f7120
pc=0xd2ed6a
github.com/gofiber/fiber/v2/internal/go-json/encoder.(*Compiler).linkRecursiveCode(0xc321587fc8, 0xc3216fe270)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encoder/compiler.go:865 +0x13c fp=0xc01c2f7290 sp=0xc01c2f71
f8 pc=0xd2ba1c
github.com/gofiber/fiber/v2/internal/go-json/encoder.(*Compiler).codeToOpcode(0xc01dbdb260, 0xc3216fe270, 0xfc9320, {0x1270ea8, 0xc321587fc8})
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encoder/compiler.go:856 +0xe5 fp=0xc01c2f72d8 sp=0xc01c2f729
0 pc=0xd2b865
github.com/gofiber/fiber/v2/internal/go-json/encoder.(*Compiler).compile(0xc01dbdc3f0, 0xfc9320)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encoder/compiler.go:83 +0xde fp=0xc01c2f7368 sp=0xc01c2f72d8
 pc=0xd2757e
github.com/gofiber/fiber/v2/internal/go-json/encoder.CompileToGetCodeSet(0x0)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encoder/compiler_norace.go:14 +0x105 fp=0xc01c2f7460 sp=0xc0
1c2f7368 pc=0xd2bc05
github.com/gofiber/fiber/v2/internal/go-json.encode(0xc000798410, {0xfc9320, 0xc01dbf2018})
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encode.go:223 +0xd0 fp=0xc01c2f74e0 sp=0xc01c2f7460 pc=0xda0
470
github.com/gofiber/fiber/v2/internal/go-json.marshal({0xfc9320, 0xc01dbf2018}, {0x0, 0x0, 0x18})
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encode.go:147 +0xba fp=0xc01c2f7540 sp=0xc01c2f74e0 pc=0xda0
27a
github.com/gofiber/fiber/v2/internal/go-json.MarshalWithOption(...)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/json.go:186
github.com/gofiber/fiber/v2/internal/go-json.Marshal({0xfc9320, 0xc01dbf2018})
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/json.go:171 +0x2a fp=0xc01c2f7578 sp=0xc01c2f7540 pc=0xda074
a
github.com/gofiber/fiber/v2.(*Ctx).JSON(0xc01dba6000, {0xfc9320, 0xc01dbf2018})
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/ctx.go:674 +0x3c fp=0xc01c2f75d0 sp=0xc01c2f7578 pc=0xeb401c
bongo/mynonuser.AllProductCategories(0xc00082c9c0)
        E:/bongoBitan/bongoGO/mynonuser/mynonuser.go:61 +0x2e7 fp=0xc01c2f7678 sp=0xc01c2f75d0 pc=0xf51d27
github.com/gofiber/fiber/v2.(*App).next(0xc000438380, 0xc01dba6000)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/router.go:130 +0x1d8 fp=0xc01c2f7718 sp=0xc01c2f7678 pc=0xebe858
github.com/gofiber/fiber/v2.(*Ctx).Next(0x200000003)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/ctx.go:771 +0x53 fp=0xc01c2f7738 sp=0xc01c2f7718 pc=0xeb4cb3
github.com/gofiber/fiber/v2/middleware/logger.New.func2(0xc01dba6000)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/middleware/logger/logger.go:160 +0x1f7 fp=0xc01c2f7a28 sp=0xc01c2f7738 pc=0xf
75257
github.com/gofiber/fiber/v2.(*Ctx).Next(0xc000c0c898)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/ctx.go:768 +0x43 fp=0xc01c2f7a48 sp=0xc01c2f7a28 pc=0xeb4ca3
github.com/gofiber/fiber/v2/middleware/cors.New.func1(0xc01dba6000)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/middleware/cors/cors.go:141 +0x292 fp=0xc01c2f7b50 sp=0xc01c2f7a48 pc=0xf7303
2
github.com/gofiber/fiber/v2.(*App).next(0xc000438380, 0xc01dba6000)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/router.go:130 +0x1d8 fp=0xc01c2f7bf0 sp=0xc01c2f7b50 pc=0xebe858
github.com/gofiber/fiber/v2.(*App).handler(0xc000438380, 0xc00073deb8)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/router.go:158 +0xe5 fp=0xc01c2f7c30 sp=0xc01c2f7bf0 pc=0xebea65
github.com/gofiber/fiber/v2.(*App).handler-fm(0xc00042dd40)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/router.go:146 +0x2c fp=0xc01c2f7c50 sp=0xc01c2f7c30 pc=0xec32cc
github.com/valyala/fasthttp.(*Server).serveConn(0xc00042dd40, {0x12864e0, 0xc00050c008})
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/server.go:2298 +0x11ae fp=0xc01c2f7ec8 sp=0xc01c2f7c50 pc=0xe475ce
github.com/valyala/fasthttp.(*Server).serveConn-fm({0x12864e0, 0xc00050c008})
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/server.go:2039 +0x39 fp=0xc01c2f7ef0 sp=0xc01c2f7ec8 pc=0xe549b9
github.com/valyala/fasthttp.(*workerPool).workerFunc(0xc0004f4000, 0xc01c3041a0)
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/workerpool.go:223 +0xa9 fp=0xc01c2f7fa0 sp=0xc01c2f7ef0 pc=0xe52a69
github.com/valyala/fasthttp.(*workerPool).getCh.func1()
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/workerpool.go:195 +0x38 fp=0xc01c2f7fe0 sp=0xc01c2f7fa0 pc=0xe527f8
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc01c2f7fe8 sp=0xc01c2f7fe0 pc=0x663b21
created by github.com/valyala/fasthttp.(*workerPool).getCh
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/workerpool.go:194 +0x1b5

goroutine 1 [IO wait]:
internal/poll.runtime_pollWait(0x117e43b0cb8, 0x72)
        C:/Program Files/Go/src/runtime/netpoll.go:234 +0x89
internal/poll.(*pollDesc).wait(0xc0007379a0, 0x60d26a, 0x0)
        C:/Program Files/Go/src/internal/poll/fd_poll_runtime.go:84 +0x32
internal/poll.execIO(0xc000128a18, 0xc0007379a8)
        C:/Program Files/Go/src/internal/poll/fd_windows.go:175 +0xe5
internal/poll.(*FD).acceptOne(0xc000128a00, 0x350, {0xc01db781e0, 0x67fc9f, 0x0}, 0x0)
        C:/Program Files/Go/src/internal/poll/fd_windows.go:810 +0x6d
internal/poll.(*FD).Accept(0xc000128a00, 0xc000737b80)
        C:/Program Files/Go/src/internal/poll/fd_windows.go:844 +0x1d6
net.(*netFD).accept(0xc000128a00)
        C:/Program Files/Go/src/net/fd_windows.go:139 +0x65
net.(*TCPListener).accept(0xc00047d818)
        C:/Program Files/Go/src/net/tcpsock_posix.go:140 +0x28
net.(*TCPListener).Accept(0xc00047d818)
        C:/Program Files/Go/src/net/tcpsock.go:262 +0x3d
github.com/valyala/fasthttp.acceptConn(0xc00042dd40, {0x12731d8, 0xc00047d818}, 0xc000737dc8)
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/server.go:1868 +0x62
github.com/valyala/fasthttp.(*Server).Serve(0xc00042dd40, {0x12731d8, 0xc00047d818})
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/server.go:1781 +0x4ea
github.com/gofiber/fiber/v2.(*App).Listen(0xc000438380, {0x11065d2, 0x1110e50})
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/app.go:760 +0xd1
main.main()
        E:/bongoBitan/bongoGO/main.go:86 +0x1eb

goroutine 6 [select]:
database/sql.(*DB).connectionOpener(0xc0003f6750, {0x127b250, 0xc00027f200})
        C:/Program Files/Go/src/database/sql/sql.go:1196 +0x93
created by database/sql.OpenDB
        C:/Program Files/Go/src/database/sql/sql.go:794 +0x188

goroutine 34 [select]:
database/sql.(*DB).connectionOpener(0xc000041e10, {0x127b250, 0xc0000ae8c0})
        C:/Program Files/Go/src/database/sql/sql.go:1196 +0x93
created by database/sql.OpenDB
        C:/Program Files/Go/src/database/sql/sql.go:794 +0x188

goroutine 60 [sleep]:
time.Sleep(0x3b9aca00)
        C:/Program Files/Go/src/runtime/time.go:193 +0x133
github.com/valyala/fasthttp.updateServerDate.func1()
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/header.go:2043 +0x1e
created by github.com/valyala/fasthttp.updateServerDate
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/header.go:2041 +0x27

goroutine 61 [running]:
        goroutine running on other thread; stack unavailable
created by github.com/valyala/fasthttp.(*workerPool).getCh
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/workerpool.go:194 +0x1b5

goroutine 148 [runnable]:
github.com/gofiber/fiber/v2/internal/go-json/encoder.OpType.CodeType(0xb)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encoder/optype.go:840 +0x1cb
github.com/gofiber/fiber/v2/internal/go-json/encoder.(*Opcode).IterNext(...)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encoder/opcode.go:71
github.com/gofiber/fiber/v2/internal/go-json/encoder.(*Opcode).TotalLength(0xc01c3f003b)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encoder/opcode.go:416 +0x7e
github.com/gofiber/fiber/v2/internal/go-json/encoder.(*Compiler).linkRecursiveCode(0xc01407e3d8, 0xc01408bb30)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encoder/compiler.go:880 +0xae
github.com/gofiber/fiber/v2/internal/go-json/encoder.(*Compiler).codeToOpcode(0x0, 0xc01408bb30, 0xfc9320, {0x1270ea8, 0xc01407e3d8})
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encoder/compiler.go:856 +0xe5
github.com/gofiber/fiber/v2/internal/go-json/encoder.(*Compiler).compile(0x1148f40, 0xfc9320)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encoder/compiler.go:83 +0xde
github.com/gofiber/fiber/v2/internal/go-json/encoder.CompileToGetCodeSet(0xc0007c3498)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encoder/compiler_norace.go:14 +0x105
github.com/gofiber/fiber/v2/internal/go-json.encode(0xc01cb881a0, {0xfc9320, 0xc0152be498})
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encode.go:223 +0xd0
github.com/gofiber/fiber/v2/internal/go-json.marshal({0xfc9320, 0xc0152be498}, {0x0, 0x0, 0x18})
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encode.go:147 +0xba
github.com/gofiber/fiber/v2/internal/go-json.MarshalWithOption(...)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/json.go:186
github.com/gofiber/fiber/v2/internal/go-json.Marshal({0xfc9320, 0xc0152be498})
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/json.go:171 +0x2a
github.com/gofiber/fiber/v2.(*Ctx).JSON(0xc000c1c580, {0xfc9320, 0xc0152be498})
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/ctx.go:674 +0x3c
bongo/mynonuser.AllProductCategories(0xc00082c9c0)
        E:/bongoBitan/bongoGO/mynonuser/mynonuser.go:61 +0x2e7
github.com/gofiber/fiber/v2.(*App).next(0xc000438380, 0xc000c1c580)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/router.go:130 +0x1d8
github.com/gofiber/fiber/v2.(*Ctx).Next(0x20)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/ctx.go:771 +0x53
github.com/gofiber/fiber/v2/middleware/logger.New.func2(0xc000c1c580)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/middleware/logger/logger.go:160 +0x1f7
github.com/gofiber/fiber/v2.(*Ctx).Next(0xc000c0ce18)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/ctx.go:768 +0x43
github.com/gofiber/fiber/v2/middleware/cors.New.func1(0xc000c1c580)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/middleware/cors/cors.go:141 +0x292
github.com/gofiber/fiber/v2.(*App).next(0xc000438380, 0xc000c1c580)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/router.go:130 +0x1d8
github.com/gofiber/fiber/v2.(*App).handler(0xc000438380, 0xc0007c3eb8)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/router.go:158 +0xe5
github.com/valyala/fasthttp.(*Server).serveConn(0xc00042dd40, {0x12864e0, 0xc000440030})
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/server.go:2298 +0x11ae
github.com/valyala/fasthttp.(*workerPool).workerFunc(0xc0004f4000, 0xc0000b2140)
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/workerpool.go:223 +0xa9
github.com/valyala/fasthttp.(*workerPool).getCh.func1()
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/workerpool.go:195 +0x38
created by github.com/valyala/fasthttp.(*workerPool).getCh
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/workerpool.go:194 +0x1b5

goroutine 147 [running]:
        goroutine running on other thread; stack unavailable
created by github.com/valyala/fasthttp.(*workerPool).getCh
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/workerpool.go:194 +0x1b5

goroutine 104 [runnable]:
runtime.Gosched(...)
        C:/Program Files/Go/src/runtime/proc.go:322
github.com/gofiber/fiber/v2/internal/go-json/encoder.copyOpcode(0xc3255bb880)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encoder/opcode.go:322 +0x4a
github.com/gofiber/fiber/v2/internal/go-json/encoder.(*Compiler).linkRecursiveCode(0xc32011f3b0, 0xc320964060)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encoder/compiler.go:865 +0x13c
github.com/gofiber/fiber/v2/internal/go-json/encoder.(*Compiler).codeToOpcode(0x0, 0xc320964060, 0xfc94a0, {0x1270ea8, 0xc32011f3b0})
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encoder/compiler.go:856 +0xe5
github.com/gofiber/fiber/v2/internal/go-json/encoder.(*Compiler).compile(0x1148f40, 0xfc94a0)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encoder/compiler.go:83 +0xde
github.com/gofiber/fiber/v2/internal/go-json/encoder.CompileToGetCodeSet(0xc01c2f7420)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encoder/compiler_norace.go:14 +0x105
github.com/gofiber/fiber/v2/internal/go-json.encode(0xc00fbd60d0, {0xfc94a0, 0xc00fbc02e8})
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encode.go:223 +0xd0
github.com/gofiber/fiber/v2/internal/go-json.marshal({0xfc94a0, 0xc00fbc02e8}, {0x0, 0x0, 0x18})
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/encode.go:147 +0xba
github.com/gofiber/fiber/v2/internal/go-json.MarshalWithOption(...)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/json.go:186
github.com/gofiber/fiber/v2/internal/go-json.Marshal({0xfc94a0, 0xc00fbc02e8})
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/internal/go-json/json.go:171 +0x2a
github.com/gofiber/fiber/v2.(*Ctx).JSON(0xc000c1c2c0, {0xfc94a0, 0xc00fbc02e8})
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/ctx.go:674 +0x3c
bongo/mynonuser.AllProducts(0xc00082d740)
        E:/bongoBitan/bongoGO/mynonuser/mynonuser.go:92 +0x499
github.com/gofiber/fiber/v2.(*App).next(0xc000438380, 0xc000c1c2c0)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/router.go:130 +0x1d8
github.com/gofiber/fiber/v2.(*Ctx).Next(0x20)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/ctx.go:771 +0x53
github.com/gofiber/fiber/v2/middleware/logger.New.func2(0xc000c1c2c0)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/middleware/logger/logger.go:160 +0x1f7
github.com/gofiber/fiber/v2.(*Ctx).Next(0xc01db80318)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/ctx.go:768 +0x43
github.com/gofiber/fiber/v2/middleware/cors.New.func1(0xc000c1c2c0)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/middleware/cors/cors.go:141 +0x292
github.com/gofiber/fiber/v2.(*App).next(0xc000438380, 0xc000c1c2c0)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/router.go:130 +0x1d8
github.com/gofiber/fiber/v2.(*App).handler(0xc000438380, 0xc000729eb8)
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/router.go:158 +0xe5
github.com/valyala/fasthttp.(*Server).serveConn(0xc00042dd40, {0x12864e0, 0xc00050c018})
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/server.go:2298 +0x11ae
github.com/valyala/fasthttp.(*workerPool).workerFunc(0xc0004f4000, 0xc01c3041c0)
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/workerpool.go:223 +0xa9
github.com/valyala/fasthttp.(*workerPool).getCh.func1()
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/workerpool.go:195 +0x38
created by github.com/valyala/fasthttp.(*workerPool).getCh
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/workerpool.go:194 +0x1b5

goroutine 146 [sleep]:
time.Sleep(0x12a05f200)
        C:/Program Files/Go/src/runtime/time.go:193 +0x133
github.com/valyala/fasthttp.(*FS).initRequestHandler.func1()
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/fs.go:428 +0x138
created by github.com/valyala/fasthttp.(*FS).initRequestHandler
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/fs.go:405 +0x405

goroutine 81 [select]:
bongo/myadmin.runHub()
        E:/bongoBitan/bongoGO/myadmin/adminsocket.go:18 +0xe5
created by bongo/myadmin.AdminSocketRoutes
        E:/bongoBitan/bongoGO/myadmin/adminsocket.go:48 +0x2b

goroutine 102 [running]:
        goroutine running on other thread; stack unavailable
created by github.com/valyala/fasthttp.(*workerPool).getCh
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/workerpool.go:194 +0x1b5

goroutine 80 [sleep]:
time.Sleep(0x1dcd6500)
        C:/Program Files/Go/src/runtime/time.go:193 +0x133
github.com/gofiber/fiber/v2/middleware/logger.New.func1()
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/middleware/logger/logger.go:104 +0x75
created by github.com/gofiber/fiber/v2/middleware/logger.New
        C:/Users/shahr/go/pkg/mod/github.com/gofiber/fiber/v2@v2.24.0/middleware/logger/logger.go:102 +0x325

goroutine 101 [sleep]:
time.Sleep(0x2540be400)
        C:/Program Files/Go/src/runtime/time.go:193 +0x133
github.com/valyala/fasthttp.(*workerPool).Start.func2()
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/workerpool.go:66 +0x56
created by github.com/valyala/fasthttp.(*workerPool).Start
        C:/Users/shahr/go/pkg/mod/github.com/valyala/fasthttp@v1.32.0/workerpool.go:58 +0xde

runtime stack:
runtime.throw({0x110bef5, 0xc65b8ec000})
        C:/Program Files/Go/src/runtime/panic.go:1198 +0x76
runtime.sysUsed(0xc65b536000, 0x4ba000)
        C:/Program Files/Go/src/runtime/mem_windows.go:83 +0x1c9
runtime.(*mheap).allocSpan(0x192c2a0, 0x25d, 0x0, 0x0)
        C:/Program Files/Go/src/runtime/mheap.go:1268 +0x3a5
runtime.(*mheap).alloc.func1()
        C:/Program Files/Go/src/runtime/mheap.go:913 +0x69
runtime.systemstack()
        C:/Program Files/Go/src/runtime/asm_amd64.s:383 +0x4e

@efectn
Copy link
Member

efectn commented Feb 7, 2022

@shahriar350
Can you send this to goccy/go-json as an issue?

@shahriar350
Copy link
Author

@shahriar350 Can you send this to goccy/go-json as an issue?

I've already send them as a issue but they tell me to make a pprof measurement. They tell me that might be a environment issues. Because i dont know about pprof, that's why i cannot measure that. Here is my code Could anyone please check?

@ReneWerner87
Copy link
Member

we will check it out, may take a little while as there are many issues on the table at the moment

unfortunately you will have to be patient for a while
in the meantime you can set the json encoder and decoder to another engine or to the default engine

@shahriar350
Copy link
Author

we will check it out, may take a little while as there are many issues on the table at the moment

unfortunately you will have to be patient for a while in the meantime you can set the json encoder and decoder to another engine or to the default engine

Yes. that's why i normally use ffjson for json encoder and decoder and waiting for your future response.

@efectn
Copy link
Member

efectn commented Feb 7, 2022

@shahriar350 Can you send this to goccy/go-json as an issue?

I've already send them as a issue but they tell me to make a pprof measurement. They tell me that might be a environment issues. Because i dont know about pprof, that's why i cannot measure that. Here is my code Could anyone please check?

I'll look on weekend

@shahriar350
Copy link
Author

goccy/go-json#331 (comment)
go-json includes this issue in their performance category and goccy response with answer why this problem occurs.

@efectn efectn linked a pull request Apr 9, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants