-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
geo: remove pointer usage for Geometry/Geography #53446
geo: remove pointer usage for Geometry/Geography #53446
Conversation
This should improve our heap profiles by making tree.DGeometry/Geography only implant a geo.Geometry/Geography object. Release justification: low risk, high reward changes to existing functionality Release note: None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
pkg/geo/geogfn/dwithin.go
Outdated
distance float64, | ||
useSphereOrSpheroid UseSphereOrSpheroid, | ||
exclusivity geo.FnExclusivity, | ||
) (bool, error) { | ||
if a.SRID() != b.SRID() { | ||
return false, geo.NewMismatchingSRIDsError(a, b) | ||
return false, geo.NewMismatchingSRIDsError(&a, &b) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive-by comment: this error is probably making the local vars escape back to the heap wherever it’s used. We might want to make the args values too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might address that in a follow up PR. Gotta remove the interface and use spatial object instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM. I did just confirm that this is the case though, so you'll want to make that change before running sqlcmp
. As is, this might actually be a pessimization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
-
The
sizeof
aSpatialObject
is currently 48 bytes. With some reduction in size of fields and rearrangement we can bring it down to 40 bytes.
SRID: int32
ShapeType: int32 but can be changed to int16
Type: ditto
EWKB: 24 bytes
BoundingBox: 8 bytes
If we reorder the fields as above, the first 3 fields get packed into an 8 byte word (the old ordering adds padding so no improvement). -
Can you run
sqlcmp
once with these changes just to make sure we don't have an unforeseen regression.
Reviewed 57 of 57 files at r1.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @nvanbenschoten)
Does that change the encoding, or is protobuf okay with downgrading int sizes? |
If you're always parsing this using Doing so it likely not worth it if means you'd need to go from |
good call @nvanbenschoten, after fixing the mismatching SRID pointer promotion:
tacked on as a separate commit. |
Release justification: low risk, high benefit changes to existing functionality Release note: None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that change the encoding, or is protobuf okay with downgrading int sizes?
they are all varint encoded so should be ok, and we don't care about compatibility yet. But I overlooked two things: these are enums in the proto file; because of the varint encoding, there is no int16 type for protos. Maybe a proto extension can be used to tell gogoproto to do the right thing -- like gogoproto.casttype
?
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @otan and @sumeerbhola)
bors r=sumeerbhola
I'm not sure -- I think we care once beta hits.
I think we can do that.
This escapes to the heap right now. If we can "flatten" it that may improve performance, but I'd need to be able "NULL" bounding box (maybe a bool or something). |
Build failed (retrying...): |
bors r=sumeerbhola |
bors r=sumeerbhola |
Build succeeded: |
btw, I tried this out but it made no difference to query latency |
This should improve our heap profiles by making tree.DGeometry/Geography
only implant a geo.Geometry/Geography object.
Release justification: low risk, high reward changes to existing
functionality
Release note: None