Return-Path: X-Original-To: apmail-flink-issues-archive@minotaur.apache.org Delivered-To: apmail-flink-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CD22B10D38 for ; Tue, 8 Sep 2015 19:25:55 +0000 (UTC) Received: (qmail 30021 invoked by uid 500); 8 Sep 2015 19:25:46 -0000 Delivered-To: apmail-flink-issues-archive@flink.apache.org Received: (qmail 29874 invoked by uid 500); 8 Sep 2015 19:25:46 -0000 Mailing-List: contact issues-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flink.apache.org Delivered-To: mailing list issues@flink.apache.org Received: (qmail 29651 invoked by uid 99); 8 Sep 2015 19:25:46 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Sep 2015 19:25:46 +0000 Date: Tue, 8 Sep 2015 19:25:46 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@flink.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (FLINK-1320) Add an off-heap variant of the managed memory MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/FLINK-1320?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14735456#comment-14735456 ] ASF GitHub Bot commented on FLINK-1320: --------------------------------------- Github user StephanEwen commented on the pull request: https://github.com/apache/flink/pull/1093#issuecomment-138676203 Thanks! Let us keep up the good work :-) @hsaputra I addressed your comment in the commit. Actually made the field volatile, we should be safe that way. I filed two JIRA issues for followup (integration with YARN and startup scripts). > Add an off-heap variant of the managed memory > --------------------------------------------- > > Key: FLINK-1320 > URL: https://issues.apache.org/jira/browse/FLINK-1320 > Project: Flink > Issue Type: Improvement > Components: Local Runtime > Reporter: Stephan Ewen > Assignee: Stephan Ewen > Priority: Minor > Fix For: 0.10 > > > For (nearly) all memory that Flink accumulates (in the form of sort buffers, hash tables, caching), we use a special way of representing data serialized across a set of memory pages. The big work lies in the way the algorithms are implemented to operate on pages, rather than on objects. > The core class for the memory is the {{MemorySegment}}, which has all methods to set and get primitives values efficiently. It is a somewhat simpler (and faster) variant of a HeapByteBuffer. > As such, it should be straightforward to create a version where the memory segment is not backed by a heap byte[], but by memory allocated outside the JVM, in a similar way as the NIO DirectByteBuffers, or the Netty direct buffers do it. > This may have multiple advantages: > - We reduce the size of the JVM heap (garbage collected) and the number and size of long living alive objects. For large JVM sizes, this may improve performance quite a bit. Utilmately, we would in many cases reduce JVM size to 1/3 to 1/2 and keep the remaining memory outside the JVM. > - We save copies when we move memory pages to disk (spilling) or through the network (shuffling / broadcasting / forward piping) > The changes required to implement this are > - Add a {{UnmanagedMemorySegment}} that only stores the memory adress as a long, and the segment size. It is initialized from a DirectByteBuffer. > - Allow the MemoryManager to allocate these MemorySegments, instead of the current ones. > - Make sure that the startup script pick up the mode and configure the heap size and the max direct memory properly. > Since the MemorySegment is probably the most performance critical class in Flink, we must take care that we do this right. The following are critical considerations: > - If we want both solutions (heap and off-heap) to exist side-by-side (configurable), we must make the base MemorySegment abstract and implement two versions (heap and off-heap). > - To get the best performance, we need to make sure that only one class gets loaded (or at least ever used), to ensure optimal JIT de-virtualization and inlining. > - We should carefully measure the performance of both variants. From previous micro benchmarks, I remember that individual byte accesses in DirectByteBuffers (off-heap) were slightly slower than on-heap, any larger accesses were equally good or slightly better. -- This message was sent by Atlassian JIRA (v6.3.4#6332)