Skip to content

Commit

Permalink
Fix update of statistic for LFC/prefetch (#9272)
Browse files Browse the repository at this point in the history
## Problem

See #9199

## Summary of changes

Fix update of hits/misses for LFC and prefetch introduced in
78938d1

## Checklist before requesting a review

- [ ] I have performed a self-review of my code.
- [ ] If it is a core feature, I have added thorough tests.
- [ ] Do we need to implement analytics? if so did you add the relevant
metrics to the dashboard?
- [ ] If this PR requires public announcement, mark it with
/release-notes label and add several sentences in this section.

## Checklist before merging

- [ ] Do not forget to reformat commit message to not include the above
checklist

Co-authored-by: Konstantin Knizhnik <[email protected]>
  • Loading branch information
knizhnik and Konstantin Knizhnik authored Oct 7, 2024
1 parent eae4470 commit 47c3c9a
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions pgxn/neon/pagestore_smgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,12 +886,19 @@ prefetch_register_bufferv(BufferTag tag, neon_request_lsns *frlsns,
{
min_ring_index = Min(min_ring_index, ring_index);
/* The buffered request is good enough, return that index */
pgBufferUsage.prefetch.duplicates++;
if (is_prefetch)
pgBufferUsage.prefetch.duplicates++;
else
pgBufferUsage.prefetch.hits++;
continue;
}
}
}

else if (!is_prefetch)
{
pgBufferUsage.prefetch.misses += 1;
MyNeonCounters->getpage_prefetch_misses_total++;
}
/*
* We can only leave the block above by finding that there's
* no entry that can satisfy this request, either because there
Expand Down Expand Up @@ -2797,7 +2804,6 @@ neon_read_at_lsnv(NRelFileInfo rinfo, ForkNumber forkNum, BlockNumber base_block
if (neon_prefetch_response_usable(reqlsns, slot))
{
ring_index = slot->my_ring_index;
pgBufferUsage.prefetch.hits += 1;
}
else
{
Expand Down Expand Up @@ -2827,9 +2833,6 @@ neon_read_at_lsnv(NRelFileInfo rinfo, ForkNumber forkNum, BlockNumber base_block
{
if (entry == NULL)
{
pgBufferUsage.prefetch.misses += 1;
MyNeonCounters->getpage_prefetch_misses_total++;

ring_index = prefetch_register_bufferv(buftag, reqlsns, 1, NULL, false);
Assert(ring_index != UINT64_MAX);
slot = GetPrfSlot(ring_index);
Expand Down Expand Up @@ -3059,6 +3062,9 @@ neon_readv(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
lfc_result = lfc_readv_select(InfoFromSMgrRel(reln), forknum, blocknum, buffers,
nblocks, read);

if (lfc_result > 0)
MyNeonCounters->file_cache_hits_total += lfc_result;

/* Read all blocks from LFC, so we're done */
if (lfc_result == nblocks)
return;
Expand Down

1 comment on commit 47c3c9a

@github-actions
Copy link

Choose a reason for hiding this comment

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

5173 tests run: 4956 passed, 0 failed, 217 skipped (full report)


Code coverage* (full report)

  • functions: 31.4% (7509 of 23942 functions)
  • lines: 49.6% (60277 of 121592 lines)

* collected from Rust tests only


The comment gets automatically updated with the latest test results
47c3c9a at 2024-10-07T11:14:26.963Z :recycle:

Please sign in to comment.