Closed jedrzejboczar closed 2 weeks ago
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.
Just checked that this is still an issue.
Are you sure this is still a problem? The code that sets those options is wrapped in eventignore, so it should no longer trigger autocmds
Ah, you're right. I used the original test, which was just checking that the filetype was being set, but if I create a FileType *
autocmd and increment count per buffer, then it's not called.
However, I found another issue. I'm using perfanno.nvim which uses LuaJIT profiler (:PerfLuaProfileStart
, do the test, :PerfLuaProfileStop
, :PerfHottestLines
). It looks like most of the time is spent here:
So I added simple counter _G.dbg[bufnr] = (_G.dbg[bufnr] or 0) + 1
inside line:render
and I got an unexpectedly high count. When running =require'noice.config'
which produced 965 lines of output I got count of 466095 calls to line:render
. This is exactly the sum 1+2+3+...+965
so the complexity is O(n^2), which is explains why printing not so big outputs takes a lot of time.
Is it possible to reimplement command redirection in such a way that it does not always replace the content of the whole buffer? I don't really understand the details of how this works, so I wonder if this is due to some limitation of how message redirection works or maybe there is some simple fix for that?
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.
Did you check docs and existing issues?
Neovim version (nvim -v)
NVIM v0.9.0-dev-784+g72f0c461a
Operating system/version
Arch Linux
Describe the bug
When using
noice.redirect
to display command output in a popup, it is very slow (e.g. over 1.2 seconds to display 50 lines on my system). After some debugging I found that it is due to constantly settingfiletype
for the buffer (View:render -> nui.nvim utils.set_buf_options). This option is being set on each displayed line, which in turn runs the following lines from ftplugin.vim, which is quite slow on my system and takes ~10ms for each call. Tested with:Steps To Reproduce
While in this repro it will not be slow because there are not many plugins in runtimepath, the following steps will show how many times the
filetype
option is being set:repro.lua
:nvim -u repro.lua
, then exitnui.patch
:cd ./.repro/plugins/nui.nvim/ && git apply ../../../nui.patch
+_G.dbg = {} + ---@private ---@param bufnr number ---@param bufoptions table<string, any> function .set_buf_options(bufnr, buf_options) for name, value in pairs(buf_options) do
nvim -u repro.lua
, type:TestCmd
and hit<m-cr>
:lua = _G.dbg
and hit<m-cr>
filetype
has been set for a buffer, which for one buffer should correspond to the number of message lines:Expected Behavior
Maybe this is an issue with my setup with quite a lot of plugins, or maybe I have some plugin that makes the call to
runtime!
very slow - I am not sure, I'll try to investigate more. But still I think it should be expected thatnoice
is not settingfiletype
on every output line.Repro