Skip to content
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: further speedup for 2.0 startup #2510

Merged
merged 11 commits into from
May 30, 2021
Merged

perf: further speedup for 2.0 startup #2510

merged 11 commits into from
May 30, 2021

Conversation

hanxiao
Copy link
Member

@hanxiao hanxiao commented May 30, 2021

2.0rc1 already achieves 2.2x speedup on startup and from jina import Document, Executor, Flow. This PR further improves the speed up by carefully inspecting

PYTHONPROFILEIMPORTTIME=x python -c 'from jina import Document, Flow, Executor'

and

PYTHONPROFILEIMPORTTIME=x jina -v

This PR achieves 1.6x speedup on import (3.6x compare to 1.x):

➜  jina git:(perf-startup) ✗ hyperfine --warmup 1 'python -c "from jina import Document, Flow, Executor"'
Benchmark #1: python -c "from jina import Document, Flow, Executor"
  Time (mean ± σ):     350.4 ms ±   6.1 ms    [User: 265.7 ms, System: 398.7 ms]
  Range (min … max):   343.2 ms … 363.2 ms    10 runs

while master is at:

➜  jina git:(master) ✗ hyperfine --warmup 1 'python -c "from jina import Document, Flow, Executor"'
Benchmark #1: python -c "from jina import Document, Flow, Executor"
  Time (mean ± σ):     566.5 ms ±   7.3 ms    [User: 449.6 ms, System: 576.2 ms]
  Range (min … max):   556.3 ms … 582.8 ms    10 runs

This PR achieves 1.7x speedup on CLI jina (3.4x compare to 1.x)

➜  jina git:(perf-startup) ✗ hyperfine --warmup 1 "jina -v"
Benchmark #1: jina -v
  Time (mean ± σ):     392.5 ms ±   3.6 ms    [User: 278.6 ms, System: 385.4 ms]
  Range (min … max):   386.3 ms … 397.0 ms    10 runs

while master is at:

➜  jina git:(master) ✗ hyperfine --warmup 1 "jina -v"
Benchmark #1: jina -v
  Time (mean ± σ):     689.2 ms ±  14.3 ms    [User: 613.7 ms, System: 903.1 ms]
  Range (min … max):   673.2 ms … 712.7 ms    10 runs

Optimizations:

@hanxiao hanxiao requested a review from a team as a code owner May 30, 2021 06:33
@hanxiao hanxiao requested review from imsergiy and deepankarm May 30, 2021 06:33
@jina-bot jina-bot added size/M area/cli This issue/PR affects the command line interface area/core This issue/PR affects the core codebase area/daemon area/entrypoint This issue/PR affects the entrypoint codebase area/helloworld This issue/PR affects the helloworld area/helper This issue/PR affects the helper functionality area/network This issue/PR affects network functionality area/testing This issue/PR affects testing component/client component/docker component/flow component/jaml component/logging component/peapod component/type labels May 30, 2021
@codecov
Copy link

codecov bot commented May 30, 2021

Codecov Report

Merging #2510 (8a3130b) into master (cc87cd5) will decrease coverage by 4.24%.
The diff coverage is 76.74%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2510      +/-   ##
==========================================
- Coverage   83.29%   79.04%   -4.25%     
==========================================
  Files         152      152              
  Lines        9444     9417      -27     
==========================================
- Hits         7866     7444     -422     
- Misses       1578     1973     +395     
Flag Coverage Δ
daemon 46.78% <56.97%> (-0.20%) ⬇️
jina 78.55% <76.92%> (-4.55%) ⬇️

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

Impacted Files Coverage Δ
jina/helloworld/chatbot/app.py 0.00% <0.00%> (ø)
jina/helloworld/fork.py 0.00% <0.00%> (ø)
jina/jaml/helper.py 82.64% <ø> (-1.36%) ⬇️
jina/optimizers/__init__.py 0.00% <0.00%> (ø)
jina/optimizers/discovery.py 0.00% <0.00%> (ø)
jina/optimizers/flow_runner.py 0.00% <0.00%> (ø)
jina/parsers/helloworld.py 77.35% <ø> (-19.01%) ⬇️
jina/parsers/helper.py 35.76% <0.00%> (-6.63%) ⬇️
jina/__init__.py 70.31% <33.33%> (+0.61%) ⬆️
jina/helper.py 61.55% <37.50%> (-16.46%) ⬇️
... and 56 more

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 cc87cd5...8a3130b. Read the comment docs.

@jina-bot jina-bot added size/L area/docs This issue/PR affects the docs and removed size/M labels May 30, 2021
@jina-bot jina-bot added area/housekeeping This issue/PR is housekeeping area/setup This issue/PR affects setting up Jina labels May 30, 2021
@hanxiao hanxiao merged commit fecdb41 into master May 30, 2021
@hanxiao hanxiao deleted the perf-startup branch May 30, 2021 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli This issue/PR affects the command line interface area/core This issue/PR affects the core codebase area/docs This issue/PR affects the docs area/entrypoint This issue/PR affects the entrypoint codebase area/helloworld This issue/PR affects the helloworld area/helper This issue/PR affects the helper functionality area/housekeeping This issue/PR is housekeeping area/network This issue/PR affects network functionality area/setup This issue/PR affects setting up Jina area/testing This issue/PR affects testing component/client component/docker component/flow component/jaml component/logging component/peapod component/type size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants