Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: speed up adding fields, reduce memalloc if field name is alread…
…y prefixed with "app." (#406) ## Which problem is this PR solving? - Closes #401 There is a remarkable amount of memory allocation occurring under load to perform the "app." prefixing of field names by the Beeline. ## Short description of the changes This change skips the memory allocations needed for string concat and usage if the "app." prefix is already present on the field name provided. * doc comments updated to recommend users prefix their field names with "app." when calling these beeline.AddField*() functions * doc comments also updated to make the handling of Error as value more clear ### Benchmarks Existing behavior is no slower or memory hungry, but for every field name provided by the Beeline user that starts with "app.", that is one less memory allocation of the size of the field name string. ``` BenchmarkBeelineAddField/oldAddField/whatever BenchmarkBeelineAddField/oldAddField/whatever-12 19654003 60.52 ns/op 8 B/op 1 allocs/op BenchmarkBeelineAddField/AddField/no-prefix BenchmarkBeelineAddField/AddField/no-prefix-12 18939754 60.65 ns/op 8 B/op 1 allocs/op BenchmarkBeelineAddField/AddField/half-prefixed BenchmarkBeelineAddField/AddField/half-prefixed-12 22405790 51.22 ns/op 4 B/op 0 allocs/op BenchmarkBeelineAddField/AddField/all-prefixed BenchmarkBeelineAddField/AddField/all-prefixed-12 27381916 42.88 ns/op 0 B/op 0 allocs/op ``` --------- Co-authored-by: JamieDanielson <jamieedanielson@gmail.com>
- Loading branch information