Comments (4)
Unless you mention that your library is compatible with encoding/json
, I think it's good to sacrifice functionality for performance 😄
However, if you want to compare performance with other libraries, you should, to be fair, see if the library you're comparing has an option that doesn't sort the map, and use that if any.
For example, json-iterator/go supported by SortMapKeys: false
at config . ( Also, my library support too by json.UnorderedMap()
option )
from sonic.
Is this a documented behaviour of the standard library?
from sonic.
See https://golang.org/pkg/encoding/json/#Marshal
The map keys are sorted and used as JSON object keys by applying the following rules, subject to the UTF-8 coercion described for string values above:
from sonic.
As you know, this behavior hurts performance A LOT, and it's specific to the Go StdLib, RFC8259 does NOT require sorting the keys.
This library is designed for performance, not a drop-in replacement of the StdLib, so we must drop some performance-killing "features", as long as it still meets the requirements of the RFC, it's a working implementation. It is OK to behave slightly different with the StdLib.
For reproducible tests, we might consider making it optional. You can then manually switch it on at the cost of some performance.
BTW, if you think the benchmark result is unfair, you can always disable key sorting in your library, and benchmark again.
Marked low-priority
now.
from sonic.
Related Issues (20)
- can sonic support fuzzy decode like jsonitor HOT 3
- 使用sync.Pool管理buf的时候,高QPS可能会导致类似内存占用过大 HOT 9
- go: module github.com/cloudwego/iasm@upgrade found (v0.1.0), but does not contain package github.com/cloudwego/iasm/x86_64 HOT 15
- github.com/bytedance/sonic/[email protected]: verifying go.mod: checksum mismatch HOT 9
- windows use sonic error
- 使用 marshal 方法出现问题 _blankCharsMask overflows int HOT 3
- github.com/bytedance/sonic/ast not support ARM32 "_blankCharsMask overflows int" HOT 2
- Go1.16 Encode/Marshal maybe OOM when high QPS for sonic v1.10.0~v1.11.6
- Go is going to lock down future uses of `linkname` HOT 6
- optimize stream decoder SkipOneFast
- 在启用cgo环境中的情况下,编译出错ast\decode.go:31:29: cannot use 4294977024 (untyped int constant) as int value in constant declaration (overflows) HOT 3
- Error: relocation target github.com/bytedance/sonic/internal/rt.StartProf not defined HOT 4
- Checking if a field has a certain JSON type HOT 1
- Unconsumed '}' in (*traverser).decodeObject() causes entries loss after nested empty object
- make strict and accurate build tags for all source files
- support marshal NaN and INF with customed handler
- Enhance the unittest and integration testing
- minimize the performance gap for stream APIs
- make fuzz testing run longer
- Incompatible with Go 1.23, which doesn't allow //go:linkname to internal symbols, including to runtime package HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sonic.