Skip to content

Refactor Shenandoah parser #190

New issue

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

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

Already on GitHub? Sign in to your account

Conversation

ghost
Copy link

@ghost ghost commented Aug 27, 2017

Task list for this pull request:

  • ✔ add more unittests to cover all types of events supported by Shenandoah to ease refactoring.
  • ✔ create log entry instead of stopping parsing after an exception.
  • ✔ use Type.lookup() to determine the type of GC event.
  • ✔ add DateTimeStamps support. In Java9, it's activated by applying :time decorator to the -Xlog JVM flag. Since the parser currently only supports the default -Xlog configuration, the other default decorators have to be added as well (level, tags), i.e.
    -Xlog::ShenandoahSampleDateTimeStamps.txt:time,level,tags

@codecov-io
Copy link

codecov-io commented Aug 27, 2017

Codecov Report

Merging #190 into feature/enhance-shenandoah-datareader will increase coverage by 0.11%.
The diff coverage is 97.14%.

Impacted file tree graph

@@                            Coverage Diff                             @@
##             feature/enhance-shenandoah-datareader    #190      +/-   ##
==========================================================================
+ Coverage                                    62.48%   62.6%   +0.11%     
+ Complexity                                    1290    1287       -3     
==========================================================================
  Files                                          143     143              
  Lines                                         8189    8174      -15     
  Branches                                      1317    1307      -10     
==========================================================================
  Hits                                          5117    5117              
+ Misses                                        2578    2567      -11     
+ Partials                                       494     490       -4
Impacted Files Coverage Δ Complexity Δ
.../tagtraum/perf/gcviewer/model/AbstractGCEvent.java 84.85% <100%> (-0.36%) 50 <0> (-1)
...gtraum/perf/gcviewer/imp/DataReaderShenandoah.java 92.59% <95.83%> (+20.12%) 10 <3> (-3) ⬇️
...java/com/tagtraum/perf/gcviewer/model/GCModel.java 85.23% <0%> (+0.25%) 130% <0%> (+1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 850490c...31f0add. Read the comment docs.

@ghost ghost force-pushed the feature/enhance-shenandoah-datareader branch from 00f4745 to cb6bef8 Compare August 27, 2017 17:05
Copy link
Owner

@chewiebug chewiebug left a comment

Choose a reason for hiding this comment

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

I like very much, how short DataReaderShenandoah is! Other parsers usually needed many more lines to achieve good coverage of the files.

I also like the test coverage. Now every last event is covered.

I have found few really small things. Could you have a look into them, please?

@@ -88,7 +94,10 @@ public GCModel read() throws IOException {
model.setFormat(GCModel.Format.RED_HAT_SHENANDOAH_GC);

Stream<String> lines = new BufferedReader(in).lines();
Copy link
Owner

Choose a reason for hiding this comment

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

No need to wrap "in" in a BufferedReader. It is a LineNumberReader, which is a subclass of BufferedReader.

event = line.contains("Concurrent") ? new ConcurrentGCEvent() : new GCEvent();
AbstractGCEvent.Type type = AbstractGCEvent.Type.lookup(withHeapMatcher.group(WITH_HEAP_EVENT_NAME));
event.setType(type);
setPauseAndTimestamp(event, withHeapMatcher.group(WITH_HEAP_DURATION), withHeapMatcher.group(WITH_HEAP_TIMESTAMP));
addHeapDetailsToEvent(event, withHeapMatcher.group(WITH_HEAP_MEMORY));
} else {
getLogger().warning("Found line that has no match:" + line);
Copy link
Owner

Choose a reason for hiding this comment

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

Usually, I add the line number to the log warnings, because this makes finding the offending line in the log easier. You might be able to use in.getLineNumber() (might not work here, because of the usage of the streams - I don't have any experience, there).

If it is difficult to add the line number - no problem. The warning also helps without the line number.

assertThat("amount of STW GC pause types", model.getGcEventPauses().size(), is(2));
assertThat("amount of STW Full GC pause types", model.getFullGcEventPauses().size(), is(0));
assertThat("amount of concurrent pause types", model.getConcurrentEventPauses().size(), is(3));
assertThat("total pause time", model.getPause().getSum(), is(0.001318));
Copy link
Owner

Choose a reason for hiding this comment

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

I think, tests for "double" values should usually be made using Matchers.closeTo() (examples can be found in TestDataReaderSun1_8_0G1). The reason is, that the representation of double values is not exact and can lead to tests failing randomly.

@chewiebug chewiebug merged commit 31f0add into chewiebug:feature/enhance-shenandoah-datareader Sep 8, 2017
@chewiebug chewiebug added this to the 1.36 milestone Aug 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants