最萌小汐

Results 339 comments of 最萌小汐

There are 4 levels of diagnostics: `error`, `warning`, `information`, `hint`. The diagnostics of `hint` level are not displayed in the problems window.

> I see. Why is the Lua language server outputting hints? Can we change it so that it doesn't use any hints at all? Use [diagnostics.groupSeverity](https://github.com/sumneko/lua-language-server/wiki/Settings#diagnosticsgroupseverity) or [diagnostics.severity](https://github.com/sumneko/lua-language-server/wiki/Settings#diagnosticsseverity)

Use: ```lua ---@class flag96 ---@overload fun(p1?: integer, p2?: integer, p3?: integer):flag96 ```

https://github.com/microsoft/vscode/issues/158649

目前确实是一个文件1M左右内存,以后有机会看看怎么优化。

应该和文件大小成正比,大部分情况下1个文件平均消耗1M内存。消耗的内存主要是解析文件以及对解析结果进行预处理和缓存导致的。

经过一些简单测试,大部分内存占用都来自解析文件生成的语法树,因为语法树格式是lua表形式,因此内存占用确实会很高,例如lua代码 `{}` 会被解析成 `{ type = 'table', start = 0, finish = 2 }` 。前者只有2个字节大小,但生成的lua表有200多字节,放大了100倍。可能需要重新设计语法树结构才能解决这个问题。

> 经过一些简单测试,大部分内存占用都来自解析文件生成的语法树,因为语法树格式是lua表形式,因此内存占用确实会很高,例如lua代码 `{}` 会被解析成 `{ type = 'table', start = 0, finish = 2 }` 。前者只有2个字节大小,但生成的lua表有200多字节内存占用,放大了100倍。可能需要重新设计语法树结构才能解决这个问题。

> 这样治标不治本,可以试着让一部分不重要的语法树不在内存中,实际上5k文件里面常用的就几十几百,大部分解析的结果只需要作为api提示。所以可以进一步设定长期工作目录,其他的不重要的目录,不缓存语法树,甚至文件内容都不缓存。 我目前会将语义和语法树部分节点互相绑定,因此只有当一个文件完全没有使用任何全局变量以及 `---@class` 或 `---@type` 时我才能安全释放这个文件的内存。 不过想了想,这年头内存又不值钱,5000个文件的巨大工作目录总是要付出一些代价的,请自己尝试忽略掉无用的文件或是加内存吧。