Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C0D4A200CAB for ; Sun, 18 Jun 2017 21:12:09 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id BF181160BD1; Sun, 18 Jun 2017 19:12:09 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 1174A160BE3 for ; Sun, 18 Jun 2017 21:12:08 +0200 (CEST) Received: (qmail 70491 invoked by uid 500); 18 Jun 2017 19:12:08 -0000 Mailing-List: contact dev-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@drill.apache.org Delivered-To: mailing list dev@drill.apache.org Received: (qmail 70480 invoked by uid 99); 18 Jun 2017 19:12:08 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Jun 2017 19:12:08 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id A25B7C030F for ; Sun, 18 Jun 2017 19:12:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id EdFz9xsNAMHA for ; Sun, 18 Jun 2017 19:12:06 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 897D45F296 for ; Sun, 18 Jun 2017 19:12:05 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 561C6E00A3 for ; Sun, 18 Jun 2017 19:12:03 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id D2B2820DF1 for ; Sun, 18 Jun 2017 19:12:01 +0000 (UTC) Date: Sun, 18 Jun 2017 19:12:00 +0000 (UTC) From: "Paul Rogers (JIRA)" To: dev@drill.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (DRILL-5593) Modernize Drill's memory allocator to reflect current usage MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Sun, 18 Jun 2017 19:12:09 -0000 Paul Rogers created DRILL-5593: ---------------------------------- Summary: Modernize Drill's memory allocator to reflect current usage Key: DRILL-5593 URL: https://issues.apache.org/jira/browse/DRILL-5593 Project: Apache Drill Issue Type: Improvement Affects Versions: 1.10.0 Reporter: Paul Rogers Drill's memory allocator is quite sophisticated. But, as Drill moves toward improved resource management, the design of the current allocator no longer aligns well with the overall resource management design. The current allocator: * Provides a separate allocator and accountant for each operator. * Enforces a hard memory limit for each operator, causing an OOM error when the operator exceeds the per-operator limit. * Provides a complex transfer mechanism that moves memory ownership from one operator to another as batches move downstream. * Allows a buffer to be shared by multiple allocators, with one allocator being the "owing" allocator. * Allows a memory block to be shared by multiple buffers (as occurs when deserializing a record batch from the wire.) * Provides a tree of allocators in which child allocators can ask parents for more memory and parents provide that memory out of their own allocation. The current design appears to have been an attempt to allow operators to negotiate among themselves for memory usage. The idea seems to be that any given operator uses its assigned memory. If it needs more, it asks the parent allocator for more. If the parent can't provide more, the child operator sends a {{OUT_OF_MEMORY}} signal downstream and some downstream operator must give up some of its memory (perhaps by spilling) so that the upstream operator can proceed. The challenge is that only the framework was implemented, not the intended negotiation mechanisms. As a result, the current allocator presents challenges: * Drill is moving toward a planned memory allocation system: the planner assigns memory limits to each fragment (for the in-flight batch overhead) and to each buffering operator. * Memory is then managed at the fragment level, and per-opeartor, but only for buffering operators. * Memory for other operators (scan, select, project, etc.) is completely determined by batch size, th operators have no way to deal with OOM conditions. * The {{OUT_OF_MEMORY}} iterator status never worked. (It is hard to imagine how, say, a scan operator would run out of memory on column d within (a, b, c, d, e, f), remember its state, hold onto the d value, send the signal downstream, then resume where it left off. The code would become even more complex than it already is. * Code now must rediscover the memory used by each batch just to ensure that it never exceeds the per-operator memory limits. The sort, in particular is infamous for OOM on SV2 allocation because a batch is so large that it fills up the allocator, causing the next allocation (the SV2) to fail -- but only for accounting reasons. One very important part of the current allocator to be retained is the "fresh" (one buffer per vector) and deserialized (shared buffer for all vectors) modes. Also, the ability for a single deserialized buffer to be shared by multiple fragments. As a result, this is a complex design task, not a simple bug fix. -- This message was sent by Atlassian JIRA (v6.4.14#64029)