Skip to content

refactor: use vim.loop.os_uname() for is_arm#513

Merged
AntoineGS merged 1 commit intozbirenbaum:masterfrom
samirettali:master
Jul 16, 2025
Merged

refactor: use vim.loop.os_uname() for is_arm#513
AntoineGS merged 1 commit intozbirenbaum:masterfrom
samirettali:master

Conversation

@samirettali
Copy link
Copy Markdown
Contributor

@samirettali samirettali commented Jul 12, 2025

While configuring lazy loading in my config I noticed that copilot.lua took ~60ms on average to load, a lot of which is because of io.popen() so I changed the is_arm() function to use the .machine field of vim.loop.os_uname() which was already called.

I checked the neovim source code and i think it can still be simplified but I'm not entirely sure, this is the piece of code i found:

--- @param s 'x86_64'|'arm64'
--- @return boolean
function M.is_arch(s)
  if not (s == 'x86_64' or s == 'arm64') then
    error('unknown architecture: ' .. tostring(s))
  end
  return s == architecture
end

Load time with this change is ~13ms on average, I only tested it on an M1 Macbook.

@AntoineGS
Copy link
Copy Markdown
Collaborator

nice performance improvment :P

@AntoineGS AntoineGS merged commit 14bf786 into zbirenbaum:master Jul 16, 2025
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.

2 participants