Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit has a few performance-related changes. The results are promising, but we need to validate on production load first. First, I changed the way that JSON got serialized from using a `map[string]interface{}` to a specific Go type. That already had the following impact: ``` benchmark old ns/op new ns/op delta BenchmarkBulkIndexRequestSerialization-8 3348 2285 -31.75% benchmark old allocs new allocs delta BenchmarkBulkIndexRequestSerialization-8 34 18 -47.06% benchmark old bytes new bytes delta BenchmarkBulkIndexRequestSerialization-8 2464 1744 -29.22% benchmark old ns/op new ns/op delta BenchmarkBulkUpdateRequestSerialization-8 3131 2091 -33.22% benchmark old allocs new allocs delta BenchmarkBulkUpdateRequestSerialization-8 39 19 -51.28% benchmark old bytes new bytes delta BenchmarkBulkUpdateRequestSerialization-8 2624 2624 +0.00% benchmark old ns/op new ns/op delta BenchmarkBulkDeleteRequestSerialization-8 2233 1158 -48.14% benchmark old allocs new allocs delta BenchmarkBulkDeleteRequestSerialization-8 28 11 -60.71% benchmark old bytes new bytes delta BenchmarkBulkDeleteRequestSerialization-8 1744 1664 -4.59% ``` Next, I enable a setting that makes Bulk API use `github.com/mailru/easyjson` instead of `encoding/json`. This yields the following results (compared to the baseline): ``` benchmark old ns/op new ns/op delta BenchmarkBulkIndexRequestSerialization-8 3348 1692 -49.46% benchmark old allocs new allocs delta BenchmarkBulkIndexRequestSerialization-8 34 12 -64.71% benchmark old bytes new bytes delta BenchmarkBulkIndexRequestSerialization-8 2464 1328 -46.10% benchmark old ns/op new ns/op delta BenchmarkBulkUpdateRequestSerialization-8 3131 1072 -65.76% benchmark old allocs new allocs delta BenchmarkBulkUpdateRequestSerialization-8 39 10 -74.36% benchmark old bytes new bytes delta BenchmarkBulkUpdateRequestSerialization-8 2624 1952 -25.61% benchmark old ns/op new ns/op delta BenchmarkBulkDeleteRequestSerialization-8 2233 593 -73.44% benchmark old allocs new allocs delta BenchmarkBulkDeleteRequestSerialization-8 28 5 -82.14% benchmark old bytes new bytes delta BenchmarkBulkDeleteRequestSerialization-8 1744 1280 -26.61% ``` You can enable serialization with `UseEasyJSON(true)` on the individual `BulkIndexRequest`, `BulkUpdateRequest`, and `BulkDeleteRequest`. Using easyjson is experimental for now. As easyjson relies on code generation, you can use `go generate` to create the underlying code. See #667 for discussion.
- Loading branch information