Skip to content
Permalink
Browse files
move to perfmark from grpc
  • Loading branch information
carl-mastrangelo committed May 9, 2019
1 parent c08d9cb commit 783630d78a0166296aa7c449284f4eb0fadf9cf5
Show file tree
Hide file tree
Showing 39 changed files with 118 additions and 121 deletions.
@@ -12,7 +12,7 @@ target
bazel-bin
bazel-examples
bazel-genfiles
bazel-grpc-java
bazel-perfmark
bazel-out
bazel-testlogs

@@ -1,5 +1,9 @@
package io.grpc.contrib.perfmark;
package io.perfmark;

import io.perfmark.Link;
import io.perfmark.PerfMark;
import io.perfmark.PerfMarkCloseable;
import io.perfmark.Tag;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
@@ -1,7 +1,7 @@
package io.grpc.contrib.perfmark;
package io.perfmark;

/**
* Internal class for accessing package protected methods of the perfmark api. If you need to use
* Internal class for accessing package protected methods of the PerfMark API. If you need to use
* this class, please file an issue on GitHub first with your use case.
*/
public final class Internal {
@@ -1,6 +1,5 @@
package io.grpc.contrib.perfmark;
package io.perfmark;

import io.grpc.contrib.perfmark.impl.Mark;
import java.util.concurrent.atomic.AtomicLong;

/**
@@ -28,6 +27,16 @@ long getId() {

@Override
public String toString() {
return "Link{id=" + id + "}";
return "Link(" + id + ")";
}

/**
* Equality on Links is not well defined, since the created tag can depend on if PerfMark was
* enabled at the time of creation.
*/
@Override
@Deprecated // Don't use equality on links
public boolean equals(Object obj) {
return super.equals(obj);
}
}
@@ -1,6 +1,4 @@
package io.grpc.contrib.perfmark;

import io.grpc.contrib.perfmark.impl.Generator;
package io.perfmark;

/**
* Noop Generator for use when no other generator can be used.
@@ -1,9 +1,5 @@
package io.grpc.contrib.perfmark;
package io.perfmark;

import io.grpc.contrib.perfmark.impl.Mark;
import io.grpc.contrib.perfmark.impl.MarkHolder;
import io.grpc.contrib.perfmark.impl.MarkHolderProvider;
import io.grpc.contrib.perfmark.impl.Marker;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
@@ -1,10 +1,8 @@
package io.grpc.contrib.perfmark;
package io.perfmark;

import static io.grpc.contrib.perfmark.impl.Generator.GEN_OFFSET;
import static io.perfmark.Generator.GEN_OFFSET;

import com.google.errorprone.annotations.CompileTimeConstant;
import io.grpc.contrib.perfmark.impl.Generator;
import io.grpc.contrib.perfmark.impl.Marker;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.logging.Level;
@@ -21,7 +19,7 @@ public final class PerfMark {
Queue<Throwable> failures = new ArrayDeque<Throwable>();
try {
Class<? extends Generator> clz =
Class.forName("io.grpc.contrib.perfmark.java7.SecretMethodHandleGenerator$MethodHandleGenerator")
Class.forName("io.perfmark.java7.SecretMethodHandleGenerator$MethodHandleGenerator")
.asSubclass(Generator.class);
gen = clz.getDeclaredConstructor().newInstance();
} catch (ClassNotFoundException e) {
@@ -38,7 +36,7 @@ public final class PerfMark {
if (gen == null) {
try {
Class<? extends Generator> clz =
Class.forName("io.grpc.contrib.perfmark.java9.PackageAccess$VarHandleGenerator")
Class.forName("io.perfmark.java9.PackageAccess$VarHandleGenerator")
.asSubclass(Generator.class);
gen = clz.getDeclaredConstructor().newInstance();
} catch (ClassNotFoundException e) {
@@ -56,7 +54,7 @@ public final class PerfMark {
if (gen == null) {
try {
Class<? extends Generator> clz =
Class.forName("io.grpc.contrib.perfmark.java6.PackageAccess$VolatileGenerator")
Class.forName("io.perfmark.java6.PackageAccess$VolatileGenerator")
.asSubclass(Generator.class);
gen = clz.getDeclaredConstructor().newInstance();
} catch (ClassNotFoundException e) {
@@ -1,10 +1,13 @@
package io.grpc.contrib.perfmark;
package io.perfmark;

import com.google.errorprone.annotations.CompileTimeConstant;
import java.io.Closeable;

public abstract class PerfMarkCloseable implements Closeable {

/**
* {@link #close()} does not throw a checked exception.
*/
@Override
public abstract void close();

@@ -1,10 +1,5 @@
package io.grpc.contrib.perfmark;
package io.perfmark;

import io.grpc.contrib.perfmark.impl.Mark;
import io.grpc.contrib.perfmark.impl.MarkHolder;
import io.grpc.contrib.perfmark.impl.MarkHolderProvider;
import io.grpc.contrib.perfmark.impl.MarkList;
import io.grpc.contrib.perfmark.impl.Marker;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
@@ -22,7 +17,7 @@
public final class PerfMarkStorage {

static final long NO_THREAD_ID = -1;
static final String NO_THREAD_NAME = "(unknown)";
static final String NO_THREAD_NAME = "(unknownThread)";

private static final MarkHolderProvider markHolderProvider;
private static final Logger logger;
@@ -32,7 +27,7 @@ public final class PerfMarkStorage {
Queue<Throwable> failures = new ArrayDeque<Throwable>();
try {
Class<? extends MarkHolderProvider> clz =
Class.forName("io.grpc.contrib.perfmark.java9.PackageAccess$VarHandleMarkHolderProvider")
Class.forName("io.perfmark.java9.PackageAccess$VarHandleMarkHolderProvider")
.asSubclass(MarkHolderProvider.class);
MarkHolderProvider provider = clz.getDeclaredConstructor().newInstance();
if (provider.unavailabilityCause() != null) {
@@ -1,33 +1,23 @@
package io.grpc.contrib.perfmark;
package io.perfmark;

import io.grpc.contrib.perfmark.impl.Mark;
import javax.annotation.Nullable;

/**
* Tag is a dynamic, runtime created identifier (such as an RPC id).
*/
public final class Tag {
static final Tag NO_TAG = new Tag();
static final Tag NO_TAG = new Tag(Mark.NO_TAG_ID);

@Nullable final String tagName;
final long tagId;

private Tag() {
this.tagName = Mark.NO_TAG_NAME;
this.tagId = Mark.NO_TAG_ID;
}

Tag(long tagId) {
this.tagName = Mark.NO_TAG_NAME;
this.tagId = tagId;
}

Tag(String tagName) {
if (tagName == null) {
throw new NullPointerException("bad tag name");
}
this.tagName = tagName;
this.tagId = Mark.NO_TAG_ID;
this(tagName, Mark.NO_TAG_ID);
}

Tag(String tagName, long tagId) {
@@ -37,4 +27,19 @@ private Tag() {
this.tagName = tagName;
this.tagId = tagId;
}

@Override
public String toString() {
return "Tag(" + tagName + ", " + tagId + ')';
}

/**
* Equality on Tags is not well defined, since the created tag can depend on if PerfMark was
* enabled at the time of creation.
*/
@Override
@Deprecated // Don't use equality on tags
public boolean equals(Object obj) {
return super.equals(obj);
}
}
@@ -1,3 +1,3 @@
@javax.annotation.CheckReturnValue
@javax.annotation.ParametersAreNonnullByDefault
package io.grpc.contrib.perfmark;
package io.perfmark;
@@ -7,7 +7,6 @@ buildscript {

dependencies {
classpath 'com.github.erizo.gradle:jcstress-gradle-plugin:0.8.2'
classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.4.5'
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.6'
classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.8"
}
@@ -18,7 +17,6 @@ subprojects {
apply plugin: "idea"
apply plugin: "jacoco"
apply plugin: "me.champeau.gradle.jmh"
apply plugin: "ru.vyarus.animalsniffer"
apply plugin: "net.ltgt.errorprone"

repositories {
@@ -45,7 +43,7 @@ subprojects {

jacoco { toolVersion = "0.8.2" }

group = "io.grpc.contrib.perfmark"
group = "io.perfmark"
version = "1.0.0-SNAPSHOT"

ext {
@@ -6,8 +6,5 @@ targetCompatibility = 1.6
dependencies {
compile libraries.jsr305,
libraries.errorprone

signature "org.codehaus.mojo.signature:java17:1.0@signature"
signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature"
}

@@ -1,4 +1,4 @@
package io.grpc.contrib.perfmark.impl;
package io.perfmark;

public abstract class Generator {
public static final int GEN_OFFSET = 8;
@@ -1,4 +1,4 @@
package io.grpc.contrib.perfmark.impl;
package io.perfmark;

public final class Internal {

@@ -1,4 +1,4 @@
package io.grpc.contrib.perfmark.impl;
package io.perfmark;

import java.util.Arrays;
import javax.annotation.Nullable;
@@ -1,4 +1,4 @@
package io.grpc.contrib.perfmark.impl;
package io.perfmark;

import java.util.List;

@@ -1,4 +1,4 @@
package io.grpc.contrib.perfmark.impl;
package io.perfmark;

import javax.annotation.Nullable;

@@ -1,4 +1,4 @@
package io.grpc.contrib.perfmark.impl;
package io.perfmark;

import java.util.ArrayList;
import java.util.Arrays;
@@ -1,4 +1,4 @@
package io.grpc.contrib.perfmark.impl;
package io.perfmark;

import java.util.Arrays;
import javax.annotation.Nullable;
@@ -1,4 +1,4 @@
package io.grpc.contrib.perfmark.impl;
package io.perfmark;

import javax.annotation.Nullable;

@@ -1,3 +1,3 @@
@javax.annotation.CheckReturnValue
@javax.annotation.ParametersAreNonnullByDefault
package io.grpc.contrib.perfmark.impl;
package io.perfmark;
@@ -1,6 +1,6 @@
package io.grpc.contrib.perfmark.java6;
package io.perfmark.java6;

import io.grpc.contrib.perfmark.impl.Generator;
import io.perfmark.Generator;

public final class Internal {

@@ -1,6 +1,6 @@
package io.grpc.contrib.perfmark.java6;
package io.perfmark.java6;

import io.grpc.contrib.perfmark.impl.Generator;
import io.perfmark.Generator;

final class SecretVolatileGenerator {

@@ -1,3 +1,3 @@
@javax.annotation.CheckReturnValue
@javax.annotation.ParametersAreNonnullByDefault
package io.grpc.contrib.perfmark.java6;
package io.perfmark.java6;
@@ -6,9 +6,6 @@ targetCompatibility = 1.7
dependencies {
compile project(':perfmark-impl-api'),
libraries.jsr305

// no signature because method handles are @PolymorphicSignature
// signature "org.codehaus.mojo.signature:java17:1.0@signature"
}

jmh {
@@ -17,7 +14,6 @@ jmh {
fork = 1
warmupIterations = 10


profilers = ["perfasm"]

jvmArgs = [
@@ -37,5 +33,4 @@ jmh {
"-XX:PrintAssemblyOptions=syntax",
"-XX:PrintAssemblyOptions=intel"
]

}
@@ -1,4 +1,4 @@
package io.grpc.contrib.perfmark.java7;
package io.perfmark.java7;

import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
@@ -1,6 +1,6 @@
package io.grpc.contrib.perfmark.java7;
package io.perfmark.java7;

import io.grpc.contrib.perfmark.impl.Generator;
import io.perfmark.Generator;

public final class Internal {

@@ -1,6 +1,6 @@
package io.grpc.contrib.perfmark.java7;
package io.perfmark.java7;

import io.grpc.contrib.perfmark.impl.Generator;
import io.perfmark.Generator;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MutableCallSite;
@@ -1,3 +1,3 @@
@javax.annotation.CheckReturnValue
@javax.annotation.ParametersAreNonnullByDefault
package io.grpc.contrib.perfmark.java7;
package io.perfmark.java7;

0 comments on commit 783630d

Please sign in to comment.