{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/9344","labels_url":"https://api.github.com/repos/apache/spark/issues/9344/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/9344/comments","events_url":"https://api.github.com/repos/apache/spark/issues/9344/events","html_url":"https://github.com/apache/spark/pull/9344","id":113957759,"number":9344,"title":"[SPARK-11389][CORE] Add support for off-heap memory to MemoryManager","user":{"login":"JoshRosen","id":50748,"avatar_url":"https://avatars.githubusercontent.com/u/50748?v=3","gravatar_id":"","url":"https://api.github.com/users/JoshRosen","html_url":"https://github.com/JoshRosen","followers_url":"https://api.github.com/users/JoshRosen/followers","following_url":"https://api.github.com/users/JoshRosen/following{/other_user}","gists_url":"https://api.github.com/users/JoshRosen/gists{/gist_id}","starred_url":"https://api.github.com/users/JoshRosen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoshRosen/subscriptions","organizations_url":"https://api.github.com/users/JoshRosen/orgs","repos_url":"https://api.github.com/users/JoshRosen/repos","events_url":"https://api.github.com/users/JoshRosen/events{/privacy}","received_events_url":"https://api.github.com/users/JoshRosen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":22,"created_at":"2015-10-29T01:02:04Z","updated_at":"2015-11-03T00:10:08Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/9344","html_url":"https://github.com/apache/spark/pull/9344","diff_url":"https://github.com/apache/spark/pull/9344.diff","patch_url":"https://github.com/apache/spark/pull/9344.patch"},"body":"In order to lay the groundwork for proper off-heap memory support in SQL / Tungsten, we need to extend our MemoryManager to perform bookkeeping for off-heap memory.\r\n\r\n## User-facing changes\r\n\r\nThis PR introduces a new configuration, `spark.memory.offHeapSize` (name subject to change), which specifies the absolute amount of off-heap memory that Spark and Spark SQL can use. If Tungsten is configured to use off-heap execution memory for allocating data pages, then all data page allocations must fit within this size limit.\r\n\r\n## Internals changes\r\n\r\nThis PR contains a lot of internal refactoring of the MemoryManager. The key change at the heart of this patch is the introduction of a `MemoryPool` class (name subject to change) to manage the bookkeeping for a particular category of memory (storage, on-heap execution, and off-heap execution). These MemoryPools are not fixed-size; they can be dynamically grown and shrunk according to the MemoryManager's policies. In StaticMemoryManager, these pools have fixed sizes, proportional to the legacy `[storage|shuffle].memoryFraction`. In the new UnifiedMemoryManager, the sizes of these pools are dynamically adjusted according to its policies.\r\n\r\nThere are two subclasses of `MemoryPool`: `StorageMemoryPool` manages storage memory and `ExecutionMemoryPool` manages execution memory. The MemoryManager creates two execution pools, one for on-heap memory and one for off-heap. Instances of `ExecutionMemoryPool` manage the logic for fair sharing of their pooled memory across running tasks (in other words, the ShuffleMemoryManager-like logic has been moved out of MemoryManager and pushed into these ExecutionMemoryPool instances).\r\n\r\nI think that this design is substantially easier to understand and reason about than the previous design, where most of these responsibilities were handled by MemoryManager and its subclasses. To see this, take at look at how simple the logic in `UnifiedMemoryManager` has become: it's now very easy to see when memory is dynamically shifted between storage and execution.\r\n\r\n## TODOs\r\n\r\n- [x] Fix handful of test failures in the MemoryManagerSuites.\r\n- [x] Fix remaining TODO comments in code.\r\n- [ ] Document new configuration.\r\n- [x] Fix commented-out tests / asserts:\r\n  - [x] UnifiedMemoryManagerSuite.\r\n- [x] Write tests that exercise the new off-heap memory management policies."},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/153199533","html_url":"https://github.com/apache/spark/pull/9344#issuecomment-153199533","issue_url":"https://api.github.com/repos/apache/spark/issues/9344","id":153199533,"user":{"login":"AmplabJenkins","id":4031291,"avatar_url":"https://avatars.githubusercontent.com/u/4031291?v=3","gravatar_id":"","url":"https://api.github.com/users/AmplabJenkins","html_url":"https://github.com/AmplabJenkins","followers_url":"https://api.github.com/users/AmplabJenkins/followers","following_url":"https://api.github.com/users/AmplabJenkins/following{/other_user}","gists_url":"https://api.github.com/users/AmplabJenkins/gists{/gist_id}","starred_url":"https://api.github.com/users/AmplabJenkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AmplabJenkins/subscriptions","organizations_url":"https://api.github.com/users/AmplabJenkins/orgs","repos_url":"https://api.github.com/users/AmplabJenkins/repos","events_url":"https://api.github.com/users/AmplabJenkins/events{/privacy}","received_events_url":"https://api.github.com/users/AmplabJenkins/received_events","type":"User","site_admin":false},"created_at":"2015-11-03T00:10:08Z","updated_at":"2015-11-03T00:10:08Z","body":"Merged build finished. Test PASSed."}}