Skip to content
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

HPCC-31649 New StSizePeakEphemeralDisk and StSizePeakTempDisk look ahead and hash distribute spilling #18585

Merged
merged 1 commit into from
Jun 14, 2024

Conversation

shamser
Copy link
Contributor

@shamser shamser commented Apr 25, 2024

Type of change:

  • This change is a bug fix (non-breaking change which fixes an issue).
  • This change is a new feature (non-breaking change which adds functionality).
  • This change improves the code (refactor or other change that does not change the functionality)
  • This change fixes warnings (the fix does not alter the functionality or the generated code)
  • This change is a breaking change (fix or feature that will cause existing behavior to change).
  • This change alters the query API (existing queries will have to be recompiled)

Checklist:

  • My code follows the code style of this project.
    • My code does not create any new warnings from compiler, build system, or lint.
  • The commit message is properly formatted and free of typos.
    • The commit message title makes sense in a changelog, by itself.
    • The commit is signed.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly, or...
    • I have created a JIRA ticket to update the documentation.
    • Any new interfaces or exported functions are appropriately commented.
  • I have read the CONTRIBUTORS document.
  • The change has been fully tested:
    • I have added tests to cover my changes.
    • All new and existing tests passed.
    • I have checked that this change does not introduce memory leaks.
    • I have used Valgrind or similar tools to check for potential issues.
  • I have given due consideration to all of the following potential concerns:
    • Scalability
    • Performance
    • Security
    • Thread-safety
    • Cloud-compatibility
    • Premature optimization
    • Existing deployed queries will not be broken
    • This change fixes the problem, not just the symptom
    • The target branch of this pull request is appropriate for such a change.
  • There are no similar instances of the same problem that should be addressed
    • I have addressed them here
    • I have raised JIRA issues to address them separately
  • This is a user interface / front-end modification
    • I have tested my changes in multiple modern browsers
    • The component(s) render as expected

Smoketest:

  • Send notifications about my Pull Request position in Smoketest queue.
  • Test my draft Pull Request.

Testing:

Copy link

Jira Issue: https://hpccsystems.atlassian.net//browse/HPCC-31649

Jirabot Action Result:
Workflow Transition: Merge Pending
Updated PR

@shamser shamser force-pushed the issue31649 branch 2 times, most recently from 7f3bc57 to 5a3bd59 Compare April 29, 2024 14:27
@shamser shamser changed the title HPCC-31649 New StSizePeakEphemeralStorage and StSizePeakSubgraphTemp look ahead HPCC-31649 New StSizePeakEphemeralDisk and StSizePeakTempDisk look ahead May 30, 2024
@shamser shamser force-pushed the issue31649 branch 2 times, most recently from 56580e5 to da22007 Compare May 30, 2024 12:32
@shamser shamser requested a review from jakesmith May 30, 2024 12:32
@shamser shamser marked this pull request as ready for review May 30, 2024 12:33
Copy link
Member

@jakesmith jakesmith left a comment

Choose a reason for hiding this comment

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

@shamser - looks good, but worth changing the linking semantics of CFileOwner (and e.g. leaving createSmartBuffer as it was).

And side-comments re. separate JIRA to track std. temp stats.

@@ -609,8 +607,7 @@ class CSmartRowInMemoryBuffer: public CSimpleInterface, implements ISmartRowBuff

ISmartRowBuffer * createSmartBuffer(CActivityBase *activity, const char * tempname, size32_t buffsize, IThorRowInterfaces *rowif)
{
Owned<IFile> file = createIFile(tempname);
return new CSmartRowBuffer(activity,file,buffsize,rowif);
return new CSmartRowBuffer(activity,createIFile(tempname),buffsize,rowif);
Copy link
Member

Choose a reason for hiding this comment

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

this is slightly at odds with the linking semantics of other utility classes, I think it better left as it was, where CSmartRowBuffer takes a link to the passed in IFile.

And, CFileOwner's iFile member is changed to a Linked, so it's consistent, and consitent with it's other Linked member). And then change the places that currently pass a linked file into CFileOwner to just pass the file and let it link.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change to CFileOwner: #18726

Copy link
Member

Choose a reason for hiding this comment

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

ok, let's merge that one 1st, then change this back.

@@ -182,7 +182,8 @@ class CSmartRowBuffer: public CSimpleInterface, implements ISmartRowBuffer, impl
size32_t left = nb*blocksize-mb.length();
memset(mb.reserve(left),0,left);
}
fileio->write(blk*(offset_t)blocksize,mb.length(),mb.bufferBase());
tempFileIO->write(blk*(offset_t)blocksize,mb.length(),mb.bufferBase());
tmpFileOwner.noteSize(numblocks*blocksize);
Copy link
Member

Choose a reason for hiding this comment

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

unrelated to this PR, but we're not capturing standard spill (temp) stats from this/these helper functions, i.e. StCycleSpillElapsedCycles, StTimeSpillElapsed, StSizeSpillFile ( NB: we do already in CThorRowCollectorBase )

Is there an existing JIRA? If not can you open one and link it to this/other JIRA's so it doesn't get lost?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

can you also link it to this JIRA and/or others (makes it easier to find in future)

@@ -1484,7 +1481,8 @@ class CSharedWriteAheadDisk : public CSharedWriteAheadBase
mb.append((byte)0);
size32_t len = mb.length();
chunk.setown(getOutOffset(len)); // will find space for 'len', might be bigger if from free list
spillFileIO->write(chunk->offset, len, mb.toByteArray());
tempFileIO->write(chunk->offset, len, mb.toByteArray());
tempFileOwner->noteSize(highOffset);
Copy link
Member

Choose a reason for hiding this comment

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

as per comment above. If there isn't one, we need a JIRA to add the basic spill(temp) stats.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -1536,7 +1533,8 @@ class CSharedWriteAheadDisk : public CSharedWriteAheadBase
freeChunks.kill();
freeChunksSized.kill();
highOffset = 0;
spillFileIO->setSize(0);
tempFileIO->setSize(0);
tempFileOwner->noteSize(0);
Copy link
Member

Choose a reason for hiding this comment

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

I don't know why this (the setSize(0)) was implemented this way.
I think it should just delete the file, and let it be recreated if it was needed.

(not a change for now in this PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jakesmith
Copy link
Member

@shamser - infact this also covers a hashdistribute spilling, which is also used as part of hash dedup (so https://hpccsystems.atlassian.net/browse/HPCC-28757 alone won't give a full picture of a hash dedup;s spilling).

Can you update this JIRA and it's PR title to mention that it covers hash distribute spilling as well?

@shamser shamser changed the title HPCC-31649 New StSizePeakEphemeralDisk and StSizePeakTempDisk look ahead HPCC-31649 New StSizePeakEphemeralDisk and StSizePeakTempDisk look ahead and hash distribute spilling Jun 3, 2024
@shamser shamser requested a review from jakesmith June 10, 2024 09:01
Copy link
Member

@jakesmith jakesmith left a comment

Choose a reason for hiding this comment

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

@shamser - looks good, but better to merge #18726 1st, then change the linking of the iFile back in createSmartBuffer before this is merged.

@@ -609,8 +607,7 @@ class CSmartRowInMemoryBuffer: public CSimpleInterface, implements ISmartRowBuff

ISmartRowBuffer * createSmartBuffer(CActivityBase *activity, const char * tempname, size32_t buffsize, IThorRowInterfaces *rowif)
{
Owned<IFile> file = createIFile(tempname);
return new CSmartRowBuffer(activity,file,buffsize,rowif);
return new CSmartRowBuffer(activity,createIFile(tempname),buffsize,rowif);
Copy link
Member

Choose a reason for hiding this comment

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

ok, let's merge that one 1st, then change this back.

@shamser shamser force-pushed the issue31649 branch 2 times, most recently from de5a065 to 84c3c04 Compare June 12, 2024 14:43
@shamser shamser requested a review from jakesmith June 12, 2024 14:43
Copy link
Member

@jakesmith jakesmith left a comment

Choose a reason for hiding this comment

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

@shamser - please see comments.

Owned<IFile> iFile = createIFile(spillName);
iFile->setShareMode(IFSHnone);
tempFileIO.setown(iFile->open(IFOcreaterw));
tempFileOwner.setown(new CFileOwner(iFile.getClear(), activity->queryTempFileSizeTracker()));
Copy link
Member

Choose a reason for hiding this comment

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

this now needs to be changed to avoid leaking iFile, e.g. to:

tempFileOwner.setown(new CFileOwner(iFile, activity->queryTempFileSizeTracker()));

fileio.clear();
file->remove();
}
if (tempFileIO)
Copy link
Member

Choose a reason for hiding this comment

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

trivial: no need to test

fileSizeTracker->growSize(size-fileSize);
else
fileSizeTracker->shrinkSize(fileSize-size);
fileSize = size;
Copy link
Member

Choose a reason for hiding this comment

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

If fileSizeTracker is not set, fileSize won't be updated. I think should be :

    if (fileSize!=size)
    {
        if (fileSizeTracker)
        {
            if (size > fileSize)
                fileSizeTracker->growSize(size-fileSize);
            else
                fileSizeTracker->shrinkSize(fileSize-size);
        }
        fileSize = size;
    }

( Gavin made a similar comment in this PR : #18573 (comment) )

@shamser
Copy link
Contributor Author

shamser commented Jun 14, 2024

@shamser - please see comments.

Some changes made in #18573 will mean that this PR will need to be updated. I'll update this PR once 18573 is merged. @jakesmith

@shamser shamser force-pushed the issue31649 branch 2 times, most recently from 4d40d35 to 2353100 Compare June 14, 2024 14:43
@shamser shamser requested a review from jakesmith June 14, 2024 14:45
Copy link
Member

@jakesmith jakesmith left a comment

Choose a reason for hiding this comment

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

@shamser - looks good.

@jakesmith
Copy link
Member

@shamser - there's a clash now, can you rebase

…k ahead and hash distribute spilling

Signed-off-by: Shamser Ahmed <[email protected]>
@ghalliday ghalliday merged commit 786aa0d into hpcc-systems:candidate-9.6.x Jun 14, 2024
21 of 23 checks passed
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