Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't store the pois of OTP modules in ets at startup #881

Merged
merged 1 commit into from
Jan 31, 2021

Conversation

gomoripeti
Copy link
Contributor

They take up a lot of memory, duplicated for each project, and most of them not
used. They will be reloaded and inserted when needed by calling
els_utils:lookup_document/1 so there is no information loss.

OTP modules are outside of the project root, so for example if one jumps to the definition of an OTP function and opens an OTP module it will start a new ELS node. Hence the POIs of OTP modules in a non-OTP project are mostly unused. (One exception I noticed when showing hover-docs, it fetches the function heads and so it currently loads and stores the module again)
This is just a quick fix - On the long term there could be a different, limited set of info stored for OTP modules, only those which are for referencing but nothing that is about the implementation.

I observed the below memory reduction with this change when opening a file in erlang_ls (using OTP 21.3.8.2)

1> ets:info(els_dt_document, size).
977
2> ets:info(els_dt_document, memory).
42_895_927 words
3> erlang:memory(ets).
346_978_168 bytes
4> erlang:memory(total).
425_065_032 bytes
  • memory with no OTP POIs
1> ets:info(els_dt_document, size).
128
2> ets:info(els_dt_document, memory).
1_037_279 words
3> erlang:memory(ets).
12_103_352 bytes
4> erlang:memory(total).
53_198_120 bytes

They take up a lot of memory, duplicated for each project, and most of then not
used. They will be reloaded and inserted when needed by calling
`els_utils:lookup_document/1` so there is no information loss.
@robertoaloi robertoaloi merged commit dad4f1e into erlang-ls:main Jan 31, 2021
@gomoripeti gomoripeti deleted the no_initial_otp_pois branch March 1, 2021 20:17
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