catppuccin / nvim

🍨 Soothing pastel theme for (Neo)vim
MIT License
5.55k stars 247 forks source link

Compilation has different after changed in 9dc7caf7fb8a32b8a644daffb6c29d801a377b99 #361

Closed ianbattersby closed 1 year ago

ianbattersby commented 1 year ago

Description

If I revert to 72540852ca then startup hash comparison and compilation works correctly, in that it produces the same hash every time and uses the cached data. However, if I rebase to 9dc7caf7fb8 then the compile hash on each startup is different (regardless of what is stored in .cache/nvim/catppuccin. I'll try and send a PR if I get time to figure this out, but wanted to log it here in case others are seeing the same and scratching their heads :inn

Neovim version

NVIM v0.9.0-dev-441+gec6ba8722
Build type: Release
LuaJIT 2.1.0-beta3

Operating system and version

macOS 13.0.1

Catppuccin version / branch / rev

cappuccino v0.2.7

Steps to reproduce

  1. git reset --hard 72540852ca00d7842ea1123635aecb9353192f0b
  2. nvim
  3. cat ~/.cache/nvim/config.json --> XYZ123
  4. nvim
  5. cat ~/.cache/nvim/config.json --> XYZ123
  6. git reset --hard 9dc7caf7fb8a32b8a644daffb6c29d801a377b99
  7. nvim
  8. cat ~/.cache/nvim/date.txt --> XYZ456
  9. nvim
  10. cat ~/.cache/nvim/date.txt --> XYZ789

Expected behavior

The same configuration (unchanged) should result in the same hash on startup and use compiled data.

Actual behavior

Produces different hash on every load using same configuration, and recompiles (10ms+ vs ~1ms).

Minimal config

-- `minimal.lua` used for reproducible configuration
-- Open with `nvim --clean -u minimal.lua`

TBA
nullchilly commented 1 year ago

@ianbattersby I cannot reproduce this, with your config the startuptime is still < 1ms

image

I know you experience this after 9dc7caf7fb8a32b8a644daffb6c29d801a377b99 but the way compile works was drastically simplified:

https://github.com/catppuccin/nvim/blob/9d461f1e248e8cc84aeb42ef733d0fe5cc8bdcef/lua/catppuccin/init.lua#L112-L133

Maybe some problem with git path modified time? Can you send the content of date.txt, too little info was provided here.

ianbattersby commented 1 year ago

Firstly, sincere apologies for raising this without more meticulous investigation. This came from wrestling a 6 year-old at the same time as trying to quickly raise the issue - but that's no excuse! 🙇


I can see now that the reason that particular commit is an issue that debug.getinfo(2) should instead be debug.getinfo(1). I have no doubts this is fixed in a later commit. However, I do still suspect the hashing might be returning inconsistent results on my MBP M1 as fixing the fs_stat comparison now avoids the compile comparison.

In fact, I've had issues previously with this. The previous hashing code I'd looked at (rightly) used pairs over the more expensive ipairs on every startup when iterating the user config table, and it would return the k/v pairs in a different order every time. I managed to workaround this by declaring my config more declaratively. It was because of this that after today's :PackerUpdate I double-checked the profile times to see it had jumped up again.

Anyway, let me do the right thing. Close this and step away. Then come back with solid findings and cause 👍

nullchilly commented 1 year ago

No worries, happy wrestling :)

nullchilly commented 1 year ago

The table order is different everytime anyway because of the hash table nature

I use xor hashing which works regardless of the table order

ianbattersby commented 1 year ago

The table order is different everytime anyway because of the hash table nature I use xor hashing which works regardless of the table order

That's super interesting, let that be the focus of my debugging. FYI: This is what I get when on HEAD of main at the moment (after the simplification which means I'm now hitting the hash comparison immediately):

LOAD 1

user conf: {
  integrations=     {
      symbols_outline= "true",
      gitsigns= "true",
      mini= "true",
      lsp_trouble= "true",
      neotest= "true",
      dap=         {
          enable_ui= "true",
          enabled= "true",
        },
      which_key= "true",
      treesitter= "true",
      navic=         {
          custom_bg= "NONE",
          enabled= "true",
        },
      notify= "true",
      noice= "true",
      mason= "true",
      neotree= "true",
      telescope= "true",
      treesitter_context= "true",
    },
  transparent_background= "false",
  term_colors= "true",
}
cached: 5411885691670184091
git path: /Users/ian/.local/share/nvim/site/pack/packer/start/catppuccin/.git/ORIG_HEAD
git: 1670184091
hashed: -19249237861670184091

LOAD 2

user conf: {
  integrations=     {
      symbols_outline= "true",
      telescope= "true",
      dap=         {
          enable_ui= "true",
          enabled= "true",
        },
      navic=         {
          custom_bg= "NONE",
          enabled= "true",
        },
      gitsigns= "true",
      treesitter_context= "true",
      neotree= "true",
      mini= "true",
      lsp_trouble= "true",
      treesitter= "true",
      neotest= "true",
      notify= "true",
      noice= "true",
      which_key= "true",
      mason= "true",
    },
  transparent_background= "false",
  term_colors= "true",
}
cached: -19249237861670184091
git path: /Users/ian/.local/share/nvim/site/pack/packer/start/catppuccin/.git/ORIG_HEAD
git: 1670184091
hashed: -20412016251670184091

HOWEVER..

If I change the hash function's pairs to ipairs (which TBF now works pretty well at ~1.659292ms) then it works:

cached: 01670184091
git path: /Users/ian/.local/share/nvim/site/pack/packer/start/catppuccin/.git/ORIG_HEAD
git: 1670184091
hashed: 01670184091

NB: Let me try this on my Intel MBPR tomorrow and see if this is an ARM/M1 issue.

nullchilly commented 1 year ago

@ianbattersby ipairs ignore all values in the table which means your hash value is always 0 😂

nullchilly commented 1 year ago

@ianbattersby Using your config:

Load 1

cached: -11000907001670176636                                                                                                                                                                                                          
user conf: {                                                                                                                                                                                                                           
  transparent_background = false,                                                                                                                                                                                                      
  term_colors = true,                                                                                                                                                                                                                  
  integrations = {                                                                                                                                                                                                                     
    mason = true,                                                                                                                                                                                                                      
    notify = true,                                                                                                                                                                                                                     
    mini = true,                                                                                                                                                                                                                       
    neotest = true,                                                                                                                                                                                                                    
    navic = {                                                                                                                                                                                                                          
      enabled = false,                                                                                                                                                                                                                 
      custom_bg = "NONE"                                                                                                                                                                                                               
    },                                                                                                                                                                                                                                 
    native_lsp = {                                                                                                                                                                                                                     
      enabled = true,                                                                                                                                                                                                                  
      underlines = {                                                                                                                                                                                                                   
        errors = { "underline" },                                                                                                                                                                                                      
        information = { "underline" },                                                                                                                                                                                                 
        warnings = { "underline" },                                                                                                                                                                                                    
        hints = { "underline" }                                                                                                                                                                                                        
      },                                                                                                                                                                                                                               
      virtual_text = {                                                                                                                                                                                                                 
        errors = { "italic" },                                                                                                                                                                                                         
        information = { "italic" },                                                                                                                                                                                                    
        warnings = { "italic" },                                                                                                                                                                                                       
        hints = { "italic" }                                                                                                                                                                                                           
      }                                                                                                                                                                                                                                
    },                                                                                                                                                                                                                                 
    dap = {                                                                                                                                                                                                                            
      enabled = true,                                                                                                                                                                                                                  
      enable_ui = true                                                                                                                                                                                                                 
    },                                                                                                                                                                                                                                 
    telescope = true,                                                                                                                                                                                                                  
    noice = true,                                                                                                                                                                                                                      
    gitsigns = true,                                                                                                                                                                                                                   
    treesitter = true,                                                                                                                                                                                                                 
    lsp_trouble = true,                                                                                                                                                                                                                
    symbols_outline = true,                                                                                                                                                                                                            
    treesitter_context = true,                                                                                                                                                                                                         
    neotree = true,                                                                                                                                                                                                                    
    which_key = true                                                                                                                                                                                                                   
  }                                                                                                                                                                                                                                    
}                                                                                                                                                                                                                                      
git path: /home/nullchilly/.local/share/nvim/site/pack/packer/start/catppuccin/.git/ORIG_HEAD                                                                                                                                          
git: 1670176636                                                                                                                                                                                                                        
hashed: -11000907001670176636

Load 2

cached: -11000907001670176636                                                                                                                                                                                                          
user conf: {                                                                                                                                                                                                                           
  term_colors = true,                                                                                                                                                                                                                  
  integrations = {                                                                                                                                                                                                                     
    navic = {                                                                                                                                                                                                                          
      custom_bg = "NONE",                                                                                                                                                                                                              
      enabled = false                                                                                                                                                                                                                  
    },                                                                                                                                                                                                                                 
    native_lsp = {                                                                                                                                                                                                                     
      underlines = {                                                                                                                                                                                                                   
        information = { "underline" },                                                                                                                                                                                                 
        warnings = { "underline" },                                                                                                                                                                                                    
        hints = { "underline" },                                                                                                                                                                                                       
        errors = { "underline" }                                                                                                                                                                                                       
      },                                                                                                                                                                                                                               
      enabled = true,                                                                                                                                                                                                                  
      virtual_text = {                                                                                                                                                                                                                 
        information = { "italic" },                                                                                                                                                                                                    
        warnings = { "italic" },                                                                                                                                                                                                       
        hints = { "italic" },                                                                                                                                                                                                          
        errors = { "italic" }                                                                                                                                                                                                          
      }                                                                                                                                                                                                                                
    },                                                                                                                                                                                                                                 
    telescope = true,                                                                                                                                                                                                                  
    notify = true,                                                                                                                                                                                                                     
    dap = {                                                                                                                                                                                                                            
      enable_ui = true,                                                                                                                                                                                                                
      enabled = true                                                                                                                                                                                                                   
    },                                                                                                                                                                                                                                 
    treesitter = true,                                                                                                                                                                                                                 
    lsp_trouble = true,                                                                                                                                                                                                                
    symbols_outline = true,                                                                                                                                                                                                            
    treesitter_context = true,                                                                                                                                                                                                         
    neotree = true,                                                                                                                                                                                                                    
    which_key = true,                                                                                                                                                                                                                  
    gitsigns = true,                                                                                                                                                                                                                   
    noice = true,                                                                                                                                                                                                                      
    mini = true,                                                                                                                                                                                                                       
    neotest = true,                                                                                                                                                                                                                    
    mason = true                                                                                                                                                                                                                       
  },                                                                                                                                                                                                                                   
  transparent_background = false                                                                                                                                                                                                       
}                                                                                                                                                                                                                                      
git path: /home/nullchilly/.local/share/nvim/site/pack/packer/start/catppuccin/.git/ORIG_HEAD                                                                                                                                          
git: 1670176636                                                                                                                                                                                                                        
hashed: -11000907001670176636

Load 3

cached: -11000907001670176636                                                                                                                                                                                                          
user conf: {                                                                                                                                                                                                                           
  integrations = {                                                                                                                                                                                                                     
    neotree = true,                                                                                                                                                                                                                    
    which_key = true,                                                                                                                                                                                                                  
    mason = true,                                                                                                                                                                                                                      
    noice = true,                                                                                                                                                                                                                      
    mini = true,                                                                                                                                                                                                                       
    neotest = true,                                                                                                                                                                                                                    
    gitsigns = true,                                                                                                                                                                                                                   
    telescope = true,                                                                                                                                                                                                                  
    notify = true,                                                                                                                                                                                                                     
    navic = {                                                                                                                                                                                                                          
      enabled = false,                                                                                                                                                                                                                 
      custom_bg = "NONE"                                                                                                                                                                                                               
    },                                                                                                                                                                                                                                 
    native_lsp = {                                                                                                                                                                                                                     
      virtual_text = {                                                                                                                                                                                                                 
        warnings = { "italic" },                                                                                                                                                                                                       
        hints = { "italic" },                                                                                                                                                                                                          
        errors = { "italic" },                                                                                                                                                                                                         
        information = { "italic" }                                                                                                                                                                                                     
      },                                                                                                                                                                                                                               
      enabled = true,                                                                                                                                                                                                                  
      underlines = {                                                                                                                                                                                                                   
        warnings = { "underline" },                                                                                                                                                                                                    
        hints = { "underline" },                                                                                                                                                                                                       
        errors = { "underline" },                                                                                                                                                                                                      
        information = { "underline" }                                                                                                                                                                                                  
      }                                                                                                                                                                                                                                
    },                                                                                                                                                                                                                                 
    dap = {                                                                                                                                                                                                                            
      enabled = true,                                                                                                                                                                                                                  
      enable_ui = true                                                                                                                                                                                                                 
    },                                                                                                                                                                                                                                 
    treesitter = true,                                                                                                                                                                                                                 
    lsp_trouble = true,                                                                                                                                                                                                                
    symbols_outline = true,                                                                                                                                                                                                            
    treesitter_context = true                                                                                                                                                                                                          
  },                                                                                                                                                                                                                                   
  transparent_background = false,                                                                                                                                                                                                      
  term_colors = true                                                                                                                                                                                                                   
}                                                                                                                                                                                                                                      
git path: /home/nullchilly/.local/share/nvim/site/pack/packer/start/catppuccin/.git/ORIG_HEAD                                                                                                                                          
git: 1670176636                                                                                                                                                                                                                        
hashed: -11000907001670176636

All hash returns -11000907001670176636

ianbattersby commented 1 year ago

@ianbattersby ipairs ignore all values in the table which means your hash value is always 0 😂

IMG_1150 (1)

LOL 😂

ghost commented 1 year ago

OK, so these are the results from my work Intel machine, and it works. So perhaps this is a LuaJIT on M1 issue? I have a new M1 Pro coming today so will be doing a fresh install on there. I'm intrigued to see what it shows! 🕵️

This is like a proper detective mystery 😂

LOAD 1 (Intel MBPR 16" i7 2018)

{
  transparent_background= "false",
  term_colors= "true",
  integrations=     {
      which_key= "true",
      treesitter_context= "true",
      gitsigns= "true",
      neotree= "true",
      mini= "true",
      neotest= "true",
      mason= "true",
      dap=         {
          enabled= "true",
          enable_ui= "true",
        },
      notify= "true",
      telescope= "true",
      treesitter= "true",
      navic=         {
          enabled= "true",
          custom_bg= "NONE",
        },
      noice= "true",
      symbols_outline= "true",
      lsp_trouble= "true",
    },
}
cached: -16247770471670231775
hash: -16247770471670231775

LOAD 2 (Intel MBPR 16" i7 2018)


{
  transparent_background= "false",
  term_colors= "true",
  integrations=     {
      telescope= "true",
      neotest= "true",
      navic=         {
          custom_bg= "NONE",
          enabled= "true",
        },
      noice= "true",
      dap=         {
          enable_ui= "true",
          enabled= "true",
        },
      which_key= "true",
      treesitter= "true",
      notify= "true",
      treesitter_context= "true",
      symbols_outline= "true",
      gitsigns= "true",
      mini= "true",
      lsp_trouble= "true",
      mason= "true",
      neotree= "true",
    },
}
cached: -16247770471670231775
hash: -16247770471670231775
ianbattersby commented 1 year ago

FWIW, I can confirm that using the local implementation (with local B = require "catppuccin.lib.native_bit") works on M1:

cached: -19488184521670233784
hash: -19488184521670233784

So could be the interim solution (should you wish to adopt one) is to detect aarch64 and use local .. but meh 🤔

nullchilly commented 1 year ago

Pretty sure luajit only recently supported aarch64 (Still not working on armv7)

https://github.com/LuaJIT/LuaJIT/issues/49 I found this issue related to arm but the thing is murmurhash used right shift so I am 90% sure it can't surpass 47 bit address...

Maybe some undefined behavior with murmurhash https://github.com/grpc/grpc/issues/13221 😓

Where could I contact you for a live conversation (Do you have discord?)

ianbattersby commented 1 year ago

Where could I contact you for a live conversation (Do you have discord?)

I'm on Discord as ianbattersby#8868 but may be unresponsive whilst in meetings 👍

nullchilly commented 1 year ago

Friend request sent 👍🏻