go-json-experiment / json

Experimental implementation of a proposed v2 encoding/json package
BSD 3-Clause "New" or "Revised" License
341 stars 11 forks source link

all: fix strut field order for more less memory #3

Closed zchee closed 1 year ago

zchee commented 2 years ago

Fix strut field order for less memory.

benchmark diff: https://perf.golang.org/search?q=upload:20211030.7.

cristaloleg commented 2 years ago

Results from maligned linter?

zchee commented 2 years ago

No, fieldalign and revert conment block by hand.

dsnet commented 2 years ago

Hi, thanks for the PR! Per https://github.com/go-json-experiment/json/pull/2#issuecomment-956592941, this repository is just a mirror, and isn't really in a place to accept pull requests. We haven't thought too much about how to accept contributions.

Regarding this specific PR: While this reduces the memory size of structs, it also reorders fields in unnatural way. For example, we definitely should not reorder the fields in SemanticError and SyntacticError. Errors are not expected to occur in the common case, and readability of the structs takes higher precedence. Furthermore, a few of these changes have no effect (e.g., decodeBuffer and encodeBuffer).

At the present moment, we're focused on getting the semantics where we would like it before looking more broadly at performance optimizations.

dsnet commented 1 year ago

Closing as the source of truth for this module is not this mirror.