-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[PERF]: Improved server-side serialization with orjson + async #1938
Conversation
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
Picking up from #1695 (comment):
|
- Added orjson serialization improving serialization performance especially on large batches 100+ docs 2x faster (tested with locust) - Added async body serialization further improving performance (tested with locust) - Added async handling with AnyIO of the more impactful server queries further reducing concurrent request response times Future work: Add orjson serialization at client-side
…PI Server thread pool connections
- Removed commented out code - Added clarification for to_thread usage
- Configurable via `chroma_server_thread_pool_size` setting
…f the main loop TODO: Telemetry/Authz has the potentially to negatively impact things - needs async refactor
76492a2
to
ed53f6a
Compare
- Body serialization is off the main thread
- Get collection did not have enough args - Body was not awaited in modify collection - Minor cleanups to make code more readable
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.
A few questions and requests but this is looking pretty good!
@@ -789,7 +791,7 @@ def reset(self) -> bool: | |||
def get_settings(self) -> Settings: | |||
return self._settings | |||
|
|||
@property | |||
@cached_property |
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.
is there a reason for this? it adds a small amount of cognitive overhead ("what's a cached property?") for no benefit that i can see?
@@ -34,6 +34,7 @@ def __init__(self, conn_pool: Pool, stack: local): | |||
@override | |||
def __enter__(self) -> base.Cursor: | |||
if len(self._tx_stack.stack) == 0: | |||
self._conn.execute("PRAGMA case_sensitive_like = ON") |
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.
Was this meant to be included? It seems unrelated to the rest of the changes.
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.
I found this bug while testing the PR, so I added it here. I can split it up in another PR, as it is indeed unrelated.
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.
Move to PR or leave it here?
|
||
return wrapper | ||
if asyncio.iscoroutinefunction(f): | ||
|
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.
Can we fix the spacing here? It's funky to have an empty line after an if-statement
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.
Interesting, I am sure I have fixed this and ran pre-commit run
which must have resulted in this formatting again.
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.
Ty for answering my questions. If we clean up the style and import nits I'd be very happy to check this in.
Co-authored-by: Ben Eggers <[email protected]>
This is PR #1695 migrated to Chroma repo for stacking the outstanding changes.
Description of changes
Summarize the changes made by this PR.
Test plan
How are these changes tested?
pytest
for python,yarn test
for jsFor performance tests, 5 concurrent clients were querying, and 1 was adding pre-computed OpenAI (ada-02) embeddings (runtime ~1m)
Batch size: 100 (1000 also attached in a zip)
Tests with existing
main
codebase:Tests with orjson + async:
1m-100batch-5concur.zip
1m-1000batch-5concur.zip
Documentation Changes
Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs repository?
Refs