Skip to content

HPCC-30007 Introduce CPooledPersistent and "pooled" sink mode in roxie #17636

Merged
ghalliday merged 1 commit intohpcc-systems:candidate-2.0.xfrom
ghalliday:issue30007
Jan 9, 2026
Merged

HPCC-30007 Introduce CPooledPersistent and "pooled" sink mode in roxie #17636
ghalliday merged 1 commit intohpcc-systems:candidate-2.0.xfrom
ghalliday:issue30007

Conversation

@ghalliday
Copy link
Copy Markdown
Member

@ghalliday ghalliday commented Aug 1, 2023

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:

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Aug 1, 2023

@ghalliday
Copy link
Copy Markdown
Member Author

This isn't ready to merge, but I think it would be worthwhile discussing the advantages/disadvantages before cleaning it up.

Copy link
Copy Markdown
Member

@richardkchapman richardkchapman left a comment

Choose a reason for hiding this comment

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

Initial comments

Comment thread system/jhtree/jhtree.cpp Outdated
CNodeMapping * next = nullptr;
};

typedef OwningSimpleHashTableOf<CNodeMapping, CKeyIdAndPos> CNodeTable;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems unrelated

Comment thread roxie/ccd/ccdserver.cpp Outdated

//=================================================================================

#define NEW_RESTARTABLE_THREAD
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this be testing NEW_THREADEDPERSISTENT?

I assume it's in here so that we implement IThreaded and can thus make use of the noew global thread pool code...

Comment thread roxie/ccd/ccdserver.cpp Outdated
else if (!probeManager && !graphDefinition.isSequential() && sinkMode != SinkMode::Sequential)
{
if (sinkMode == SinkMode::ParallelPersistent || sinkMode == SinkMode::AutomaticPersistent)
if (sinkMode == SinkMode::ParallelPersistent || sinkMode == SinkMode::AutomaticPersistent || true)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should be || NEW_THREADEDPERSISTENT ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(or words to that effect)

Comment thread system/jlib/jthread.cpp

// CThreadedPersistent
#ifdef NEW_THREADEDPERSISTENT
class GlobalThreadPool : public CInterfaceOf<IThreadFactory>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The JIRA mentioned that the global thread pool was to gradually shrink over time if threads went unused. I don't see any code here that would do that.

Copy link
Copy Markdown
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.

@ghalliday - a few comments.

Comment thread roxie/ccd/ccdserver.cpp Outdated

#define NEW_RESTARTABLE_THREAD
#ifdef NEW_RESTARTABLE_THREAD
class RestartableThread : public CInterface, public IThreaded
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

CInterfaceOf to avoid a vmt ?

Comment thread system/jlib/jthread.cpp
GlobalThreadPool()
{
IExceptionHandler *exceptionHandler = nullptr;
unsigned defaultmax = 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

so currently pool is unbound

Comment thread system/jlib/jthread.cpp Outdated
unsigned delay = 0;
unsigned stacksize = 0; // i.e. default;
unsigned timeoutOnRelease = 0;
unsigned targetpoolsize = 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

and targetpoolsize will default to defaultmax == 0, meaning it will not scale down

For the replacement of existing CThreadedPersistent semantics, where there is no upper limit to # of threads,
should defaultmax be left as 0, but targetpoolsize be set to something highish but low enough to reduce threads from peak ?

Comment thread system/jlib/jthread.cpp

void CThreadedPersistent::start()
{
//MORE: Pass this instead of owner and catch exceptions in this class for later reporting?
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it's unfortunate that the IExceptionHandler doesn't pass the handle back..
Or, the threadpool::join method should throw the exception if there is no handler..

Comment thread system/jlib/jthread.cpp
{
if (!joined)
{
globalThreadPool.join(handle, timeout);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the pool impl. of join should be changed to throw if there is no IExceptionHandler.

Copy link
Copy Markdown
Contributor

@mckellyln mckellyln left a comment

Choose a reason for hiding this comment

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

I think roxie sink can create 5000+ threads in a very short time, we should have idle threads go away after some amount of time.

@ghalliday ghalliday changed the base branch from candidate-9.2.x to candidate-2.0.x October 23, 2025 10:48
@ghalliday ghalliday force-pushed the issue30007 branch 2 times, most recently from c9ee4bd to 94e9d96 Compare October 29, 2025 09:27
@ghalliday ghalliday requested a review from jakesmith November 12, 2025 17:24
@ghalliday ghalliday marked this pull request as ready for review November 12, 2025 17:24
Copilot AI review requested due to automatic review settings November 12, 2025 17:24
@ghalliday
Copy link
Copy Markdown
Member Author

@jakesmith I am not convinced that this really helps - I tried running thor using it and the timings were insignificant.
I might try running the performance suite tests that are designed to cause problems.
However, as it stands I don't think it will change any existing behaviour, and it would allow us to test roxie using the different modes.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
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.

@ghalliday - not sure what the state of this PR is.
There are some v. old comments of mine/others.

It will not be used by default, correct?
Can it be rebased onto master ?

@ghalliday ghalliday force-pushed the candidate-2.0.x branch 2 times, most recently from cb6d603 to 4462083 Compare December 5, 2025 10:49
@ghalliday ghalliday force-pushed the candidate-2.0.x branch 2 times, most recently from 9acfb9e to cb2622f Compare December 12, 2025 14:04
@ghalliday ghalliday force-pushed the issue30007 branch 3 times, most recently from ffa04c4 to 7f5aa3f Compare January 6, 2026 14:16
@ghalliday ghalliday changed the title HPCC-30007 Use a global thread pool for CThreadedPersistent HPCC-30007 Introduce CPooledPersistent and "pooled" sink mode in roxie Jan 6, 2026
@ghalliday ghalliday requested a review from jakesmith January 6, 2026 14:19
@ghalliday
Copy link
Copy Markdown
Member Author

@jakesmith I think this is ok to merge - it should not have any effect unless the "pooled" sink mode is used.

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Copy link
Copy Markdown
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.

@ghalliday - looks good afaics.

@ghalliday ghalliday merged commit bbc7b68 into hpcc-systems:candidate-2.0.x Jan 9, 2026
49 of 52 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.

5 participants