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

[READY] Remove healthy check #2517

Merged
merged 1 commit into from Jan 29, 2017
Merged

Conversation

micbou
Copy link
Collaborator

@micbou micbou commented Jan 28, 2017

This PR removes the code that, if the server is not yet healthy, tries in a separate thread to send the same request at different intervals until it gets a response or reaches 5 failed attempts.

Main issue with that code is that it blocks Vim if a synchronous request (semantic_completion_available, run_completer_command, etc.) is sent while the server is not up. See issue #2071.

Other issues are that it's hard to understand how this code behaves (it combines threads and retries), it becomes useless once the server is healthy (because SERVER_HEALTHY is cached and never reset), it depends on arbitrary parameters (why 5 retries with a delay of 0.5s multiplied by 1.5 at each attempt?), and it has a package dependency retries.

Now that we catch all server exceptions (PR #2453) and define a very short connection timeout (PR #2514), we can just drop this code.

This change gives a huge improvement in startup time on Windows (don't worry, more improvements are coming for all platforms). The reason is that requests (probably urllib3) tries for ~1s to check if the server is healthy on Windows while it's almost instantaneous on other platforms.

Platform First run (ms) Subsequent runs (ms)
Before After Before After
Ubuntu 16.04 64-bit 228 248 176 151
macOS 10.12 433 417 263 263
Windows 10 64-bit 1861 844 814 292

These results were obtained by running the prof.py script from this branch. The difference between first run and subsequent runs is Python bytecode generation (*.pyc files).

Fixes #2071.


This change is Reviewable

@codecov-io
Copy link

codecov-io commented Jan 28, 2017

Current coverage is 85.39% (diff: 100%)

Merging #2517 into master will decrease coverage by 0.10%

@@             master      #2517   diff @@
==========================================
  Files            19         19          
  Lines          1966       1938    -28   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
- Hits           1681       1655    -26   
+ Misses          285        283     -2   
  Partials          0          0          

Powered by Codecov. Last update 410a4b6...10aba99

@Valloric
Copy link
Member

:lgtm: Fantastic! So much complexity gone!

@micbou You're like my favorite person now. :D


Review status: 0 of 2 files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@vheon
Copy link
Contributor

vheon commented Jan 28, 2017

:lgtm: @homu r=Valloric


Reviewed 1 of 2 files at r1, 1 of 1 files at r2.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@homu
Copy link
Contributor

homu commented Jan 28, 2017

📌 Commit 10aba99 has been approved by Valloric

@homu
Copy link
Contributor

homu commented Jan 28, 2017

⌛ Testing commit 10aba99 with merge f686734...

homu added a commit that referenced this pull request Jan 28, 2017
[READY] Remove healthy check

This PR removes the code that, if the server is not yet healthy, tries in a separate thread to send the same request at different intervals until it gets a response or reaches 5 failed attempts.

Main issue with that code is that it blocks Vim if a synchronous request (`semantic_completion_available`, `run_completer_command`, etc.)  is sent while the server is not up. See issue #2071.

Other issues are that it's hard to understand how this code behaves (it combines threads and retries), it becomes useless once the server is healthy (because `SERVER_HEALTHY` is cached and never reset), it depends on arbitrary parameters (why 5 retries with a delay of 0.5s multiplied by 1.5 at each attempt?), and it has a package dependency `retries`.

Now that we catch all server exceptions (PR #2453) and define a very short connection timeout (PR #2514), we can just drop this code.

This change gives a huge improvement in startup time on Windows (don't worry, more improvements are coming for all platforms). The reason is that `requests` (probably `urllib3`) tries for ~1s to check if the server is healthy on Windows while it's almost instantaneous on other platforms.
<table>
  <tr>
    <th rowspan="2">Platform</th>
    <th colspan="2">First run (ms)</th>
    <th colspan="2">Subsequent runs (ms)</th>
  </tr>
  <tr>
    <td>Before</td>
    <td>After</td>
    <td>Before</td>
    <td>After</td>
  </tr>
  <tr>
    <td>Ubuntu 16.04 64-bit</td>
    <td>228</td>
    <td>248</td>
    <td>176</td>
    <td>151</td>
  </tr>
  <tr>
    <td>macOS 10.12</td>
    <td>433</td>
    <td>417</td>
    <td>263</td>
    <td>263</td>
  </tr>
  <tr>
    <td>Windows 10 64-bit</td>
    <td>1861</td>
    <td>844</td>
    <td>814</td>
    <td>292</td>
  </tr>
</table>

These results were obtained by running the `prof.py` script from [this branch](https://github.com/micbou/YouCompleteMe/tree/profiling-startup). The difference between first run and subsequent runs is Python bytecode generation (`*.pyc` files).

Fixes #2071.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2517)
<!-- Reviewable:end -->
@homu
Copy link
Contributor

homu commented Jan 29, 2017

☀️ Test successful - status

@homu homu merged commit 10aba99 into ycm-core:master Jan 29, 2017
@micbou micbou deleted the remove-healthy-check branch January 29, 2017 00:35
homu added a commit that referenced this pull request Feb 19, 2017
[RFC] Send requests again when server becomes ready

Since PR #2517, the `BufferVisit` and `FileReadyToParse` requests are ignored until the server is ready. We need to send them again when it becomes ready so that identifiers and snippets for the current buffer are properly parsed. This is done in the `s:OnFileReadyToParse` function since this function is regularly called. We also try to set the omnifunc since it depends on a response from the server and is only set when entering a buffer or changing its filetype. This replaces the code that consisted of setting the omnifunc when entering insert mode for the first time.

A cleaner solution would be to do that asynchronously but we can't with our Vim version requirement.

Fixes #2541.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2547)
<!-- Reviewable:end -->
@micbou micbou mentioned this pull request Mar 27, 2017
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants