Nvim_buf_set_lines consumes 100% cpu

I have a problem and I’m wondering if it’s a bug, so first want to ask here before I report it.

I’m using coc.nvim and see an issue on a large javascript/typescript project. When I do coc-references, the results show fast, but when I move to the next item in the list, I get 100% CPU usage. So I profiled this and got:

FUNCTION  coc#float#create_buf()
    Defined: ~/.local/share/nvim/plugged/coc.nvim/autoload/coc/float.vim:1221
Called 3 times
Total time:  10.469652
 Self time:  10.469652

count  total (s)   self (s)
    3              0.000012   if a:bufnr > 0 && bufloaded(a:bufnr)
    3              0.000004     let bufnr = a:bufnr
                              else
                                if s:is_vim
                                  noa let bufnr = bufadd('')
                                  noa call bufload(bufnr)
                                  call setbufvar(bufnr, '&buflisted', 0)
                                else
                                  noa let bufnr = nvim_create_buf(v:false, v:true)
                                endif
                                let bufhidden = get(a:, 2, 'wipe')
                                call setbufvar(bufnr, '&buftype', 'nofile')
                                call setbufvar(bufnr, '&bufhidden', bufhidden)
                                call setbufvar(bufnr, '&swapfile', 0)
                                call setbufvar(bufnr, '&undolevels', -1)
                                " neovim's bug
                                call setbufvar(bufnr, '&modifiable', 1)
    3              0.000002   endif
    3              0.000009   let lines = get(a:, 1, v:null)
    3              0.000006   if type(lines) != 7
    3              0.000012     if has('nvim')
    3             10.469471       call nvim_buf_set_lines(bufnr, 0, -1, v:false, lines)
                                else
                                  call deletebufline(bufnr, 1, '$')
                                  call setbufline(bufnr, 1, lines)
    3              0.000001     endif
    3              0.000001   endif
    3              0.000003   return bufnr

So it looks like a huge amount of time is spent on nvim_buf_set_lines.

Does anyone else have this problem? Should I report it as a bug? How can I investigate further?

Some information about versions:

vim version: NVIM v0.5.0-dev+1135-g300e71de9
node version: v15.5.0
coc.nvim version: 0.0.80-98a0c6db19
coc.nvim directory: /home/thomas/.local/share/nvim/plugged/coc.nvim
term: xterm-256color
platform: linux