Skip to content

External memory pressure: Add a collect threshold#3957

Open
obastemur wants to merge 1 commit intochakra-core:masterfrom
obastemur:imp_ext_collect
Open

External memory pressure: Add a collect threshold#3957
obastemur wants to merge 1 commit intochakra-core:masterfrom
obastemur:imp_ext_collect

Conversation

@obastemur
Copy link
Copy Markdown
Collaborator

uncollectedExternalBytes weren't in any specific use. Put a basic threashold for external data and improve handling the requests

uncollectedExternalBytes weren't in any specific use. Put a basic threashold for external data and improve handling the requests
// do fast large allocations in a row, normal GC might not kick in. Let's force the GC
// here if we need to collect anyhow.

if (collectOnFail || this->autoHeap.uncollectedExternalBytes > KB128 || size >= KB64)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

so, if I'm reading this correctly, if ever we end up in a place where uncollectedExternalBytes is > 128KB, every call to this function will trigger a GC. Is there some way we can avoid this? E.g., is there an API to "suggest a GC", and let some centralized GC logic worry about when to schedule that?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No it won’t trigger GC. It will check whether it’s the time to do GC by checking other heuristics as is. If it really collects, well, uncollectedExternalBytes will be set to 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sorry, not following why uncollectedExternalBytes will be 0. Won't they only be 0 if GC could actually collect those?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

How do we plan to do that? (Since some of it could be really external) and the only reason for this parameter to be exist is that we could measure the external memory pressure and try GC

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sorry, not following. I have two questions:

  1. What is uncollectedExternalBytes and when does it go to 0?
  2. Are we ever subject to a condition where uncollectedExternalBytes > KB128 and calling CollectNow will trigger GCs that are unable to reduce uncollectedExternalBytes? (i.e., does this change subject us to overly-aggressive GC?)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

uncollectedExternalBytes symbolize an extra pressure number. i.e. host app allocated a piece of memory and notified us with the size.

At the moment, we do try to GC, regardless what uncollectedExternalBytes is..

So what I did is not limited to putting a 128KB threshold. Whenever requestAlloc fails, we do actually try to GC, so adding up uncollectedExternalBytes and trying again was waste of cpu tick. Cleaned up there a bit and put a threshold.

@dilijev
Copy link
Copy Markdown
Contributor

dilijev commented Jun 22, 2018

@mike-kaufman @VSadov Has this scenario been sufficiently covered by changes to memory policy or should we consider merging this as well?

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.

3 participants