apache / apache/cassandra-gocql-driver

Suboptimal struct alignment

Open
#1,080 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.7k
Forks
658
PR merge metrics
No merged PRs in 30d

Description

### What version of Gocql are you using?
2e9f2912

I suggest fixing the struct alignment to reduce memory footprint. I think that it's important to get Conn, Session, Query fixed.

```
github.com/gocql/gocql: cluster.go:30:6: struct ClusterConfig could have size 296 (currently 320)
github.com/gocql/gocql: conn.go:125:6: struct Conn could have size 208 (currently 224)
github.com/gocql/gocql: errors.go:102:6: struct RequestErrReadFailure could have size 120 (currently 128)
github.com/gocql/gocql: errors.go:83:6: struct RequestErrReadTimeout could have size 112 (currently 120)
github.com/gocql/gocql: frame.go:1360:6: struct queryParams could have size 72 (currently 80)
github.com/gocql/gocql: frame.go:1530:6: struct writeBatchFrame could have size 40 (currently 48)
github.com/gocql/gocql: frame.go:329:6: struct frameHeader could have size 56 (currently 64)
github.com/gocql/gocql: host_source.go:99:6: struct HostInfo could have size 344 (currently 352)
github.com/gocql/gocql: policies.go:227:6: struct selectedHost could have size 344 (currently 352)
github.com/gocql/gocql: session.go:1337:6: struct nextIter could have size 296 (currently 304)
github.com/gocql/gocql: session.go:1357:6: struct Batch could have size 120 (currently 136)
github.com/gocql/gocql: session.go:33:6: struct Session could have size 696 (currently 720)
github.com/gocql/gocql: session.go:655:6: struct Query could have size 240 (currently 264)
```

Contributor guide

Open the contributing guide

Research direction

Inspect the struct declarations at the listed locations in cluster.go, conn.go, errors.go, frame.go, host_source.go, policies.go, and session.go, starting with the compiler size diagnostics in the issue. Rework the declarations only as needed to reach the suggested smaller sizes, then run the existing test suite and confirm the reported struct sizes have improved without breaking behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
databases
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.