[vim/vim] win_execute() becomes too slow on the latest vim8.2 (Issue #9504)

38 views
Skip to first unread message

rickhowe

unread,
Jan 10, 2022, 11:28:29 PM1/10/22
to vim/vim, Subscribed

Steps to reproduce

When comparing the time as blow:

let n = 1000

let t = reltime()
for z in range(n)
	let a = 1
endfor
echo reltimestr(reltime(t))

let wid = win_getid()
let t = reltime()
for z in range(n)
	call win_execute(wid, 'let a = 1')
endfor
echo reltimestr(reltime(t))

on vim8.2.3582:

0.009245
0.021792

on vim8.2.4058:

0.008434
0.991177

Looks like the latest vim becomes more than 50 times slower than before.

Expected behaviour

I am not sure which patch has caused this, but hope to resolve this issue.

Version of Vim

8.2.4058

Environment

Windows 10

Logs and stack traces

No response


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9504@github.com>

lacygoill

unread,
Jan 10, 2022, 11:57:31 PM1/10/22
to vim/vim, Subscribed

Here is the list of patches after 8.2.3582 containing the keyword win_execute in their commit messages:

  • 8.2.3593 directory is wrong after executing "lcd" with win_execute()
  • 8.2.3739 in wrong directory when using win_execute() with 'acd' set
  • 8.2.3862 crash on exit with EXITFREE and using win_execute()
  • 8.2.4018 ml_get error when win_execute redraws with Visual selection
  • 8.2.4026 ml_get error with specific win_execute() command

I am not sure which patch has caused this, but hope to resolve this issue.

FWIW, I can't reproduce the issue. I get these timings:

0.004148
0.012403

The ratio is somewhere around 3, which looks similar to what you observe on 8.2.3582.

Maybe the issue is specific to Windows. In any case, it would help if you could:

  • bisect the regression
  • profile the C code

For the last bullet point, on linux, you could try to run these shell commands from the Vim root directory:

make clean
make distclean
sed -i '/#PROFILE_CFLAGS = -pg -g -DWE_ARE_PROFILING/s/^#// ; /#PROFILE_LIBS = -pg -no-pie/s/^#//' src/Makefile
make
./src/vim -Nu NONE -S /tmp/issue.vim
gprof ./src/vim ./gmon.out

/tmp/issue.vim should contain the Vim script code necessary to reproduce the issue.

This requires the gprof(1) tool, which on Ubuntu is provided by the binutils package:

$ sudo apt install binutils

Unfortunately, I don't know enough about Windows in general to tell how all of this can be adapted to a Windows 10 system.


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9504/1009599454@github.com>

rickhowe

unread,
Jan 11, 2022, 3:50:37 AM1/11/22
to vim/vim, Subscribed

I found that 8.2.3920, which is a win_execute() relevant patch, has caused this issue.

on vim8.2.3919:

0.007691
0.019335

on vim8.2.3920:

0.009243
1.000277


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9504/1009722894@github.com>

lacygoill

unread,
Jan 11, 2022, 4:04:36 AM1/11/22
to vim/vim, Subscribed

I found that 8.2.3920, which is a win_execute() relevant patch, has caused this issue.

In case it helps finding a fix, here is an explanation about the purpose of the patch.


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9504/1009734946@github.com>

Bram Moolenaar

unread,
Jan 11, 2022, 7:30:12 AM1/11/22
to vim/vim, Subscribed

I suppose you are on a system where getcwd() or chdir() is slow.
I'll see if I can avoid them when no local directories or 'acd' is involved.


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9504/1009918740@github.com>

Bram Moolenaar

unread,
Jan 11, 2022, 7:38:12 AM1/11/22
to vim/vim, Subscribed

Closed #9504 via d6f27c6.


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/9504/issue_event/5873028255@github.com>

Dominique Pellé

unread,
Jan 11, 2022, 7:44:07 AM1/11/22
to vim/vim, Subscribed

@rickhowe wrote:

on vim8.2.3920:

0.009243
1.000277

Is it a coincidence that it takes almost exactly 1 second
or is it an indication of a timeout somewhere?

What timing to you get if you make let n = 2000 instead
of let n = 1000 in your script?


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9504/1009928726@github.com>

rickhowe

unread,
Jan 11, 2022, 7:55:53 AM1/11/22
to vim/vim, Subscribed

Thank you. I found the issue resolved now.

on vim8.2.4060:

0.008480
0.020767


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9504/1009937460@github.com>

rickhowe

unread,
Jan 11, 2022, 8:01:03 AM1/11/22
to vim/vim, Subscribed

@rickhowe wrote:

on vim8.2.3920:
0.009243
1.000277

Is it a coincidence that it takes almost exactly 1 second or is it an indication of a timeout somewhere?

What timing to you get if you make let n = 2000 instead of let n = 1000 in your script?

I tried on my system;
when n=2000

0.019571
2.037047

when n=5000

0.046071
5.015006


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9504/1009941408@github.com>

Reply all
Reply to author
Forward
0 new messages