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

Implement a rough memory Limit for the IdTables #344

Merged
merged 1 commit into from Mar 30, 2021

Conversation

joka921
Copy link
Member

@joka921 joka921 commented Jul 31, 2020

Allows limiting the size of all IdTables that are used at the same time by using a stateful allocator.

Exceeding the limit will cause an exception.
We currently have no automatic cleanup mechanism etc. , clearing the cache
is the only possibility to get out of the OOM state under heavy load.

However, this is very useful nonetheless because it prevents most std::bad_alloc (or even worse OOM or silent)
crashes.

TODO:

  • Some operations use other data structures (e.g. hash maps) which still have to be integrated here
  • better handle large immediate results by streaming or externalizing them.

@joka921 joka921 force-pushed the f.memoryLimit branch 4 times, most recently from a8dd5d9 to 769ea70 Compare December 24, 2020 14:30
Copy link
Member

@hannahbast hannahbast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this valuable PR which saved us from hundreds of avoidable QLever crashes already. We already discussed much of it via ZOOM. Most of my comments are about better names, comments, or logging. Note that several of my comments have the property that they have consequences for the names in a lot of places, but I only made the comment once.

Let me know if you don't agree with a name change or if it seems that I misunderstood something.

src/ServerMain.cpp Outdated Show resolved Hide resolved
src/engine/IdTable.h Outdated Show resolved Hide resolved
src/engine/IdTable.h Outdated Show resolved Hide resolved
src/engine/IdTable.h Outdated Show resolved Hide resolved
src/engine/IdTable.h Outdated Show resolved Hide resolved
src/engine/IdTable.h Show resolved Hide resolved
src/util/LimitedAllocator.h Outdated Show resolved Hide resolved
src/util/Synchronized.h Outdated Show resolved Hide resolved
test/EngineTest.cpp Outdated Show resolved Hide resolved
test/IndexTest.cpp Show resolved Hide resolved
Copy link
Member

@hannahbast hannahbast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the changes, a few minor things and we are done

src/engine/IdTable.h Outdated Show resolved Hide resolved
src/util/AllocatorWithLimit.h Outdated Show resolved Hide resolved
src/util/AllocatorWithLimit.h Outdated Show resolved Hide resolved
src/util/Synchronized.h Outdated Show resolved Hide resolved
Copy link
Member

@hannahbast hannahbast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor comments

test/IndexTest.cpp Show resolved Hide resolved
src/util/AllocatorWithLimit.h Outdated Show resolved Hide resolved
src/util/Synchronized.h Outdated Show resolved Hide resolved
- It keeps track of the number of maximally allowed bytes, using a synchronized, shared state, checks if an allocation is OK.
- The actual allocation is still done by a std::allocator.
- The IdTable now also internally uses an allocator template insteead of malloc and free.
- Integrated the memory Limit into the complete project.
- Required minor adaptations for a lot of Unit tests.
Copy link
Member

@hannahbast hannahbast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are done, thanks a lot :-)

@joka921 joka921 merged commit e3609f2 into ad-freiburg:master Mar 30, 2021
@joka921 joka921 deleted the f.memoryLimit branch March 30, 2021 08:37
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.

None yet

2 participants