8000 feat(daemon): async interaction with children by deepankarm · Pull Request #2948 · jina-ai/serve · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(daemon): async interaction with children #2948

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

Merged
merged 14 commits into from
Jul 15, 2021
Merged

Conversation

deepankarm
Copy link
Contributor

Fixes #2746

@deepankarm deepankarm requested a review from a team as a code owner July 14, 2021 10:53
@jina-bot jina-bot added size/M area/core This issue/PR affects the core codebase area/daemon area/network This issue/PR affects network functionality component/peapod labels Jul 14, 2021
@codecov
Copy link
codecov bot commented Jul 14, 2021

Codecov Report

Merging #2948 (c9694b2) into master (bab6323) will decrease coverage by 0.13%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2948      +/-   ##
==========================================
- Coverage   89.10%   88.96%   -0.14%     
==========================================
  Files         138      138              
  Lines        9607     9607              
==========================================
- Hits         8560     8547      -13     
- Misses       1047     1060      +13     
Flag Coverage Δ
daemon 43.16% <0.00%> (ø)
jina 88.95% <100.00%> (-0.14%) ⬇️

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

Impacted Files Coverage Δ
jina/peapods/zmq/__init__.py 88.75% <ø> (ø)
jina/peapods/runtimes/jinad/client.py 90.53% <100.00%> (ø)
jina/clients/base/grpc.py 63.82% <0.00%> (-6.39%) ⬇️
jina/peapods/peas/__init__.py 92.26% <0.00%> (-3.87%) ⬇️
jina/peapods/pods/compound.py 90.14% <0.00%> (-1.41%) ⬇️
jina/peapods/runtimes/gateway/prefetch.py 93.15% <0.00%> (-1.37%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bab6323...c9694b2. Read the comment docs.

@deepankarm deepankarm requested a review from jacobowitz July 14, 2021 10:57
@jina-bot jina-bot added size/L area/testing This issue/PR affects testing and removed size/M labels Jul 14, 2021
@jina-bot jina-bot added the area/housekeeping This issue/PR is housekeeping label Jul 14, 2021
@nan-wang
Copy link
Member

@github-actions
Copy link
github-actions bot commented Jul 15, 2021

Latency summary

Current PR yields:

  • 😶 index QPS at 1566, delta to last 1 avg.: +0%
  • 😶 query QPS at 18, delta to last 1 avg.: -3%
  • 😶 dam extend QPS at 58153, delta to last 1 avg.: -4%
  • 😶 avg flow time within 1.7756 seconds, delta to last 1 avg.: +0%
  • 🐎🐎 import jina within 0.3608 seconds, delta to last 1 avg.: +8%

Breakdown

Version Index QPS Query QPS DAM Extend QPS Avg Flow Time (s) Import Time (s)
current 1566 18 58153 1.7756 0.3608
2.0.7 1560 18 60939 1.7598 0.3335

Backed by latency-tracking. Further commits will update this comment.

@deepankarm
Copy link
Contributor Author

The dump_and_reload test failed. https://github.com/jina-ai/jina/pull/2948/checks?check_run_id=3069763856#step:5:1115

Fixed now

Copy link
Contributor
@jacobowitz jacobowitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only some minor comments/questions.

Otherwise looks good :)

_update_default_args()
pathlib.Path(__root_workspace__).mkdir(parents=True, exist_ok=True)
if not jinad_args.no_fluentd:
Thread(target=_start_fluentd, daemon=True).start()
_start_consumer()
_start_uvicorn(app=_get_app(mode=jinad_args.mode))


def teardown():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we stop the consumer thread and uvicorn here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consumer thread is a daemon thread, so no need to close it manually.
Uvicorn handles its own shutdown logic in serve itself for different signal handlers.

async with aiohttp.request(
method='PUT', url=f'{uri}/{self._kind}', params=params
) as response:
response_json = await response.json()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if there is some issue with the json deserialization? Same goes for other cases. Does this work then here or throw an exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That gets caught in containers.py exception handler and raised to the invoker. But our exception sending logic to the user is poor now. It needs quite some work and cannot be done in this PR



@pytest.yield_fixture(scope="session")
def event_loop(request):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cant we use the default loop fixture? If so (I think the scope is different), the comment below seems to be wrong as the scope here session and not 'for each test'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. The comment is wrong. It needs to be a session, else we need to handle event loop (start and closure) logic in aiohttp client session, which is not required in the actual code (as uvicorn takes care of it), and needed only in tests.

I had to spent >2hrs just to fix this :)

@deepankarm deepankarm force-pushed the feat-aiohttp-jinad branch from 839b7af to 953c320 Compare July 15, 2021 08:03
@deepankarm deepankarm force-pushed the feat-aiohttp-jinad branch from 953c320 to abc5d88 Compare July 15, 2021 08:08
jacobowitz
jacobowitz previously approved these changes Jul 15, 2021
Copy link
Contributor
@jacobowitz jacobowitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍

@deepankarm deepankarm merged commit 5082c49 into master Jul 15, 2021
@deepankarm deepankarm deleted the feat-aiohttp-jinad branch July 15, 2021 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core This issue/PR affects the core codebase area/housekeeping This issue/PR is housekeeping area/network This issue/PR affects network functionality area/testing This issue/PR affects testing component/peapod size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move from requests to aiohttp in JinaD
4 participants
0