GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: update for inmemory index by jupyterjazz · Pull Request #1724 · docarray/docarray

This repository was archived by the owner on Sep 9, 2026. It is now read-only.

Conversation

@jupyterjazz

@jupyterjazz jupyterjazz commented Jul 24, 2023

Copy link
Copy Markdown
Contributor

Implements Update for InMemoryExactNNIndex by creating a mapping between document IDs and their corresponding positions in the DocList.

In terms of performance, we see significant ~130x (from 0.0266s to 0.0002s) improvement in get, and a slight increase in the index time - approx. from 3.50s to 3.57s; Other operation times stayed very similar. Experiment was made on 200 000 docs, vector dim 128.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jupyterjazz
feat: update for inmemory index
e327450
Signed-off-by: jupyterjazz <[email protected]>
@github-actions github-actions Bot added size/m area/core area/testing labels Jul 24, 2023
@jupyterjazz jupyterjazz linked an issue Jul 24, 2023 that may be closed by this pull request
feat: support update for inmemory index #1725
Closed
@codecov

codecov Bot commented Jul 24, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

Patch coverage: 46.15% and project coverage change: -0.04 ⚠️

Comparison is base (410665a) 85.57% compared to head (6ace117) 85.54%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1724      +/-   ##
==========================================
- Coverage   85.57%   85.54%   -0.04%     
==========================================
  Files         133      133              
  Lines        8592     8608      +16     
==========================================
+ Hits         7353     7364      +11     
- Misses       1239     1244       +5     
Flag Coverage Δ
docarray 85.54% <46.15%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
docarray/index/backends/in_memory.py 45.45% <46.15%> (+1.93%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JoanFM

JoanFM commented Jul 24, 2023

Copy link
Copy Markdown
Member

Can you also add how much more memory is used? I am not sure this is desired.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jupyterjazz

jupyterjazz commented Jul 24, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@JoanFM

Not much change in terms of memory too.

Here's the experiment code

from docarray.index import InMemoryExactNNIndex
from docarray import BaseDoc
from docarray.typing import NdArray
import numpy as np
import tracemalloc

tracemalloc.start()

class MyDoc(BaseDoc):
    text: str
    embedding: NdArray[128]


data = [MyDoc(text=f'text {i}', embedding=np.random.rand(128)) for i in range(200000)]
doc_index = InMemoryExactNNIndex[MyDoc]()

doc_index.index(data)

docs, scores = doc_index.find(data[0], search_field='embedding')

if data[10] in doc_index:
    print('wohoo')

ids_to_get = [data[200].id, data[250].id, data[350].id]
docs = doc_index[ids_to_get]

ids_to_del = [data[200].id, data[250].id, data[350].id]
del doc_index[ids_to_del]


print(tracemalloc.get_traced_memory())

tracemalloc.stop()

Before change prints (768773718, 1032141402) showing current memory usage and max memory usage
After change - (784741328, 1048109012)
So there's ~2% increase

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jupyterjazz
Merge branch 'main' into feat-inmemory-update
6ace117
@jupyterjazz
jupyterjazz requested review from JoanFM, JohannesMessner and samsja July 24, 2023 06:59
@github-actions

github-actions Bot commented Jul 24, 2023

Copy link
Copy Markdown

📝 Docs are deployed on https://ft-feat-inmemory-update--jina-docs.netlify.app 🎉

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JoanFM
JoanFM approved these changes Jul 24, 2023
View reviewed changes
@JoanFM
JoanFM merged commit 7ad70bf into main Jul 24, 2023
@JoanFM
JoanFM deleted the feat-inmemory-update branch July 24, 2023 09:10
@jupyterjazz jupyterjazz mentioned this pull request Aug 1, 2023
Release Notes v0.37.0 #1740
Closed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@JohannesMessner JohannesMessner Awaiting requested review from JohannesMessner
@samsja samsja Awaiting requested review from samsja
1 more reviewer
@JoanFM JoanFM JoanFM approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

area/core area/testing size/m

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

feat: support update for inmemory index

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@jupyterjazz @JoanFM
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.