chakra-core / chakra-core/ChakraCore

AllocationPolicy should be made more straightforward to use

Open
#5,114 1 comment 0 reactions 0 assignees View on GitHub
Suggestion
Dominant language
JavaScript
Stars
9.3k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

From the issues found in https://github.com/Microsoft/ChakraCore/pull/5099 `AllocationPolicy` seems fairly confusing to use. Especially when external allocations are involved.

- it is not very clear what `AllocationPolicy` applies to. - Is it process-wide, per script host or per-thread?
This need to be made more apparent.
- it is not easy to obtain `AllocationPolicy`. There are several patterns in use and applicable in deifferent situations. Perhaps there is a reason for the complexity here, but maybe there is a simpler way?
- ownership of `AllocationPolicy` is not very clear. We often retrieve it via recycler, but recycler itself does not own a policy. Should it be recycler, thread context, script context or should the policy be process-wide?
- it is especially confusing when we handle allocation of external memory via recycler, but it does not track that memory, so freeing still needs to be handled externally.
- also when external memory is involved, we also need to manipulate memory pressure. And it could be confusing. Perhaps adding/freeing external memory for the purpose of allocation policy should also handle adding/removing memory/GC pressure automatically.
- there are scenarios when we transfer the ownership of memory from one object to another and we handle that by temporarily "freeing" the allocation limit and then adding it back. That is fragile and redundant. We need helpers to "move" the allocation charge. (could be a noop in release)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.