bytedance / sonic

A blazingly fast JSON serializing & deserializing library
Apache License 2.0
6.71k stars 333 forks source link

Compilation consumes many resources #561

Closed llwwbb closed 9 months ago

llwwbb commented 9 months ago

Compiling the following simple code will consume a lot of CPU memory and disk resources. 7B30A4B1-6E40-4091-859F-EDD6DBA8DF7E 截屏2023-12-10 10 37 08

Everything works fine in v1.9.2

go.mod

module test

go 1.21

require github.com/bytedance/sonic v1.10.2

require (
    github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
    github.com/chenzhuoyu/iasm v0.9.0 // indirect
    github.com/klauspost/cpuid/v2 v2.0.9 // indirect
    github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
    golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
)

main.go

package main
import "log"
import "github.com/bytedance/sonic"
type S struct {
    A int
}
func main() {
    var s S
    err := sonic.Unmarshal([]byte("{\"A\": 1}"), &s)
    if err != nil {
        log.Println(err)
    }
    log.Println(s)
}
llwwbb commented 9 months ago

~ cat /proc/version Linux version 5.10.0-16-amd64 (debian-kernel@lists.debian.org) (gcc-10 (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2) #1 SMP Debian 5.10.127-2 (2022-07-23)

AsterDY commented 9 months ago

It's worth trading off online performance. BTW, why not compare with C++ programs? You will get used to it ;)

nightwolfz commented 8 months ago

It must be that 90 MB dependency, slow compile and makes my binary big :'(

Any plans to improve this?

goweight             
   90 MB github.com/chenzhuoyu/iasm/x86_64
   51 MB github.com/redis/rueidis/internal/cmds
   23 MB github.com/jackc/pgx/v5/pgtype
   11 MB runtime
  8.7 MB github.com/redis/rueidis/rueidiscompat
  7.7 MB net/http
  6.2 MB github.com/yugabyte/gocql
  5.6 MB github.com/gogo/protobuf/proto
  5.3 MB google.golang.org/protobuf/internal/impl