VectorSessionFunctions Cleanup#1886
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the vector-store session function plumbing to remove legacy alignment workarounds and to stop mutating VectorInput/VectorOutput as a side-channel for communicating updated sizes, replacing that with a new “updated desired size” value on VectorOutput.
Changes:
- Removed the alignment/pinning “hack” code path from
VectorSessionFunctionsand adjusted record sizing calculations accordingly. - Made
VectorInputareadonly structwithinit-only properties, and addedVectorOutput.UpdatedReadDesiredSizeto propagate unknown-size reads across pending completion paths. - Updated vector migration, DiskANN callbacks, and vector set tests to use the new initialization/propagation patterns.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/standalone/Garnet.test.vectorset/RespVectorSetTests.cs | Updates tests to build VectorInput via object initializers (compatible with init-only fields). |
| libs/server/VectorOutput.cs | Adds UpdatedReadDesiredSize to carry back size requirements for unknown-size reads. |
| libs/server/Storage/Functions/VectorStore/VectorSessionFunctions.cs | Removes alignment-related logic and switches unknown-size read propagation from mutating VectorInput to setting VectorOutput.UpdatedReadDesiredSize. |
| libs/server/Resp/Vector/VectorManager.Migration.cs | Removes AlignmentExpected usage for migration reads. |
| libs/server/Resp/Vector/VectorManager.cs | Removes the CompletePending overload that previously propagated mutated VectorInput. |
| libs/server/Resp/Vector/VectorManager.ContextMetadata.cs | Updates metadata write path to construct VectorInput with init-only properties. |
| libs/server/Resp/Vector/VectorManager.Callbacks.cs | Updates DiskANN callback paths to use the new VectorInput initialization and UpdatedReadDesiredSize retry mechanism. |
| libs/server/InputHeader.cs | Makes VectorInput readonly with init-only properties and removes AlignmentExpected. |
| libs/cluster/Server/Migration/MigrateOperation.cs | Removes AlignmentExpected when migrating vector set element data. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
libs/server/InputHeader.cs:632
VectorInputis now areadonly structwith auto-properties, but the explicit parameterless ctor body is empty. In C#, an explicit struct ctor must definitely assign all instance fields; with auto-properties this typically fails compilation unless you delegate to the default initializer. Either remove this ctor or delegate to: this()/this = defaultso all backing fields are initialized.
public VectorInput()
{
}
|
|
||
| var value = AlignOrPin(in srcLogRecord, ref input, out var pin); | ||
| try | ||
| var value = srcLogRecord.ValueSpan; |
There was a problem hiding this comment.
I'm not clear whether we're ensuring Key size is aligned to (now removed) ValueAlignmentBytes or if when we support ExtendedNamespace we'll be guaranteeing ExtendedNS+Key lengths are aligned to ValueAlignmentBytes; if not then we may still need to align the value start
There was a problem hiding this comment.
That's a good point - today we'd get away with alignment because DiskANN provided keys are (generally) all 4-bytes. But this would make that contractual.
I'll discuss and come back with a plan.
There was a problem hiding this comment.
We'll update DiskANN to guarantee keys are always of alignment friendly sizes.
I'll set this back on draft until we've got a version to bump to that does that.
…://github.com/microsoft/garnet into users/kmontrose/vectorSessionFunctionsCleanup
Removes two hacks from
VectorSessionFunctionsVectorInput,VectorOutputnow receives updated values andVectorInputisreadonly