Mercurial > hg > shenandoah-visualizer
changeset 46:a72bb2827e44
Rehash coloring scheme to fit liveness data without darkening everything
author | shade |
---|---|
date | Thu, 16 Aug 2018 10:51:18 +0200 |
parents | 3243c61e4bf8 |
children | 8531d3ab4c6c |
files | src/main/java/org/openjdk/shenandoah/Colors.java src/main/java/org/openjdk/shenandoah/RegionStat.java src/main/java/org/openjdk/shenandoah/ShenandoahVisualizer.java |
diffstat | 3 files changed, 69 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/org/openjdk/shenandoah/Colors.java Wed Aug 15 18:18:12 2018 +0200 +++ b/src/main/java/org/openjdk/shenandoah/Colors.java Thu Aug 16 10:51:18 2018 +0200 @@ -17,7 +17,7 @@ static final Color GCLAB_ALLOC = new Color(185, 0, 250); static final Color GCLAB_ALLOC_BORDER = new Color(118, 0, 160); - static final Color USED = new Color(200, 200, 200); + static final Color USED = new Color(220, 220, 220); static final Color LIVE_COMMITTED = new Color(150, 150, 150); static final Color LIVE_REGULAR = new Color(0, 200, 0);
--- a/src/main/java/org/openjdk/shenandoah/RegionStat.java Wed Aug 15 18:18:12 2018 +0200 +++ b/src/main/java/org/openjdk/shenandoah/RegionStat.java Thu Aug 16 10:51:18 2018 +0200 @@ -89,51 +89,74 @@ } } + private Color mixAlpha(Color c, float alpha) { + return new Color(c.getRed(), c.getGreen(), c.getBlue(), (int)(alpha * 150 + 105)); + } + public void render(Graphics g, int x, int y, int width, int height) { g.setColor(Color.WHITE); g.fillRect(x, y, width, height); - int usedWidth = (int) (width * usedLvl); - g.setColor(USED); - g.fillRect(x, y, usedWidth, height); + switch (state) { + case REGULAR: { + if (gclabLvl > 0 || tlabLvl > 0 || sharedLvl > 0) { + int sharedWidth = (int) (width * sharedLvl); + int tlabWidth = (int) (width * tlabLvl); + int gclabWidth = (int) (width * gclabLvl); + + int h = height; + int ly = y + (height - h); + int lx = x; - if (state == RegionState.REGULAR) { - if (gclabLvl > 0 || tlabLvl > 0 || sharedLvl > 0) { - int sharedWidth = (int) (width * liveLvl * sharedLvl); - int tlabWidth = (int) (width * liveLvl * tlabLvl); - int gclabWidth = (int) (width * liveLvl * gclabLvl); + g.setColor(mixAlpha(TLAB_ALLOC, liveLvl)); + g.fillRect(lx, ly, tlabWidth, h); + g.setColor(TLAB_ALLOC_BORDER); + g.drawRect(lx, ly, tlabWidth, h); - int h = height; - int ly = y + (height - h); - int lx = x; - - g.setColor(TLAB_ALLOC); - g.fillRect(lx, ly, tlabWidth, h); - g.setColor(TLAB_ALLOC_BORDER); - g.drawRect(lx, ly, tlabWidth, h); + lx += tlabWidth; + g.setColor(mixAlpha(GCLAB_ALLOC, liveLvl)); + g.fillRect(lx, ly, gclabWidth, h); + g.setColor(GCLAB_ALLOC_BORDER); + g.drawRect(lx, ly, gclabWidth, h); - lx += tlabWidth; - g.setColor(GCLAB_ALLOC); - g.fillRect(lx, ly, gclabWidth, h); - g.setColor(GCLAB_ALLOC_BORDER); - g.drawRect(lx, ly, gclabWidth, h); + lx += gclabWidth; + g.setColor(mixAlpha(SHARED_ALLOC, liveLvl)); + g.fillRect(lx, ly, sharedWidth, h); + g.setColor(SHARED_ALLOC_BORDER); + g.drawRect(lx, ly, sharedWidth, h); + } + break; + } + case PINNED: { + int usedWidth = (int) (width * usedLvl); + g.setColor(Colors.LIVE_PINNED); + g.fillRect(x, y, usedWidth, height); + break; + } + case CSET: + case PINNED_CSET: + case HUMONGOUS: + case PINNED_HUMONGOUS: { + int usedWidth = (int) (width * usedLvl); + g.setColor(USED); + g.fillRect(x, y, usedWidth, height); - lx += gclabWidth; - g.setColor(SHARED_ALLOC); - g.fillRect(lx, ly, sharedWidth, h); - g.setColor(SHARED_ALLOC_BORDER); - g.drawRect(lx, ly, sharedWidth, h); + int liveWidth = (int) (width * liveLvl); + g.setColor(selectLive(state)); + g.fillRect(x, y, liveWidth, height); + + g.setColor(selectLive(state)); + g.drawLine(x + liveWidth, y, x + liveWidth, y + height); + break; } - } else { - int liveWidth = (int) (width * liveLvl); - g.setColor(selectLive(state)); - g.fillRect(x, y, liveWidth, height); - - g.setColor(LIVE_BORDER); - g.drawLine(x + liveWidth, y, x + liveWidth, y + height); + case EMPTY_COMMITTED: + case EMPTY_UNCOMMITTED: + case TRASH: + break; + default: + throw new IllegalStateException("Unhandled region state: " + state); } - if (state == RegionState.TRASH) { g.setColor(Color.BLACK); g.drawLine(x, y, x + width, y + height); @@ -147,7 +170,6 @@ g.drawLine(x, y + off, x + off, y); g.drawLine(x + off, y + height, x + width, y + off); } - } g.setColor(Colors.BORDER);
--- a/src/main/java/org/openjdk/shenandoah/ShenandoahVisualizer.java Wed Aug 15 18:18:12 2018 +0200 +++ b/src/main/java/org/openjdk/shenandoah/ShenandoahVisualizer.java Thu Aug 16 10:51:18 2018 +0200 @@ -264,24 +264,27 @@ items.put("Empty Committed", new RegionStat(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, EMPTY_COMMITTED)); - items.put("1/2 Used", - new RegionStat(0.5f, 0.0f, 0.0f, 0.0f, 0.0f, REGULAR)); - - items.put("Fully Used", - new RegionStat(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, REGULAR)); - - items.put("Fully Used, Trash", + items.put("Trash", new RegionStat(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, TRASH)); items.put("Fully Live, 100% TLAB Allocs", new RegionStat(1.0f, 1.0f, 1.0f, 0.0f, 0.0f, REGULAR)); + items.put("0% Live, 100% TLAB Allocs", + new RegionStat(1.0f, 0.0f, 1.0f, 0.0f, 0.0f, REGULAR)); + items.put("Fully Live, 100% GCLAB Allocs", new RegionStat(1.0f, 1.0f, 0.0f, 1.0f, 0.0f, REGULAR)); + items.put("0% Live, 100% GCLAB Allocs", + new RegionStat(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, REGULAR)); + items.put("Fully Live, 100% Shared Allocs", new RegionStat(1.0f, 1.0f, 0.0f, 0.0f, 1.0f, REGULAR)); + items.put("0% Live, 100% Shared Allocs", + new RegionStat(1.0f, 0.0f, 0.0f, 0.0f, 1.0f, REGULAR)); + items.put("Fully Live, 50%/50% TLAB/GCLAB Allocs", new RegionStat(1.0f, 1.0f, 0.5f, 0.5f, 0.0f, REGULAR)); @@ -298,7 +301,7 @@ new RegionStat(1.0f, 0.3f, 0.0f, 0.0f, 0.0f, CSET)); items.put("1/3 Live + Pinned", - new RegionStat(1.0f, 0.3f, 0.0f, 0.0f, 0.0f, PINNED)); + new RegionStat(1.0f, 0.3f, 0.3f, 0.0f, 0.0f, PINNED)); items.put("1/3 Live + Pinned CSet", new RegionStat(1.0f, 0.3f, 0.0f, 0.0f, 0.0f, PINNED_CSET));