g4lb opened a new pull request, #1703: URL: https://github.com/apache/arrow-go/pull/1703
### Rationale for this change `RecordBuilder.UnmarshalOne` calls `Schema.FieldIndices` for each JSON key, and that copies a slice each time. ### What changes are included in this PR? Add `Schema.FieldIdx`, the same as `StructType.FieldIdx`, and use it in `UnmarshalOne`. | Case | Time | Bytes | Allocs | |---|---|---|---| | `BenchmarkJSONReader`, all 9 cases | −2% to −10% | −2% to −3% | −18% | | 1000 rows, 3 fields | 677 → 569 µs (−16%) | 207 → 184 KiB | 13.1k → 10.1k | | 1000 rows, 3 fields, unknown key | 841 → 745 µs (−11%) | 262 → 231 KiB | 17.1k → 14.1k | | 1000 rows, 10 fields | 2.46 → 2.21 ms (−10%) | 1.14 → 1.07 MiB | 51.2k → 41.2k | | 1000 rows, 10 fields, unknown key | 2.67 → 2.45 ms (−8%) | 1.19 → 1.11 MiB | 55.2k → 45.2k | | 1000 rows, 30 fields | 8.38 → 7.67 ms (−9%) | 5.21 → 4.98 MiB | 155k → 125k | | 1000 rows, 30 fields, unknown key | 8.63 → 7.87 ms (−9%) | 5.26 → 5.03 MiB | 159k → 129k | No benchmark was slower in all 3 code layouts (Xeon 6973P, Go 1.27.4). ### Are these changes tested? Yes, with `TestSchemaFieldIdx`. `go test -race` passes. ### Are there any user-facing changes? Yes, the new `Schema.FieldIdx`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
