Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Apr 2017 17:58:59 +0000 (UTC)
From:      Johannes M Dieterich <jmd@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r437452 - in head/java: . lightweight-java-profiler lightweight-java-profiler/files
Message-ID:  <201704011758.v31HwxuH096198@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jmd
Date: Sat Apr  1 17:58:59 2017
New Revision: 437452
URL: https://svnweb.freebsd.org/changeset/ports/437452

Log:
  new port: java/lightweight-java-profiler
  
  A port of the lightweight-java-profiler (ljp). ljp acts as a bare-bones agentlib to produce profiling stacks that can be digested, e.g., by Brendan Gregg's flamegraph scripts.
  
  Reviewed by:	mat, swills (mentor)
  Approved by:	swills (mentor)
  Differential Revision:	https://reviews.freebsd.org/D10194

Added:
  head/java/lightweight-java-profiler/
  head/java/lightweight-java-profiler/Makefile   (contents, props changed)
  head/java/lightweight-java-profiler/distinfo   (contents, props changed)
  head/java/lightweight-java-profiler/files/
  head/java/lightweight-java-profiler/files/patch-Makefile   (contents, props changed)
  head/java/lightweight-java-profiler/files/patch-src_display.cc   (contents, props changed)
  head/java/lightweight-java-profiler/files/patch-src_entry.cc   (contents, props changed)
  head/java/lightweight-java-profiler/files/patch-src_globals.h   (contents, props changed)
  head/java/lightweight-java-profiler/pkg-descr   (contents, props changed)
  head/java/lightweight-java-profiler/pkg-message   (contents, props changed)
Modified:
  head/java/Makefile

Modified: head/java/Makefile
==============================================================================
--- head/java/Makefile	Sat Apr  1 17:42:28 2017	(r437451)
+++ head/java/Makefile	Sat Apr  1 17:58:59 2017	(r437452)
@@ -90,6 +90,7 @@
     SUBDIR += junit
     SUBDIR += jxgrabkey
     SUBDIR += langspec
+    SUBDIR += lightweight-java-profiler
     SUBDIR += linux-oracle-jdk18
     SUBDIR += linux-oracle-jre18
     SUBDIR += mmake

Added: head/java/lightweight-java-profiler/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/java/lightweight-java-profiler/Makefile	Sat Apr  1 17:58:59 2017	(r437452)
@@ -0,0 +1,47 @@
+# Created by: Johannes Dieterich <jmd@FreeBSD.org>
+# $FreeBSD$
+
+PORTNAME=	lightweight-java-profiler
+PORTVERSION=	g20170308
+CATEGORIES=	java devel
+
+MAINTAINER=	jmd@FreeBSD.org
+COMMENT=	Lightweight Java profiler which can be used for flamegraphs
+
+LICENSE=	APACHE20
+LICENSE_FILE=	${WRKSRC}/COPYING
+
+BUILD_DEPENDS=	bash>=0:shells/bash
+RUN_DEPENDS=	bash>=0:shells/bash
+
+ONLY_FOR_ARCHS=	amd64 i386
+ONLY_FOR_ARCHS_REASON=	assembly only available for x86
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	inevity
+GH_TAGNAME=	e8041b5
+
+USE_JAVA=	yes
+JAVA_VERSION=	1.8
+
+USE_LDCONFIG=	yes
+USES=		gmake shebangfix
+
+SHEBANG_FILES=	Makefile
+
+MAKE_ENV=	JAVA_HOME=${LOCALBASE}/openjdk8
+
+.include <bsd.port.pre.mk>
+
+.if ${ARCH} == "i386"
+MAKE_ENV+=	BITS=32
+.else
+MAKE_ENV+=	BITS=64
+.endif
+
+PLIST_FILES=	lib/liblagent.so
+
+do-install:
+		${INSTALL_LIB} ${WRKSRC}/build/liblagent.so ${STAGEDIR}/${LOCALBASE}/lib/liblagent.so
+
+.include <bsd.port.post.mk>

Added: head/java/lightweight-java-profiler/distinfo
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/java/lightweight-java-profiler/distinfo	Sat Apr  1 17:58:59 2017	(r437452)
@@ -0,0 +1,3 @@
+TIMESTAMP = 1490927903
+SHA256 (inevity-lightweight-java-profiler-g20170308-e8041b5_GH0.tar.gz) = b5a64716586407ff69c3c77a0621e6b65e9580686ae9ec29b145becd65fa678e
+SIZE (inevity-lightweight-java-profiler-g20170308-e8041b5_GH0.tar.gz) = 16120

Added: head/java/lightweight-java-profiler/files/patch-Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/java/lightweight-java-profiler/files/patch-Makefile	Sat Apr  1 17:58:59 2017	(r437452)
@@ -0,0 +1,41 @@
+--- Makefile.orig	2017-03-31 01:58:22 UTC
++++ Makefile
+@@ -1,7 +1,7 @@
+-SHELL:=/bin/bash
++SHELL:=/usr/bin/env bash
+ UNAME:=$(shell uname | tr '[A-Z]' '[a-z]')
+ 
+-BITS?=32
++#BITS?=32
+ ifeq ($(UNAME), darwin)
+   READLINK_ARGS:=""
+   PLATFORM_WARNINGS:=-Weverything -Wno-c++98-compat-pedantic -Wno-padded \
+@@ -23,6 +23,13 @@ else ifeq ($(UNAME), linux)
+   HEADERS:=include
+   CC=g++
+   LDFLAGS=-Wl,--fatal-warnings
++else ifeq ($(UNAME), freebsd)
++  READLINK_ARGS:=""
++  PLATFORM_WARNINGS:=-Weverything -Wno-c++98-compat-pedantic -Wno-padded \
++        -Wno-missing-prototypes
++  PLATFORM_COPTS:=-std=c++11
++  HEADERS:=include
++  LDFLAGS=-Wl,-fatal_warnings
+ endif
+ 
+ JAVA_HOME := $(shell \
+@@ -32,11 +39,11 @@ JAVA_HOME := $(shell \
+ 	[[ -n "$${JAVA_HOME}" ]] || (echo "Cannot find JAVA_HOME" && exit) ; \
+ 	echo $${JAVA_HOME})
+ AGENT=liblagent.so
+-LIBS=-ldl
+-BUILD_DIR ?= $(shell mkdir build-$(BITS) 2> /dev/null ; echo build-$(BITS))
++LIBS=-lc
++BUILD_DIR ?= $(shell mkdir build 2> /dev/null ; echo build)
+ SRC_DIR:=${PWD}/src
+ OPT?=-O2
+-GLOBAL_WARNINGS=-Wall -Werror -Wformat-security -Wno-char-subscripts \
++GLOBAL_WARNINGS=-Wall -Wformat-security -Wno-char-subscripts \
+ 	-Wno-sign-compare -Wno-strict-overflow -Wwrite-strings -Wnon-virtual-dtor \
+ 	-Woverloaded-virtual
+ GLOBAL_COPTS=-fdiagnostics-show-option -fno-exceptions \

Added: head/java/lightweight-java-profiler/files/patch-src_display.cc
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/java/lightweight-java-profiler/files/patch-src_display.cc	Sat Apr  1 17:58:59 2017	(r437452)
@@ -0,0 +1,11 @@
+--- src/display.cc.orig	2015-04-15 08:00:23 UTC
++++ src/display.cc
+@@ -20,7 +20,7 @@ void StackTracesPrinter::PrintStackTrace
+     if (traces[i].count != 0) {
+       total += traces[i].count;
+       count++;
+-      fprintf(file_, "%"PRIdPTR" ", traces[i].count);
++      fprintf(file_, "%" PRIdPTR" ", traces[i].count);
+       PrintStackTrace(&traces[i]);
+       fprintf(file_, "\n");
+     }

Added: head/java/lightweight-java-profiler/files/patch-src_entry.cc
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/java/lightweight-java-profiler/files/patch-src_entry.cc	Sat Apr  1 17:58:59 2017	(r437452)
@@ -0,0 +1,20 @@
+--- src/entry.cc.orig	2015-04-15 08:00:23 UTC
++++ src/entry.cc
+@@ -182,7 +182,7 @@ static void SetFileFromOption(char *equa
+     if (Globals::OutFile == NULL) {
+       fprintf(stderr, "Could not open file %s: ", file_name);
+       perror(NULL);
+-      exit(1);
++      _exit(1);
+     }
+   }
+ 
+@@ -207,7 +207,7 @@ static void ParseArguments(char *options
+     char path[PATH_MAX];
+     if (getcwd(path, PATH_MAX) == NULL) {
+       fprintf(stderr, "cwd too long?\n");
+-      exit(0);
++      _exit(0);
+     }
+     size_t pathlen = strlen(path);
+     strncat(path, "/", PATH_MAX - (pathlen++));

Added: head/java/lightweight-java-profiler/files/patch-src_globals.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/java/lightweight-java-profiler/files/patch-src_globals.h	Sat Apr  1 17:58:59 2017	(r437452)
@@ -0,0 +1,23 @@
+--- src/globals.h.orig	2015-04-15 08:00:23 UTC
++++ src/globals.h
+@@ -179,18 +179,13 @@ class Accessors {
+ #endif
+ };
+ 
+-#if defined(__GNUC__) && (defined(i386) || defined(__x86_64))
+ #if defined(__x86_64__)
+ #define __CAS_INSTR "lock; cmpxchgq %1,%2"
+ #define __ADD_INSTR "lock; xaddq %0,%1"
+-#else  // defined(__x86_64__)
++#else
+ #define __CAS_INSTR "lock; cmpxchgl %1,%2"
+ #define __ADD_INSTR "lock; xaddl %0,%1"
+-#endif  // defined(__x86_64__)
+-#else  // defined(__GNUC__) && (defined(i386) || defined(__x86_64))
+-#error \
+-    "Cannot compile with non-x86.  Add support for atomic ops, if you want it"
+-#endif  // defined(__GNUC__) && (defined(i386) || defined(__x86_64))
++#endif
+ 
+ inline intptr_t NoBarrier_CompareAndSwap(volatile intptr_t *ptr,
+                                          intptr_t old_value,

Added: head/java/lightweight-java-profiler/pkg-descr
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/java/lightweight-java-profiler/pkg-descr	Sat Apr  1 17:58:59 2017	(r437452)
@@ -0,0 +1,9 @@
+lightweight-java-profiler
+
+a lightweight Java profiler which can be used for flamegraphs
+
+The lightweight Java profiler acts as an agent library and generates
+execution stacks. These can be fed into flamegraph utils to profile
+Java applications at minimal cost.
+
+WWW: https://github.com/inevity/lightweight-java-profiler

Added: head/java/lightweight-java-profiler/pkg-message
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/java/lightweight-java-profiler/pkg-message	Sat Apr  1 17:58:59 2017	(r437452)
@@ -0,0 +1,3 @@
+To use the lightweight-java-profiler, you can invoke Java as follows:
+
+java -agentpath:path/to/liblagent.so[:file=fname] It will spit out stack traces into traces.txt (or into the optional fname passed to the agent). The current implementation samples every 1/100th of a second. It stores the first 3000 stack traces it encounters; additional stack traces will be ignored, but duplicate stack traces will continue to be counted indefinitely (or until the counter overflows, which will take a while).



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201704011758.v31HwxuH096198>