-
Notifications
You must be signed in to change notification settings - Fork 73
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
[patch] add C.free & delete ivc before core.BulkInsert C' function executing for reducing memory usage #701
Conversation
Best reviewed: commit by commit
Optimal code review plan (2 warnings, 4 commits squashed)
|
[CHATOPS:HELP] ChatOps commands.
|
internal/core/ngt/ngt.go
Outdated
cvec := (*C.float)(&vec[0]) | ||
defer C.free(unsafe.Pointer(cvec)) | ||
csize := *(*C.size_t)(unsafe.Pointer(&size)) | ||
defer C.free(unsafe.Pointer(&csize)) |
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.
[golangci] reported by reviewdog 🐶
dupSubExpr: suspicious identical LHS and RHS for ==
operator (gocritic)
internal/core/ngt/ngt.go
Outdated
csize := *(*C.size_t)(unsafe.Pointer(&size)) | ||
defer C.free(unsafe.Pointer(&csize)) | ||
cepsilon := *(*C.float)(unsafe.Pointer(&epsilon)) | ||
defer C.free(unsafe.Pointer(&cepsilon)) |
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.
[golangci] reported by reviewdog 🐶
dupSubExpr: suspicious identical LHS and RHS for ==
operator (gocritic)
internal/core/ngt/ngt.go
Outdated
cepsilon := *(*C.float)(unsafe.Pointer(&epsilon)) | ||
defer C.free(unsafe.Pointer(&cepsilon)) | ||
cradius := *(*C.float)(unsafe.Pointer(&radius)) | ||
defer C.free(unsafe.Pointer(&cradius)) |
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.
[golangci] reported by reviewdog 🐶
dupSubExpr: suspicious identical LHS and RHS for ==
operator (gocritic)
Codecov Report
@@ Coverage Diff @@
## master #701 +/- ##
==========================================
- Coverage 15.64% 15.40% -0.24%
==========================================
Files 418 418
Lines 22240 22191 -49
==========================================
- Hits 3479 3419 -60
- Misses 18523 18528 +5
- Partials 238 244 +6
Continue to review full report at Codecov.
|
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.
Overall looks good
If I end up in a test environment e2e breathing, I will remove the comment out block. |
okay |
internal/core/ngt/ngt.go
Outdated
@@ -454,8 +483,10 @@ func (n *ngt) SaveIndex() error { | |||
|
|||
// Remove removes from NGT index. | |||
func (n *ngt) Remove(id uint) error { | |||
oid := C.ObjectID(id) | |||
defer C.free(unsafe.Pointer(&oid)) |
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.
[golangci] reported by reviewdog 🐶
dupSubExpr: suspicious identical LHS and RHS for ==
operator (gocritic)
internal/core/ngt/ngt.go
Outdated
@@ -470,7 +501,9 @@ func (n *ngt) Remove(id uint) error { | |||
func (n *ngt) BulkRemove(ids ...uint) error { | |||
n.mu.Lock() | |||
for _, id := range ids { | |||
if C.ngt_remove_index(n.index, C.ObjectID(id), n.ebuf) == ErrorCode { | |||
oid := C.ObjectID(id) | |||
defer C.free(unsafe.Pointer(&oid)) |
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.
[golangci] reported by reviewdog 🐶
dupSubExpr: suspicious identical LHS and RHS for ==
operator (gocritic)
internal/core/ngt/ngt.go
Outdated
results, | ||
n.ebuf) | ||
defer C.free(unsafe.Pointer(&ret)) |
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.
[golangci] reported by reviewdog 🐶
dupSubExpr: suspicious identical LHS and RHS for ==
operator (gocritic)
internal/core/ngt/ngt.go
Outdated
@@ -302,12 +316,16 @@ func (n *ngt) Search(vec []float32, size int, epsilon, radius float32) ([]Search | |||
n.mu.RUnlock() | |||
|
|||
rsize := int(C.ngt_get_result_size(results, n.ebuf)) | |||
defer C.free(unsafe.Pointer(&rsize)) |
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.
[golangci] reported by reviewdog 🐶
dupSubExpr: suspicious identical LHS and RHS for ==
operator (gocritic)
internal/core/ngt/ngt.go
Outdated
id := C.ngt_insert_index_as_float(n.index, (*C.float)(&vec[0]), C.uint32_t(n.dimension), n.ebuf) | ||
defer C.free(unsafe.Pointer(&id)) |
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.
[golangci] reported by reviewdog 🐶
dupSubExpr: suspicious identical LHS and RHS for ==
operator (gocritic)
@@ -214,12 +214,14 @@ func (n *ngt) create() (err error) { | |||
return err | |||
} | |||
} | |||
path := C.CString(n.idxPath) | |||
defer C.free(unsafe.Pointer(path)) |
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.
[golangci] reported by reviewdog 🐶
only one cuddle assignment allowed before defer statement (wsl)
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.
LGTM
/rebase |
[REBASE] Rebase triggered by kpango for branch: bugfix/internal-agent/reduce-memory-usage |
56b5f7c
to
4e14ed7
Compare
[FORMAT] Updating license headers and formatting go codes triggered by kpango. |
/rebase |
[REBASE] Rebase triggered by kpango for branch: bugfix/internal-agent/reduce-memory-usage |
…ecuting for reducing memory usage Signed-off-by: kpango <i.can.feel.gravity@gmail.com>
76353fa
to
3a39dbd
Compare
Signed-off-by: kpango i.can.feel.gravity@gmail.com
Description:
this PR includes 3 fixes
Related Issue:
How Has This Been Tested?:
Environment:
Types of changes:
Changes to Core Features:
Checklist: