Giter Site home page Giter Site logo

Comments (12)

SlyngDK avatar SlyngDK commented on May 26, 2024 1

@dfa1 Thx for creating the issue, I understand the problem you are pointing at.

I see these different solutions for the problem, with different performance impact.

  • synchronized like the class the JsonFormatter extends StructuredFormatter
  • Pool of writers, result in some other locking when requesting at writer not in use.
  • Use new writer for each format, results in more object creation(Including auto expand of buffer) and GC.

I don't have any performance numbers of the different solutions, but I think synchronized is the best compromise.

@dfa1 If you have the time you could create a micro benchmark, to check the numbers, against current library.

from quarkus-logging-json.

SlyngDK avatar SlyngDK commented on May 26, 2024 1

I have done a quick benchmark with 1 and 2 thread, and creating a new StringBuildWriter is the best compromise.

I have released 1.0.1.

Benchmark                        Mode  Cnt        Score   Error  Units
BenchmarkNewStringWriter.init1  thrpt    2   598932,618          ops/s
BenchmarkNewStringWriter.init2  thrpt    2  1087659,986          ops/s
BenchmarkObjectPool.init1       thrpt    2   554206,536          ops/s
BenchmarkObjectPool.init2       thrpt    2   837947,587          ops/s
BenchmarkOld.init1              thrpt    2   670263,357          ops/s
BenchmarkOld.init2              thrpt    2  1206957,338          ops/s
BenchmarkSynchronized.init1     thrpt    2   663996,158          ops/s
BenchmarkSynchronized.init2     thrpt    2   577327,380          ops/s

from quarkus-logging-json.

gsmet avatar gsmet commented on May 26, 2024 1

You can play for sure but my advice is to keep it simple. StringBuilder is not an expensive object to create and it has been designed for exactly this usage.

from quarkus-logging-json.

dfa1 avatar dfa1 commented on May 26, 2024

@gsmet please have a look here. A bit of context: I just migrated to this library for our JSON logging needs, as per quarkusio/quarkus#15193 (comment)

Often in Splunk we have corrupted logs starting with t{, instead of {

from quarkus-logging-json.

dfa1 avatar dfa1 commented on May 26, 2024

/cc @SlyngDK maybe you can help here?

from quarkus-logging-json.

dfa1 avatar dfa1 commented on May 26, 2024

@SlyngDK thank you for the answer :) I would like to have a release as soon as possible, so maybe the synchronized is the best option right now (better than my proposed PR).

@SlyngDK later I could try to write a benchmark, also to evaluate the option of pool of writers (e.g. I would like to try with this little object pool library requiring only JDK classes, https://github.com/chrisvest/stormpot)

from quarkus-logging-json.

gsmet avatar gsmet commented on May 26, 2024

@SlyngDK I would just create a new one each time. It's a lightweight object and that's how you use StringBuilder usually.

from quarkus-logging-json.

dfa1 avatar dfa1 commented on May 26, 2024

@SlyngDK would it be possible to merge my pull request as is, release it and then iterate on a better fix? @gsmet has a valid argument about StringBuilder)

from quarkus-logging-json.

dfa1 avatar dfa1 commented on May 26, 2024

thank you @SlyngDK!

just one question: which object pooling library you used in the benchmark?

from quarkus-logging-json.

SlyngDK avatar SlyngDK commented on May 26, 2024

@dfa1 I used Apache Commons Pool.

from quarkus-logging-json.

dfa1 avatar dfa1 commented on May 26, 2024

@SlyngDK thank you! Can you please push the benchmark code somewhere? I would like to play a bit with https://github.com/chrisvest/stormpot

from quarkus-logging-json.

dfa1 avatar dfa1 commented on May 26, 2024

@gsmet yes, it is just out of curiosity :) By the way the current fix shipped with 1.0.1 is obviously working fine for my use case (few thousands log events per hour)

from quarkus-logging-json.

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.