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

Add OOM enabler in operator tree #1379

Merged
merged 53 commits into from
Oct 25, 2023
Merged

Add OOM enabler in operator tree #1379

merged 53 commits into from
Oct 25, 2023

Conversation

antoniofilipovic
Copy link
Collaborator

@antoniofilipovic antoniofilipovic commented Oct 18, 2023

This diff will introduce the OOM exception enabler to the operator tree.

The reason why OOM enabler was not introduced inside disk storage directly is that exceptions can blow during storing inside rocksdb and the transaction never commits, nor is the exception returned. We need to be careful when to add an OOM Exception enabler, and when to use a blocker in disk storage. Currently, the OOM enabler in the operator tree enables exceptions for all operations.

OOM enabler needs to be introduced also in mg_procedure_impl and that is what new diff will do. Currently, if a user specifies multiple threads that will do allocations from the procedure, due to the thread local variable for the OOM enabler to check if the error can be thrown, call in procedure will pass (although it shouldn't if memory is too big) and error will be not thrown.

  • Fix
  • Write e2e tests

[master < Task] PR

  • Check, and update documentation if necessary
  • Provide the full content or a guide for the final git message

To keep docs changelog up to date, one more thing to do:

  • Write a release note here, including added/changed clauses
  • Tag someone from docs team in the comments

antoniofilipovic and others added 30 commits September 11, 2023 16:58
This commit introduces memory tracker with jemalloc extent hooks which fully works in case when jemalloc config is following:
MALLOC_CONF="retain:false,percpu_arena:percpu,oversize_threshold:1000000000000,muzzy_decay_ms:0,dirty_decay_ms:0" \
./configure \
    --disable-cxx \
    $COMMON_CONFIGURE_FLAGS \
    --with-malloc-conf="retain:false,percpu_arena:percpu,oversize_threshold:1000000000000,muzzy_decay_ms:0,dirty_decay_ms:0"

This config will for jemalloc not to use lazy purge or MADV_FREE(muzzy_decay_ms=0 and dirty_decay_ms=0), it will force jemalloc not to use
custom arena for huge allocations (oversize_threshold) and it will force jemalloc not extend virtual memory indefinitely (retain=false)
and therefore call alloc hook when allocation actually takes place.

Only problem is if we do huge allocations which are not mapped on alloc directly, in that case jemalloc uses cache and we can overcounter
allocation size.
@antoniofilipovic antoniofilipovic added the Docs - changelog only Docs - changelog only label Oct 23, 2023
Copy link
Contributor

@as51340 as51340 left a comment

Choose a reason for hiding this comment

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

Several things:

  • why do you need exception enabler in the operator tree?
  • I think it is not good to disable OOM for disk storage
  • not sure you need exception enabler in all methods (why would create index need it)?

@antoniofilipovic
Copy link
Collaborator Author

Several things:

  • why do you need exception enabler in the operator tree?
  • I think it is not good to disable OOM for disk storage
  • not sure you need exception enabler in all methods (why would create index need it)?

-> The operator tree goes through all storage methods, so it is common place for all allocations to happen. It seems less error-prone than adding it to each method.
-> OOM for disk storage is not disabled but just moved to operator tree.
-> Index is also allocating memory, I am not sure why not add exception handler to that also as it might crash database.

src/storage/v2/storage.cpp Outdated Show resolved Hide resolved
@antoniofilipovic antoniofilipovic changed the title Add OOM enabler Add OOM enabler in operator tree Oct 24, 2023
@antoniofilipovic antoniofilipovic removed the Ready for review PR is ready for review label Oct 24, 2023
@antoniofilipovic antoniofilipovic merged commit 2426d79 into master Oct 25, 2023
6 checks passed
@antoniofilipovic antoniofilipovic deleted the add-oom-enabler branch October 25, 2023 10:16
@antoniofilipovic
Copy link
Collaborator Author

RN: @vpavicic : Out of memory exception is now thrown whenever memgraph is out of memory.

as51340 pushed a commit that referenced this pull request Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs - changelog only Docs - changelog only memory
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Memory usage not aligned with --memory-limit
3 participants