Skip to content

Commit

Permalink
IGNITE-14266 Added "page free space" column to pages lists system vie…
Browse files Browse the repository at this point in the history
…ws - Fixes apache#10631.

Signed-off-by: Aleksey Plekhanov <[email protected]>
  • Loading branch information
alex-plekhanov committed Apr 10, 2023
1 parent d0d3ead commit aa57c09
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/_docs/monitoring-metrics/system-views.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ and also helps to detect skews in page lists utilization.
|BUCKET_SIZE | long | Count of pages in the bucket
|STRIPES_COUNT | int| Count of stripes used by this bucket. Stripes are used to avoid contention.
|CACHED_PAGES_COUNT | int| Count of pages in an on-heap page list cache for this bucket.
|PAGE_FREE_SPACE | int | Free space (in bytes) available to use for each page in this bucket.
|===

=== DATA_REGION_PAGE_LISTS
Expand All @@ -708,6 +709,7 @@ and also helps to detect skews in page lists utilization.
|BUCKET_SIZE | long | Count of pages in the bucket
|STRIPES_COUNT | int| Count of stripes used by this bucket. Stripes are used to avoid contention.
|CACHED_PAGES_COUNT | int| Count of pages in an on-heap page list cache for this bucket.
|PAGE_FREE_SPACE | int | Free space (in bytes) available to use for each page in this bucket.
|===

== PARTITION_STATES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1012,11 +1012,13 @@ public void testGetAllColumns() throws Exception {
"SYS.CACHE_GROUP_PAGE_LISTS.BUCKET_SIZE.null",
"SYS.CACHE_GROUP_PAGE_LISTS.STRIPES_COUNT.null",
"SYS.CACHE_GROUP_PAGE_LISTS.CACHED_PAGES_COUNT.null",
"SYS.CACHE_GROUP_PAGE_LISTS.PAGE_FREE_SPACE.null",
"SYS.DATA_REGION_PAGE_LISTS.NAME.null",
"SYS.DATA_REGION_PAGE_LISTS.BUCKET_NUMBER.null",
"SYS.DATA_REGION_PAGE_LISTS.BUCKET_SIZE.null",
"SYS.DATA_REGION_PAGE_LISTS.STRIPES_COUNT.null",
"SYS.DATA_REGION_PAGE_LISTS.CACHED_PAGES_COUNT.null",
"SYS.DATA_REGION_PAGE_LISTS.PAGE_FREE_SPACE.null",
"SYS.PARTITION_STATES.CACHE_GROUP_ID.null",
"SYS.PARTITION_STATES.PARTITION_ID.null",
"SYS.PARTITION_STATES.NODE_ID.null",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class CachePagesListViewWalker implements SystemViewRowAttributeWalker<Ca
v.accept(4, "bucketSize", long.class);
v.accept(5, "stripesCount", int.class);
v.accept(6, "cachedPagesCount", int.class);
v.accept(7, "pageFreeSpace", int.class);
}

/** {@inheritDoc} */
Expand All @@ -69,10 +70,11 @@ public class CachePagesListViewWalker implements SystemViewRowAttributeWalker<Ca
v.acceptLong(4, "bucketSize", row.bucketSize());
v.acceptInt(5, "stripesCount", row.stripesCount());
v.acceptInt(6, "cachedPagesCount", row.cachedPagesCount());
v.acceptInt(7, "pageFreeSpace", row.pageFreeSpace());
}

/** {@inheritDoc} */
@Override public int count() {
return 7;
return 8;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class PagesListViewWalker implements SystemViewRowAttributeWalker<PagesLi
v.accept(2, "bucketSize", long.class);
v.accept(3, "stripesCount", int.class);
v.accept(4, "cachedPagesCount", int.class);
v.accept(5, "pageFreeSpace", int.class);
}

/** {@inheritDoc} */
Expand All @@ -59,10 +60,11 @@ public class PagesListViewWalker implements SystemViewRowAttributeWalker<PagesLi
v.acceptLong(2, "bucketSize", row.bucketSize());
v.acceptInt(3, "stripesCount", row.stripesCount());
v.acceptInt(4, "cachedPagesCount", row.cachedPagesCount());
v.acceptInt(5, "pageFreeSpace", row.pageFreeSpace());
}

/** {@inheritDoc} */
@Override public int count() {
return 5;
return 6;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,11 @@ public AbstractFreeList(
init(metaPageId, initNew);
}

/** {@inheritDoc} */
@Override public int getPageFreeSpace(int bucket) {
return bucket << shift;
}

/**
* Calculates free space tracked by this FreeListImpl instance.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,13 @@ private void releaseAndClose(long pageId, long page, long pageAddr) {
}
}

/**
* Gets per page free space for specified bucket.
*
* @return Free space available to use for each page in specified bucket.
*/
public abstract int getPageFreeSpace(int bucket);

/**
* Gets bucket index by page freespace.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ public ReuseListImpl(
return this.bucket;
}

/** {@inheritDoc} */
@Override public int getPageFreeSpace(int bucket) {
return pageSize();
}

/** {@inheritDoc} */
@Override protected int getBucketIndex(int freeSpace) {
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,12 @@ public int stripesCount() {
public int cachedPagesCount() {
return pagesList.cachedPagesCount(bucket);
}

/**
* @return Free space for each page in this bucket.
*/
@Order(7)
public int pageFreeSpace() {
return pagesList.getPageFreeSpace(bucket);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
import org.apache.ignite.internal.managers.systemview.walker.NodeAttributeViewWalker;
import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager;
import org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager;
import org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList;
import org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage;
import org.apache.ignite.internal.processors.metric.impl.PeriodicHistogramMetricImpl;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcConnectionContext;
Expand Down Expand Up @@ -1858,6 +1859,29 @@ public void testPagesList() throws Exception {
assertTrue(dr0flPages > 0);
assertTrue(dr0flStripes > 0);

int bucketsCnt = ((PagesList)ignite.context().cache().context().database().freeList("dr0")).bucketsCount();
int[] bucketPagesSize = new int[bucketsCnt];

for (PagesListView pagesListView : dataRegionPageLists) {
int bucket = pagesListView.bucketNumber();

if (bucketPagesSize[bucket] == 0) {
assertTrue(bucket == 0 || pagesListView.pageFreeSpace() != 0);
bucketPagesSize[bucket] = pagesListView.pageFreeSpace();
}
else
assertEquals(bucketPagesSize[bucket], pagesListView.pageFreeSpace());
}

int prev = 0;

for (int size : bucketPagesSize) {
if (size > 0) {
assertTrue(size > prev);
prev = size;
}
}

SystemView<CachePagesListView> cacheGrpPageLists = ignite.context().systemView().view(CACHE_GRP_PAGE_LIST_VIEW);

long dr1flPages = 0;
Expand Down

0 comments on commit aa57c09

Please sign in to comment.