Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Performance test and fix for logger part of the logging system #24949

Merged
merged 3 commits into from
May 12, 2024

Conversation

dmatej
Copy link
Contributor

@dmatej dmatej commented May 10, 2024

Years ago I made some comparisons for JUL logging, but I never pushed those tests.
Yesterday I had some doubts about the best way to format log messages, so I created a test. Meanwhile I noticed that one method in logger was not overridden and when I overrode it, it started failing the test. Long story short, GlassFish usually uses multiple handlers in parallel, so GJULE pushes common parts to caller threads to avoid duplicating and even blocking on handlers and formatters. But that means that the early resolution should not do work which is not required later - especially it should not analyze stacktraces when the detected class and method is not used in any output.

Oh, the original idea - yeah, MessageFormat is really slow compared to "+", StringBuilder, even behind suppliers. String.format is quiet slow too.

- The test checks mostly the GlassFishLogger class and several message formatting
  strategies
- The test doesn't check handlers, formatters.
- The LogCollectorHandler has new constructor allowing to set the capacity and
  wait timeout.
- The logrb method was not overridden (was added to JUL in Java 9); when
  overriden, caused significant slowdown because of the stacktrace analysis.
- This commit does not pass the test.

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
- The stacktrace analysis is now done just when
  - it is detected that some handler/formatter uses its results
  - it is explicitly enabled

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
@dmatej dmatej marked this pull request as ready for review May 10, 2024 15:41
@dmatej dmatej added this to the 7.0.15 milestone May 10, 2024
@dmatej dmatej added the enhancement New feature or request label May 10, 2024
@dmatej dmatej changed the title Gjule Performance test and fix for logger part of the logging system May 10, 2024
* If this key is set to true, GJULE will detect the caller class and method from stacktrace,
* which is quite expensive operation affecting logging throughput.
* <p>
* If it is set to null, GJULE will not perform such detection.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand that. It says: if set to null but the code seems to check for false.

I'm not very familiar with properties handling here, but set to null is different case than not set, isn't it?

Just would like to know what are my options here 😁 and where the false from

        if (Boolean.FALSE.toString().equalsIgnoreCase(value)) {
            return false;
        }

fits in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I will take a sleep and I will read and fix it after myself :-)
Thanks for noticing that!
And I should add that to the documentation too.

@dmatej dmatej marked this pull request as draft May 10, 2024 20:07
@dmatej dmatej requested a review from pzygielo May 11, 2024 19:19
@dmatej dmatej marked this pull request as ready for review May 11, 2024 19:19
@dmatej dmatej marked this pull request as draft May 11, 2024 19:49
@dmatej
Copy link
Contributor Author

dmatej commented May 11, 2024

Ok, yet once more to the Draft - missing documentation, and OneLineFormatter has printSource as true by default.

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
@dmatej dmatej marked this pull request as ready for review May 11, 2024 20:11
@dmatej dmatej merged commit e6e71df into eclipse-ee4j:master May 12, 2024
2 checks passed
@dmatej dmatej deleted the gjule branch May 12, 2024 08:05
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants