Git Product home page Git Product logo

Comments (9)

brian-brazil avatar brian-brazil commented on September 7, 2024

The design of Striped64 is that once it creates additional Cells due to contention that it won't remove them afterwards, on the basis that you're likely to have that level of concurrency again in the future.

https://github.com/prometheus/client_java/blob/master/simpleclient/src/main/java/io/prometheus/client/Striped64.java#L17 has more detail.

Would this explain what you're seeing?

from client_java.

jsuchenia avatar jsuchenia commented on September 7, 2024

I know a design a solution, question is: Do we need to store own class in a ThreadLocal storage?
I found only one place where it's used. It's in DoubleAdder:

int h = (hc = threadHashCode.get()).code;

Maybe you can store generated hashCode as an Integer, not HashCode inner class ?

from client_java.

brian-brazil avatar brian-brazil commented on September 7, 2024

This code is copied from a recent versions of Java (older versions are missing it), so I'm afraid I can't comment on the exact implementation details. If there's a newer upstream version I'll be happy to update our copy.

from client_java.

jsuchenia avatar jsuchenia commented on September 7, 2024

This is not a master repo for prometheus libraries? Should I prepare a Pull request for that?
Sorry I didn't got your answer..

from client_java.

brian-brazil avatar brian-brazil commented on September 7, 2024

This is the master repo for the Prometheus java library. The code in question is from JCP JSR-166 and is included in Java 8 for example. As not all versions of Java include this library, we've copied it into this repository to avoid the need for users to pull in dependencies.

If there's an issue with this code, it should be fixed in the core Java libraries so that everyone can benefit.

from client_java.

jsuchenia avatar jsuchenia commented on September 7, 2024

In a latest version of Stped64 in Java code:
http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/ce1c874903cb/src/share/classes/java/util/concurrent/atomic/Striped64.java
they are storing a Double (via ThreadLocalRandom class)

In a JSR proposal:
http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/jsr166e/Striped64.java?view=co
they are storing an array of integers

So nobody is storing own Inner classes, only basic types to do not lock-down a classloader

from client_java.

Derbeth avatar Derbeth commented on September 7, 2024

I see Prometheus client already has a dependency on Guava and Guava has its own implementation of Striped64, very similar to yours but using ThreadLocal<int[]> instead of ThreadLocal<HashCode> (at least in Guava 18.0).

If you don't want to keep maintaining your own version of Striped64 and fixing memory issues, just use the version from Guava.

from client_java.

brian-brazil avatar brian-brazil commented on September 7, 2024

The original java client has dependencies, however the simpleclient (which we're discussing here). I haven't worked through the fully history yet, but if there's a newer version that works as far back as Java 6 I'll be happy to accept a PR to update our copy.

from client_java.

brian-brazil avatar brian-brazil commented on September 7, 2024

This should be resolved with #70

from client_java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.