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

a big array of structure will make clangd very slow #967

Open
asd-a opened this issue Dec 28, 2021 · 3 comments
Open

a big array of structure will make clangd very slow #967

asd-a opened this issue Dec 28, 2021 · 3 comments

Comments

@asd-a
Copy link

asd-a commented Dec 28, 2021

for example:

pair<int,int>hack_clangd[1<<20];

then clangd will be slow

@asd-a asd-a changed the title a big array of structure will make clangd very slowly a big array of structure will make clangd very slow Dec 28, 2021
@HighCommander4
Copy link

I suspect this is the upstream bug llvm/llvm-project#51054

@sam-mccall
Copy link
Member

I relanded the fix from that bug but it still feels sluggish.

#include <utility>
std::pair<int, int> hack_clangd[1<<20];
time bin/clang -fsyntax-only ~/test.cc
________________________________________________________
Executed in    1.97 secs   fish           external 
   usr time  1778.03 millis  820.00 micros  1777.21 millis 
   sys time  192.02 millis  324.00 micros  191.70 millis 

@fishBone000
Copy link

fishBone000 commented May 4, 2024

This problem still exists, even on 18.1.3.

#include <bits/stdc++.h>

struct s_t {

};

// Large memory consumption: 6+GB
// std::pair<int, int> tree[int(10e7)];
// s_t tree[int(10e7)];

// No effect
// int tree[int(10e7)];

int main() {
}

Uncomment corresponding lines to see the effect.

For std::pair<int, int>, each time I edit the src code in my IDE (nvim), e.g. delete a character, add a character, or delete lines, a memory consumption spike can be observed (6+GB).
The spike gets much smaller if the array is smaller, e.g. ~1GB for 10e6, and much smaller if less than 10e5.

For s_t, it is kind of strange:
The memory consumption goes up by 6GB, and never goes down, unlike std::pair<int, int> which looks like a spike.

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

No branches or pull requests

4 participants