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 08A772009C6 for ; Tue, 17 May 2016 00:20:15 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 07242160A20; Mon, 16 May 2016 22:20:15 +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 4FBE6160A1F for ; Tue, 17 May 2016 00:20:14 +0200 (CEST) Received: (qmail 64847 invoked by uid 500); 16 May 2016 22:20:13 -0000 Mailing-List: contact hdfs-dev-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list hdfs-dev@hadoop.apache.org Received: (qmail 64723 invoked by uid 99); 16 May 2016 22:20:13 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 May 2016 22:20:13 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id DE51D2C1F62 for ; Mon, 16 May 2016 22:20:12 +0000 (UTC) Date: Mon, 16 May 2016 22:20:12 +0000 (UTC) From: "Stephen Bovy (JIRA)" To: hdfs-dev@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (HDFS-10412) Add optional non-thread support for better perfromance MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 16 May 2016 22:20:15 -0000 Stephen Bovy created HDFS-10412: ----------------------------------- Summary: Add optional non-thread support for better perfromance Key: HDFS-10412 URL: https://issues.apache.org/jira/browse/HDFS-10412 Project: Hadoop HDFS Issue Type: Improvement Components: libhdfs Reporter: Stephen Bovy Priority: Minor I would like to propose some simple optional changes that would be activated by a compiler flag. These changes would enable a typical monolithic single threaded application to use libhdfs without the need to incur additional overhead for threads that is not needed. Here is a proposed for these changes: #1 add a new function to "jni_helper.c" /** getSoloJNIEnv: A helper function to get the JNIEnv* for non-threaded use. * If no JVM exists, then one will be created. JVM command line arguments * are obtained from the LIBHDFS_OPTS environment variable. * @param: None. * @return The JNIEnv* for non-thread use. * */ JNIEnv* getSoloJNIEnv(void) { JNIEnv *env; env = getGlobalJNIEnv(); if (!env) { fprintf(stderr, "getJNIEnv: getGlobalJNIEnv failed\n"); return NULL; } return env; } Add the following the following to "hdfs.c" #1 a static global variable : "JNIEnv* hdfsJNIEnv;" #2 a MACRO: "GETJNIENV();" #ifdef NOTHREAD static JNIEnv* hdfsJNIEnv = NULL; #define GETJNIENV() \ if (hdfsJNIEnv == NULL) { \ hdfsJNIEnv = getSoloJNIEnv(); \ } \ env = hdfsJNIEnv; #else #define GETJNIENV() env = getJNIEnv(); #endif The above NEW MACRO would be used as in the following example: int hdfsFileGetReadStatistics(hdfsFile file, struct hdfsReadStatistics **stats) { jthrowable jthr; jobject readStats = NULL; jvalue jVal; struct hdfsReadStatistics *s = NULL; int ret; JNIEnv* env; // JNIEnv* env = getJNIEnv(); GETJNIENV(); ( ... ) } -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-dev-unsubscribe@hadoop.apache.org For additional commands, e-mail: hdfs-dev-help@hadoop.apache.org