startreedata / pinot-client-go

Apache Pinot Golang Client managed by StarTree
Apache License 2.0
28 stars 10 forks source link

Defined structs not following field alignment #24

Closed abhioncbr closed 1 year ago

abhioncbr commented 1 year ago

Field alignment is a standard simple trick recommended in Go-based apps for better memory usage and fast processing. I found that the structs defined in the package aren't following the field alignment. Here is the output of the lint

$go vet -vettool=$(which fieldalignment) ./...
# github.com/startreedata/pinot-client-go/pinot
pinot/config.go:6:19: struct with 56 pointer bytes could be 32
pinot/config.go:25:22: struct with 32 pointer bytes could be 24
pinot/config.go:33:23: struct with 32 pointer bytes could be 16
pinot/controllerBasedBrokerSelector.go:28:30: struct with 96 pointer bytes could be 56
pinot/controllerResponse.go:8:16: struct with 32 pointer bytes could be 24
pinot/dynamicBrokerSelector.go:21:28: struct with 96 pointer bytes could be 64
pinot/dynamicBrokerSelector.go:30:19: struct with 40 pointer bytes could be 32
pinot/response.go:6:21: struct with 72 pointer bytes could be 56
pinot/response.go:54:16: struct with 16 pointer bytes could be 8
pinot/controllerBasedBrokerSelector_test.go:16:28: struct with 24 pointer bytes could be 16

This issue tracks to change the defined structs with aligned fields and add support in the lint for future checks.

I will work on this issue. Thanks

cc @xiangfu0

xiangfu0 commented 1 year ago

Thanks for taking this up! Is this more on changing the ordering of the fields in the struct?

abhioncbr commented 1 year ago

Yes, that's right.

abhioncbr commented 1 year ago

We can close this issue. Thanks.

xiangfu0 commented 1 year ago

Many thanks!