Skip to content

Seriallel attempts to increase the performance of serializing large data structures to JSON by parallelizing serialization of arrays and slices.

License

Notifications You must be signed in to change notification settings

blakearoberts/seriallel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Seriallel

Seriallel attempts to increase the performance of serializing large data structures to JSON. Namely, when an array or slice is encountered, each item is serialized in its own goroutine.

Getting Started

package main

import "github.com/blakearoberts/seriallel/json"

type Big struct {
    // ...
}

func main() {
    bigs := []Big{/* ... */}
    bytes, err := json.Marshal(bigs)
    if err != nil {
        panic(err)
    }
    println(string(bytes))
}

Performance

Really bad.

In practice, I was able to reduce serialization time from ~40ms to ~15ms for ~512KB payloads where the data structure resembled the following:

[
    {
        "field": [
            {},
            ..., m // m ~ 10
        ],
        ...,
    },
    ..., n // n ~ 20
]

About

Seriallel attempts to increase the performance of serializing large data structures to JSON by parallelizing serialization of arrays and slices.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published