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

Huge delay added to switching tabs #47

Closed
Chilinot opened this issue Apr 18, 2017 · 12 comments
Closed

Huge delay added to switching tabs #47

Chilinot opened this issue Apr 18, 2017 · 12 comments

Comments

@Chilinot
Copy link

I'm using lots of tabs with many windows when I'm coding and when I added this plugin to my Vim the performance really tanked. From taking a couple milliseconds between tab switches it now takes around 0.5+ everytime I switch tab in Vim.

My guess is that this line is the cause:
autocmd BufEnter * call s:handleActivity(s:false) found here: https://github.com/wakatime/vim-wakatime/blob/master/plugin/wakatime.vim#L312

Does it really have to call this method every single time on every single buffer in the tab I switch to?
Could this be refactored to use the new async API that has been implemented in the latest Vim or NeoVim?

@alanhamlett
Copy link
Member

Just to make sure, debug mode is turned off in your ~/.wakatime.cfg file?

When debug = true the plugin does some networking in the foreground process instead of the background when switching to a new buffer.

Could this be refactored to use the new async API that has been implemented in the latest Vim or NeoVim?

Yes, that would improve performance.

@Chilinot
Copy link
Author

Yea it is disabled.

@alanhamlett
Copy link
Member

Ok, I'll update the plugin to use the new async api if available.

@alanhamlett
Copy link
Member

Instead of using async, I've buffered the heartbeats in memory. Can you update the plugin and see if performance improves when switching tabs? If it's improved enough, we can postpone using the async job_start for now.

@Chilinot
Copy link
Author

Vim seems a lot snappier now compared to before. Huge thanks :)

@alanhamlett
Copy link
Member

alanhamlett commented Apr 22, 2017

Awesome! Glad it's fixed!

@Chilinot
Copy link
Author

It would seem that Vim no longer reports any time to wakatime. I have zero time registered from the day this issue was solved up to now.

@alanhamlett
Copy link
Member

How about with the latest version?

@alanhamlett alanhamlett reopened this Apr 26, 2017
@Chilinot
Copy link
Author

Chilinot commented Apr 26, 2017

Yes, latest version solves the issue. I was looking through the log and it is filled with these errors (that are no longer happening). In case you would find it useful anyway:

"2017/04/25 16:04:34 +0000", "version": "8.0.0", "plugin": "vim/704 vim-wakatime/4.0.15", "time": 25696.623507, "level": "ERROR", "message": "{'response_code': 400, 'response_content': u'{\\n  \"errors\": {\\n    \"time\": [\\n  
   \"Number must be between 1388534400 and 99999999999.\"\\n    ]\\n  }\\n}\\n'}"}

@alanhamlett
Copy link
Member

That was the same issue as #48. I can write a script to parse your ~/.wakatime.log file and replay that coding activity if that's useful?

@Chilinot
Copy link
Author

Oh my bad. No that wont be needed but thanks anyway :)

@alanhamlett
Copy link
Member

An update, now vim-wakatime uses Vim's async job_start for improved performance with 99ffbf3.

It also buffers heartbeats to prevent spawning too many python processes.

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

No branches or pull requests

2 participants