Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: struct field alignment #2632

Merged
merged 1 commit into from
Apr 26, 2023
Merged

fix: struct field alignment #2632

merged 1 commit into from
Apr 26, 2023

Conversation

lukaszraczylo
Copy link
Contributor

@lukaszraczylo lukaszraczylo commented Apr 18, 2023

This PR sorts the structs fields so they are aligned in memory. This is supposed to be a performance improvement decreasing the overall memory footprint

More information on the process and reasoning: https://en.wikipedia.org/wiki/Data_structure_alignment

Example of struct alignment to visualise the impact:

** Before **
image

** After **
image

Changes to the structs:

go-micro/util/ring/buffer.go:12:13: struct with 64 pointer bytes could be 16
go-micro/util/ring/buffer.go:27:13: struct with 32 pointer bytes could be 24
go-micro/debug/log/options.go:9:14: struct with 32 pointer bytes could be 16
go-micro/debug/log/os.go:11:12: struct with 64 pointer bytes could be 24
go-micro/logger/default.go:25:20: struct with 80 pointer bytes could be 56
go-micro/logger/options.go:10:14: struct with 56 pointer bytes could be 40
go-micro/auth/auth.go:55:14: struct with 88 pointer bytes could be 80
go-micro/auth/auth.go:71:12: struct with 80 pointer bytes could be 72
go-micro/auth/auth.go:108:11: struct with 40 pointer bytes could be 32
go-micro/auth/options.go:22:14: struct with 128 pointer bytes could be 112
go-micro/auth/options.go:93:22: struct with 72 pointer bytes could be 64
go-micro/codec/codec.go:57:14: struct with 104 pointer bytes could be 96
go-micro/util/mdns/client.go:18:19: struct of size 176 could be 168
go-micro/util/mdns/client.go:41:17: struct of size 88 could be 80
go-micro/util/mdns/client.go:166:13: struct with 48 pointer bytes could be 40
go-micro/util/mdns/server.go:47:13: struct with 40 pointer bytes could be 32
go-micro/util/mdns/server.go:68:13: struct with 72 pointer bytes could be 40
go-micro/util/mdns/zone.go:26:18: struct with 168 pointer bytes could be 144
go-micro/registry/mdns_registry.go:28:14: struct with 64 pointer bytes could be 48
go-micro/registry/mdns_registry.go:35:16: struct with 24 pointer bytes could be 16
go-micro/registry/mdns_registry.go:40:19: struct with 80 pointer bytes could be 40
go-micro/registry/mdns_registry.go:57:18: struct with 88 pointer bytes could be 80
go-micro/registry/memory.go:16:11: struct with 40 pointer bytes could be 32
go-micro/registry/memory.go:30:18: struct with 48 pointer bytes could be 24
go-micro/registry/memory_watcher.go:7:17: struct with 64 pointer bytes could be 56
go-micro/registry/options.go:11:14: struct with 80 pointer bytes could be 48
go-micro/registry/options.go:22:22: struct with 24 pointer bytes could be 16
go-micro/registry/options.go:29:19: struct with 32 pointer bytes could be 24
go-micro/registry/registry.go:39:11: struct with 40 pointer bytes could be 32
go-micro/registry/registry.go:45:15: struct with 40 pointer bytes could be 32
go-micro/registry/watcher.go:15:13: struct with 24 pointer bytes could be 16
go-micro/registry/watcher.go:47:12: struct with 56 pointer bytes could be 40
go-micro/registry/cache/cache.go:25:14: struct with 24 pointer bytes could be 16
go-micro/registry/cache/cache.go:34:12: struct with 136 pointer bytes could be 112
go-micro/broker/http.go:31:17: struct with 256 pointer bytes could be 192
go-micro/broker/http.go:51:21: struct with 96 pointer bytes could be 88
go-micro/broker/http.go:60:16: struct with 40 pointer bytes could be 32
go-micro/broker/memory.go:16:19: struct with 64 pointer bytes could be 24
go-micro/broker/memory.go:25:18: struct with 56 pointer bytes could be 48
go-micro/broker/memory.go:32:23: struct with 88 pointer bytes could be 80
go-micro/broker/options.go:12:14: struct with 112 pointer bytes could be 88
go-micro/broker/options.go:38:23: struct with 40 pointer bytes could be 24
go-micro/cache/memory.go:9:15: struct with 96 pointer bytes could be 72
go-micro/cache/options.go:11:14: struct with 64 pointer bytes could be 48
go-micro/codec/jsonrpc/client.go:12:18: struct with 136 pointer bytes could be 128
go-micro/codec/jsonrpc/client.go:25:20: struct with 48 pointer bytes could be 40
go-micro/codec/jsonrpc/jsonrpc.go:13:16: struct with 48 pointer bytes could be 40
go-micro/codec/jsonrpc/server.go:21:20: struct with 40 pointer bytes could be 32
go-micro/codec/protorpc/protorpc.go:19:17: struct with 40 pointer bytes could be 24
go-micro/selector/options.go:21:20: struct with 48 pointer bytes could be 32
go-micro/transport/http_client.go:19:26: struct of size 200 could be 192
go-micro/transport/http_socket.go:15:26: struct with 128 pointer bytes could be 104
go-micro/transport/memory.go:18:19: struct with 112 pointer bytes could be 88
go-micro/transport/memory.go:47:21: struct with 192 pointer bytes could be 160
go-micro/transport/memory.go:57:22: struct with 136 pointer bytes could be 104
go-micro/transport/options.go:17:14: struct with 96 pointer bytes could be 64
go-micro/transport/options.go:41:18: struct of size 40 could be 32
go-micro/util/pool/default.go:12:11: struct with 48 pointer bytes could be 24
go-micro/util/pool/default.go:21:15: struct with 56 pointer bytes could be 48
go-micro/client/options.go:33:14: struct with 352 pointer bytes could be 320
go-micro/client/options.go:69:18: struct of size 168 could be 160
go-micro/client/options.go:104:21: struct with 32 pointer bytes could be 24
go-micro/client/options.go:116:21: struct with 40 pointer bytes could be 24
go-micro/client/rpc_client.go:32:16: struct with 392 pointer bytes could be 384
go-micro/client/rpc_message.go:3:14: struct with 48 pointer bytes could be 40
go-micro/client/rpc_request.go:7:17: struct with 136 pointer bytes could be 128
go-micro/client/rpc_response.go:8:18: struct with 64 pointer bytes could be 48
go-micro/client/rpc_stream.go:13:16: struct of size 152 could be 144
go-micro/config/source/source.go:23:16: struct with 96 pointer bytes could be 80
go-micro/config/loader/loader.go:46:14: struct with 56 pointer bytes could be 40
go-micro/config/loader/memory/memory.go:19:13: struct with 176 pointer bytes could be 136
go-micro/config/loader/memory/memory.go:36:18: struct with 32 pointer bytes could be 24
go-micro/config/loader/memory/memory.go:41:14: struct with 88 pointer bytes could be 72
go-micro/config/source/file/file.go:12:11: struct with 80 pointer bytes could be 72
go-micro/config/config.go:37:14: struct with 72 pointer bytes could be 56
go-micro/config/default.go:15:13: struct with 136 pointer bytes could be 104
go-micro/config/default.go:26:14: struct with 72 pointer bytes could be 56
go-micro/debug/trace/default.go:11:16: struct with 16 pointer bytes could be 8
go-micro/debug/trace/trace.go:38:11: struct with 104 pointer bytes could be 88
go-micro/runtime/local/build/build.go:17:13: struct with 24 pointer bytes could be 16
go-micro/runtime/local/build/build.go:25:14: struct with 56 pointer bytes could be 48
go-micro/runtime/local/git/git.go:207:13: struct with 80 pointer bytes could be 72
go-micro/runtime/local/process/process.go:22:17: struct with 64 pointer bytes could be 56
go-micro/runtime/local/process/process.go:34:10: struct with 64 pointer bytes could be 56
go-micro/runtime/default.go:23:14: struct with 64 pointer bytes could be 32
go-micro/runtime/default.go:436:16: struct with 80 pointer bytes could be 64
go-micro/runtime/options.go:14:14: struct with 96 pointer bytes could be 88
go-micro/runtime/options.go:88:20: struct with 160 pointer bytes could be 136
go-micro/runtime/options.go:110:18: struct with 80 pointer bytes could be 72
go-micro/runtime/options.go:224:20: struct with 32 pointer bytes could be 24
go-micro/runtime/options.go:247:20: struct with 32 pointer bytes could be 24
go-micro/runtime/options.go:272:18: struct with 48 pointer bytes could be 24
go-micro/runtime/runtime.go:47:16: struct with 24 pointer bytes could be 16
go-micro/runtime/runtime.go:87:12: struct with 64 pointer bytes could be 48
go-micro/runtime/runtime.go:101:14: struct with 56 pointer bytes could be 48
go-micro/runtime/service.go:17:14: struct with 160 pointer bytes could be 112
go-micro/util/socket/pool.go:7:11: struct with 32 pointer bytes could be 8
go-micro/util/socket/socket.go:11:13: struct with 72 pointer bytes could be 64
go-micro/server/handler.go:7:21: struct with 16 pointer bytes could be 8
go-micro/server/handler.go:14:24: struct of size 48 could be 40
go-micro/server/options.go:42:14: struct with 312 pointer bytes could be 280
go-micro/server/rpc_codec.go:21:15: struct with 96 pointer bytes could be 64
go-micro/server/rpc_codec.go:34:22: struct with 40 pointer bytes could be 16
go-micro/server/rpc_handler.go:9:17: struct with 72 pointer bytes could be 56
go-micro/server/rpc_request.go:11:17: struct with 144 pointer bytes could be 128
go-micro/server/rpc_request.go:25:17: struct with 88 pointer bytes could be 72
go-micro/server/rpc_router.go:28:17: struct with 136 pointer bytes could be 112
go-micro/server/rpc_router.go:37:14: struct with 64 pointer bytes could be 56
go-micro/server/rpc_router.go:55:13: struct with 160 pointer bytes could be 96
go-micro/server/rpc_server.go:29:16: struct with 408 pointer bytes could be 376
go-micro/server/rpc_stream.go:13:16: struct with 112 pointer bytes could be 72
go-micro/server/rpc_util.go:8:16: struct with 24 pointer bytes could be 8
go-micro/server/subscriber.go:14:14: struct with 56 pointer bytes could be 48
go-micro/server/subscriber.go:20:17: struct with 168 pointer bytes could be 152
go-micro/store/memory.go:34:18: struct with 72 pointer bytes could be 56
go-micro/store/options.go:12:14: struct with 104 pointer bytes could be 88
go-micro/store/options.go:129:19: struct with 56 pointer bytes could be 48
go-micro/store/store.go:38:13: struct with 48 pointer bytes could be 32
go-micro/debug/profile/http/http.go:13:18: struct with 24 pointer bytes could be 8
go-micro/debug/profile/pprof/pprof.go:14:15: struct with 48 pointer bytes could be 24
go-micro/util/cmd/options.go:21:14: struct with 272 pointer bytes could be 264
go-micro/options.go:26:14: struct with 320 pointer bytes could be 304
go-micro/api/resolver/resolver.go:33:14: struct with 24 pointer bytes could be 16
go-micro/api/router/options.go:11:14: struct with 64 pointer bytes could be 56
go-micro/api/handler/options.go:15:14: struct with 72 pointer bytes could be 56
go-micro/api/router/util/compile.go:11:15: struct with 104 pointer bytes could be 88
go-micro/api/router/util/compile.go:32:9: struct with 16 pointer bytes could be 8
go-micro/api/router/util/parse.go:109:13: struct with 64 pointer bytes could be 48
go-micro/api/router/util/runtime.go:26:14: struct with 96 pointer bytes could be 72
go-micro/api/router/util/runtime.go:44:21: struct with 24 pointer bytes could be 16
go-micro/api/router/util/types.go:11:15: struct with 48 pointer bytes could be 40
go-micro/api/router/registry/registry.go:29:21: struct with 128 pointer bytes could be 104
go-micro/api/server/acme/options.go:12:14: struct of size 80 could be 72
go-micro/api/server/cors/cors.go:7:13: struct with 48 pointer bytes could be 40
go-micro/api/server/options.go:15:14: struct of size 128 could be 120
go-micro/api/server/http/http.go:17:17: struct with 184 pointer bytes could be 152
go-micro/api/api.go:34:14: struct with 48 pointer bytes could be 40
go-micro/api/client/client.go:48:15: struct with 64 pointer bytes could be 56
go-micro/api/router/static/static.go:27:13: struct with 104 pointer bytes could be 80
go-micro/config/secrets/secrets.go:20:14: struct with 88 pointer bytes could be 72
go-micro/config/source/env/env.go:17:10: struct with 96 pointer bytes could be 80
go-micro/config/source/memory/memory.go:12:13: struct with 40 pointer bytes could be 16
go-micro/config/source/memory/watcher.go:7:14: struct with 32 pointer bytes could be 24
go-micro/events/events.go:40:12: struct with 104 pointer bytes could be 88
go-micro/events/memory.go:23:17: struct with 72 pointer bytes could be 40
go-micro/events/options.go:27:19: struct with 40 pointer bytes could be 32
go-micro/events/options.go:68:21: struct of size 72 could be 64
go-micro/util/kubernetes/api/request.go:17:14: struct with 152 pointer bytes could be 144
go-micro/util/kubernetes/api/request.go:248:14: struct with 48 pointer bytes could be 40
go-micro/util/kubernetes/client/options.go:7:17: struct with 24 pointer bytes could be 16
go-micro/util/kubernetes/client/options.go:21:17: struct with 24 pointer bytes could be 16
go-micro/util/kubernetes/client/options.go:26:19: struct with 24 pointer bytes could be 16
go-micro/util/kubernetes/client/types.go:4:20: struct with 40 pointer bytes could be 24
go-micro/util/kubernetes/client/types.go:34:21: struct with 24 pointer bytes could be 16
go-micro/util/kubernetes/client/types.go:49:23: struct with 48 pointer bytes could be 8
go-micro/util/kubernetes/client/types.go:86:15: struct with 64 pointer bytes could be 56
go-micro/util/kubernetes/client/types.go:95:14: struct with 32 pointer bytes could be 24
go-micro/util/kubernetes/client/types.go:113:16: struct with 88 pointer bytes could be 80
go-micro/util/kubernetes/client/types.go:139:15: struct with 48 pointer bytes could be 40
go-micro/util/kubernetes/client/types.go:146:18: struct with 32 pointer bytes could be 24
go-micro/util/kubernetes/client/types.go:199:13: struct with 32 pointer bytes could be 24
go-micro/runtime/kubernetes/kubernetes.go:17:17: struct with 72 pointer bytes could be 40
go-micro/runtime/kubernetes/kubernetes.go:348:17: struct with 40 pointer bytes could be 32
go-micro/runtime/kubernetes/logs.go:17:11: struct with 80 pointer bytes could be 72
go-micro/runtime/local/build/docker/docker.go:16:14: struct with 24 pointer bytes could be 16
go-micro/server/mock/mock.go:11:17: struct with 344 pointer bytes could be 328
go-micro/server/mock/mock_handler.go:8:18: struct with 48 pointer bytes could be 40
go-micro/server/mock/mock_subscriber.go:8:21: struct with 80 pointer bytes could be 72
go-micro/sync/sync.go:41:14: struct with 80 pointer bytes could be 64
go-micro/util/file/handler.go:32:14: struct with 40 pointer bytes could be 32
go-micro/util/file/handler.go:122:14: struct with 16 pointer bytes could be 8
go-micro/util/pki/certoptions.go:13:18: struct with 400 pointer bytes could be 392
go-micro/util/stream/stream.go:21:13: struct with 64 pointer bytes could be 40
go-micro/util/sync/manager.go:10:16: struct with 40 pointer bytes could be 32
go-micro/util/sync/sync.go:22:16: struct with 176 pointer bytes could be 160
go-micro/util/sync/sync.go:110:21: struct with 64 pointer bytes could be 48
go-micro/util/wrapper/wrapper.go:69:19: struct with 48 pointer bytes could be 40
go-micro/web/options.go:16:14: struct of size 368 could be 360
go-micro/web/service.go:27:14: struct with 432 pointer bytes could be 384

This PR sorts the structs fields so they are aligned in memory.
This is supposed to be a performance improvement decreasing overall memory footprint.

More information on the process and reasoning: https://en.wikipedia.org/wiki/Data_structure_alignment

Changes to the structs:

go-micro/util/ring/buffer.go:12:13: struct with 64 pointer bytes could be 16
go-micro/util/ring/buffer.go:27:13: struct with 32 pointer bytes could be 24
go-micro/debug/log/options.go:9:14: struct with 32 pointer bytes could be 16
go-micro/debug/log/os.go:11:12: struct with 64 pointer bytes could be 24
go-micro/logger/default.go:25:20: struct with 80 pointer bytes could be 56
go-micro/logger/options.go:10:14: struct with 56 pointer bytes could be 40
go-micro/auth/auth.go:55:14: struct with 88 pointer bytes could be 80
go-micro/auth/auth.go:71:12: struct with 80 pointer bytes could be 72
go-micro/auth/auth.go:108:11: struct with 40 pointer bytes could be 32
go-micro/auth/options.go:22:14: struct with 128 pointer bytes could be 112
go-micro/auth/options.go:93:22: struct with 72 pointer bytes could be 64
go-micro/codec/codec.go:57:14: struct with 104 pointer bytes could be 96
go-micro/util/mdns/client.go:18:19: struct of size 176 could be 168
go-micro/util/mdns/client.go:41:17: struct of size 88 could be 80
go-micro/util/mdns/client.go:166:13: struct with 48 pointer bytes could be 40
go-micro/util/mdns/server.go:47:13: struct with 40 pointer bytes could be 32
go-micro/util/mdns/server.go:68:13: struct with 72 pointer bytes could be 40
go-micro/util/mdns/zone.go:26:18: struct with 168 pointer bytes could be 144
go-micro/registry/mdns_registry.go:28:14: struct with 64 pointer bytes could be 48
go-micro/registry/mdns_registry.go:35:16: struct with 24 pointer bytes could be 16
go-micro/registry/mdns_registry.go:40:19: struct with 80 pointer bytes could be 40
go-micro/registry/mdns_registry.go:57:18: struct with 88 pointer bytes could be 80
go-micro/registry/memory.go:16:11: struct with 40 pointer bytes could be 32
go-micro/registry/memory.go:30:18: struct with 48 pointer bytes could be 24
go-micro/registry/memory_watcher.go:7:17: struct with 64 pointer bytes could be 56
go-micro/registry/options.go:11:14: struct with 80 pointer bytes could be 48
go-micro/registry/options.go:22:22: struct with 24 pointer bytes could be 16
go-micro/registry/options.go:29:19: struct with 32 pointer bytes could be 24
go-micro/registry/registry.go:39:11: struct with 40 pointer bytes could be 32
go-micro/registry/registry.go:45:15: struct with 40 pointer bytes could be 32
go-micro/registry/watcher.go:15:13: struct with 24 pointer bytes could be 16
go-micro/registry/watcher.go:47:12: struct with 56 pointer bytes could be 40
go-micro/registry/cache/cache.go:25:14: struct with 24 pointer bytes could be 16
go-micro/registry/cache/cache.go:34:12: struct with 136 pointer bytes could be 112
go-micro/broker/http.go:31:17: struct with 256 pointer bytes could be 192
go-micro/broker/http.go:51:21: struct with 96 pointer bytes could be 88
go-micro/broker/http.go:60:16: struct with 40 pointer bytes could be 32
go-micro/broker/memory.go:16:19: struct with 64 pointer bytes could be 24
go-micro/broker/memory.go:25:18: struct with 56 pointer bytes could be 48
go-micro/broker/memory.go:32:23: struct with 88 pointer bytes could be 80
go-micro/broker/options.go:12:14: struct with 112 pointer bytes could be 88
go-micro/broker/options.go:38:23: struct with 40 pointer bytes could be 24
go-micro/cache/memory.go:9:15: struct with 96 pointer bytes could be 72
go-micro/cache/options.go:11:14: struct with 64 pointer bytes could be 48
go-micro/codec/jsonrpc/client.go:12:18: struct with 136 pointer bytes could be 128
go-micro/codec/jsonrpc/client.go:25:20: struct with 48 pointer bytes could be 40
go-micro/codec/jsonrpc/jsonrpc.go:13:16: struct with 48 pointer bytes could be 40
go-micro/codec/jsonrpc/server.go:21:20: struct with 40 pointer bytes could be 32
go-micro/codec/protorpc/protorpc.go:19:17: struct with 40 pointer bytes could be 24
go-micro/selector/options.go:21:20: struct with 48 pointer bytes could be 32
go-micro/transport/http_client.go:19:26: struct of size 200 could be 192
go-micro/transport/http_socket.go:15:26: struct with 128 pointer bytes could be 104
go-micro/transport/memory.go:18:19: struct with 112 pointer bytes could be 88
go-micro/transport/memory.go:47:21: struct with 192 pointer bytes could be 160
go-micro/transport/memory.go:57:22: struct with 136 pointer bytes could be 104
go-micro/transport/options.go:17:14: struct with 96 pointer bytes could be 64
go-micro/transport/options.go:41:18: struct of size 40 could be 32
go-micro/util/pool/default.go:12:11: struct with 48 pointer bytes could be 24
go-micro/util/pool/default.go:21:15: struct with 56 pointer bytes could be 48
go-micro/client/options.go:33:14: struct with 352 pointer bytes could be 320
go-micro/client/options.go:69:18: struct of size 168 could be 160
go-micro/client/options.go:104:21: struct with 32 pointer bytes could be 24
go-micro/client/options.go:116:21: struct with 40 pointer bytes could be 24
go-micro/client/rpc_client.go:32:16: struct with 392 pointer bytes could be 384
go-micro/client/rpc_message.go:3:14: struct with 48 pointer bytes could be 40
go-micro/client/rpc_request.go:7:17: struct with 136 pointer bytes could be 128
go-micro/client/rpc_response.go:8:18: struct with 64 pointer bytes could be 48
go-micro/client/rpc_stream.go:13:16: struct of size 152 could be 144
go-micro/config/source/source.go:23:16: struct with 96 pointer bytes could be 80
go-micro/config/loader/loader.go:46:14: struct with 56 pointer bytes could be 40
go-micro/config/loader/memory/memory.go:19:13: struct with 176 pointer bytes could be 136
go-micro/config/loader/memory/memory.go:36:18: struct with 32 pointer bytes could be 24
go-micro/config/loader/memory/memory.go:41:14: struct with 88 pointer bytes could be 72
go-micro/config/source/file/file.go:12:11: struct with 80 pointer bytes could be 72
go-micro/config/config.go:37:14: struct with 72 pointer bytes could be 56
go-micro/config/default.go:15:13: struct with 136 pointer bytes could be 104
go-micro/config/default.go:26:14: struct with 72 pointer bytes could be 56
go-micro/debug/trace/default.go:11:16: struct with 16 pointer bytes could be 8
go-micro/debug/trace/trace.go:38:11: struct with 104 pointer bytes could be 88
go-micro/runtime/local/build/build.go:17:13: struct with 24 pointer bytes could be 16
go-micro/runtime/local/build/build.go:25:14: struct with 56 pointer bytes could be 48
go-micro/runtime/local/git/git.go:207:13: struct with 80 pointer bytes could be 72
go-micro/runtime/local/process/process.go:22:17: struct with 64 pointer bytes could be 56
go-micro/runtime/local/process/process.go:34:10: struct with 64 pointer bytes could be 56
go-micro/runtime/default.go:23:14: struct with 64 pointer bytes could be 32
go-micro/runtime/default.go:436:16: struct with 80 pointer bytes could be 64
go-micro/runtime/options.go:14:14: struct with 96 pointer bytes could be 88
go-micro/runtime/options.go:88:20: struct with 160 pointer bytes could be 136
go-micro/runtime/options.go:110:18: struct with 80 pointer bytes could be 72
go-micro/runtime/options.go:224:20: struct with 32 pointer bytes could be 24
go-micro/runtime/options.go:247:20: struct with 32 pointer bytes could be 24
go-micro/runtime/options.go:272:18: struct with 48 pointer bytes could be 24
go-micro/runtime/runtime.go:47:16: struct with 24 pointer bytes could be 16
go-micro/runtime/runtime.go:87:12: struct with 64 pointer bytes could be 48
go-micro/runtime/runtime.go:101:14: struct with 56 pointer bytes could be 48
go-micro/runtime/service.go:17:14: struct with 160 pointer bytes could be 112
go-micro/util/socket/pool.go:7:11: struct with 32 pointer bytes could be 8
go-micro/util/socket/socket.go:11:13: struct with 72 pointer bytes could be 64
go-micro/server/handler.go:7:21: struct with 16 pointer bytes could be 8
go-micro/server/handler.go:14:24: struct of size 48 could be 40
go-micro/server/options.go:42:14: struct with 312 pointer bytes could be 280
go-micro/server/rpc_codec.go:21:15: struct with 96 pointer bytes could be 64
go-micro/server/rpc_codec.go:34:22: struct with 40 pointer bytes could be 16
go-micro/server/rpc_handler.go:9:17: struct with 72 pointer bytes could be 56
go-micro/server/rpc_request.go:11:17: struct with 144 pointer bytes could be 128
go-micro/server/rpc_request.go:25:17: struct with 88 pointer bytes could be 72
go-micro/server/rpc_router.go:28:17: struct with 136 pointer bytes could be 112
go-micro/server/rpc_router.go:37:14: struct with 64 pointer bytes could be 56
go-micro/server/rpc_router.go:55:13: struct with 160 pointer bytes could be 96
go-micro/server/rpc_server.go:29:16: struct with 408 pointer bytes could be 376
go-micro/server/rpc_stream.go:13:16: struct with 112 pointer bytes could be 72
go-micro/server/rpc_util.go:8:16: struct with 24 pointer bytes could be 8
go-micro/server/subscriber.go:14:14: struct with 56 pointer bytes could be 48
go-micro/server/subscriber.go:20:17: struct with 168 pointer bytes could be 152
go-micro/store/memory.go:34:18: struct with 72 pointer bytes could be 56
go-micro/store/options.go:12:14: struct with 104 pointer bytes could be 88
go-micro/store/options.go:129:19: struct with 56 pointer bytes could be 48
go-micro/store/store.go:38:13: struct with 48 pointer bytes could be 32
go-micro/debug/profile/http/http.go:13:18: struct with 24 pointer bytes could be 8
go-micro/debug/profile/pprof/pprof.go:14:15: struct with 48 pointer bytes could be 24
go-micro/util/cmd/options.go:21:14: struct with 272 pointer bytes could be 264
go-micro/options.go:26:14: struct with 320 pointer bytes could be 304
go-micro/api/resolver/resolver.go:33:14: struct with 24 pointer bytes could be 16
go-micro/api/router/options.go:11:14: struct with 64 pointer bytes could be 56
go-micro/api/handler/options.go:15:14: struct with 72 pointer bytes could be 56
go-micro/api/router/util/compile.go:11:15: struct with 104 pointer bytes could be 88
go-micro/api/router/util/compile.go:32:9: struct with 16 pointer bytes could be 8
go-micro/api/router/util/parse.go:109:13: struct with 64 pointer bytes could be 48
go-micro/api/router/util/runtime.go:26:14: struct with 96 pointer bytes could be 72
go-micro/api/router/util/runtime.go:44:21: struct with 24 pointer bytes could be 16
go-micro/api/router/util/types.go:11:15: struct with 48 pointer bytes could be 40
go-micro/api/router/registry/registry.go:29:21: struct with 128 pointer bytes could be 104
go-micro/api/server/acme/options.go:12:14: struct of size 80 could be 72
go-micro/api/server/cors/cors.go:7:13: struct with 48 pointer bytes could be 40
go-micro/api/server/options.go:15:14: struct of size 128 could be 120
go-micro/api/server/http/http.go:17:17: struct with 184 pointer bytes could be 152
go-micro/api/api.go:34:14: struct with 48 pointer bytes could be 40
go-micro/api/client/client.go:48:15: struct with 64 pointer bytes could be 56
go-micro/api/router/static/static.go:27:13: struct with 104 pointer bytes could be 80
go-micro/config/secrets/secrets.go:20:14: struct with 88 pointer bytes could be 72
go-micro/config/source/env/env.go:17:10: struct with 96 pointer bytes could be 80
go-micro/config/source/memory/memory.go:12:13: struct with 40 pointer bytes could be 16
go-micro/config/source/memory/watcher.go:7:14: struct with 32 pointer bytes could be 24
go-micro/events/events.go:40:12: struct with 104 pointer bytes could be 88
go-micro/events/memory.go:23:17: struct with 72 pointer bytes could be 40
go-micro/events/options.go:27:19: struct with 40 pointer bytes could be 32
go-micro/events/options.go:68:21: struct of size 72 could be 64
go-micro/util/kubernetes/api/request.go:17:14: struct with 152 pointer bytes could be 144
go-micro/util/kubernetes/api/request.go:248:14: struct with 48 pointer bytes could be 40
go-micro/util/kubernetes/client/options.go:7:17: struct with 24 pointer bytes could be 16
go-micro/util/kubernetes/client/options.go:21:17: struct with 24 pointer bytes could be 16
go-micro/util/kubernetes/client/options.go:26:19: struct with 24 pointer bytes could be 16
go-micro/util/kubernetes/client/types.go:4:20: struct with 40 pointer bytes could be 24
go-micro/util/kubernetes/client/types.go:34:21: struct with 24 pointer bytes could be 16
go-micro/util/kubernetes/client/types.go:49:23: struct with 48 pointer bytes could be 8
go-micro/util/kubernetes/client/types.go:86:15: struct with 64 pointer bytes could be 56
go-micro/util/kubernetes/client/types.go:95:14: struct with 32 pointer bytes could be 24
go-micro/util/kubernetes/client/types.go:113:16: struct with 88 pointer bytes could be 80
go-micro/util/kubernetes/client/types.go:139:15: struct with 48 pointer bytes could be 40
go-micro/util/kubernetes/client/types.go:146:18: struct with 32 pointer bytes could be 24
go-micro/util/kubernetes/client/types.go:199:13: struct with 32 pointer bytes could be 24
go-micro/runtime/kubernetes/kubernetes.go:17:17: struct with 72 pointer bytes could be 40
go-micro/runtime/kubernetes/kubernetes.go:348:17: struct with 40 pointer bytes could be 32
go-micro/runtime/kubernetes/logs.go:17:11: struct with 80 pointer bytes could be 72
go-micro/runtime/local/build/docker/docker.go:16:14: struct with 24 pointer bytes could be 16
go-micro/server/mock/mock.go:11:17: struct with 344 pointer bytes could be 328
go-micro/server/mock/mock_handler.go:8:18: struct with 48 pointer bytes could be 40
go-micro/server/mock/mock_subscriber.go:8:21: struct with 80 pointer bytes could be 72
go-micro/sync/sync.go:41:14: struct with 80 pointer bytes could be 64
go-micro/util/file/handler.go:32:14: struct with 40 pointer bytes could be 32
go-micro/util/file/handler.go:122:14: struct with 16 pointer bytes could be 8
go-micro/util/pki/certoptions.go:13:18: struct with 400 pointer bytes could be 392
go-micro/util/stream/stream.go:21:13: struct with 64 pointer bytes could be 40
go-micro/util/sync/manager.go:10:16: struct with 40 pointer bytes could be 32
go-micro/util/sync/sync.go:22:16: struct with 176 pointer bytes could be 160
go-micro/util/sync/sync.go:110:21: struct with 64 pointer bytes could be 48
go-micro/util/wrapper/wrapper.go:69:19: struct with 48 pointer bytes could be 40
go-micro/web/options.go:16:14: struct of size 368 could be 360
go-micro/web/service.go:27:14: struct with 432 pointer bytes could be 384
@lukaszraczylo
Copy link
Contributor Author

After the pipelines are fixed, please re-run them if possible. Ran the tests locally, and except of "I haven't changed it so it should not fail" all was clear :)

@Davincible
Copy link
Contributor

Hi Lukas, thanks a lot for the work. Looks like a great improvement. What tools did you use for the alignment?

@Davincible Davincible changed the title Fix fields alignment within the structs. fix: struct field alignment Apr 26, 2023
@Davincible Davincible merged commit a7522e7 into micro:master Apr 26, 2023
@lukaszraczylo
Copy link
Contributor Author

@Davincible Not a problem; I've been on the hyper-optimisation binge recently :)
The basic tool - golang.org/x/tools/go/analysis/passes/fieldalignment + additional calculations and checks on my side :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants