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

Executor service fixes #3307

Closed
wants to merge 1 commit into from
Closed

Executor service fixes #3307

wants to merge 1 commit into from

Conversation

pepone
Copy link
Member

@pepone pepone commented Dec 26, 2024

Fix #3300

@pepone pepone requested a review from externl December 30, 2024 17:02
Comment on lines +91 to +93
10,
10,
1000,
Copy link
Member

Choose a reason for hiding this comment

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

what do these magic numbers refer to?

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

Ok, so the 1000 for keepAliveTime will have no effect here since we're setting core and max to 10.

@pepone pepone requested a review from bernardnormier January 7, 2025 16:11
Copy link
Member

@bernardnormier bernardnormier left a comment

Choose a reason for hiding this comment

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

I am concerned the original QueueExecutorService has a single thread by design, to ensure the jobs are serialized. Hard to say without comment. If it was by design, this PR is changing the design.

@@ -82,15 +82,19 @@ protected void afterExecute(Runnable t, Throwable e) {
private final ThreadObserverHelper _observerHelper;
}

// The thead pool executor uses an unbounded queue. The tasks would wait in the queue until a
// core pool thread is available to run it and the value of the maximumPoolSize therefore
// doesn't have any effect.
Copy link
Member

Choose a reason for hiding this comment

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

The comment is not clear.

Presumably, maximumPoolSize has not effect because the executor uses an unbounded queue? As written, it sounds like a consequence of the wait?

It's also not clear to me what this means / add:

The tasks would wait in the queue until a core pool thread is available to run it

This is not obvious?

@pepone
Copy link
Member Author

pepone commented Jan 7, 2025

If you look at when we use this executor there are two situations:

  • We want to allow interrupt threads
  • We are running on Android and need to avoid IO calls from UI thread

//
// If Ice.ThreadInterruptSafe is set or we're running on Android all
// IO is done on the background thread. For Android we use the queue
// executor as Android doesn't allow any network invocations on the main
// thread even if the call is non-blocking.
//
if (properties.getIcePropertyAsInt("Ice.ThreadInterruptSafe") > 0 || Util.isAndroid()) {
_queueExecutor =
new QueueExecutor(
properties, Util.createThreadName(properties, "Ice.BackgroundIO"));
_queueExecutorService = new QueueExecutorService(_queueExecutor);
// Caching message buffers is not supported with background IO.
_cacheMessageBuffers = 0;
} else {
_cacheMessageBuffers = properties.getIcePropertyAsInt("Ice.CacheMessageBuffers");
}

The interrupt case is about about ensuring that Java interrupt works correctly. See https://doc.zeroc.com/ice/latest/property-reference/miscellaneous-ice-properties#id-.MiscellaneousIce.*Propertiesv3.7-Ice.ThreadInterruptSafe

We have Ice/interrupt test in Java with seems to work fine with this PR.

In the android case this is about not calling IO APIs from the main thread, and unrelated to serialization.

I guess it would be safer to just change the behavior for Android, as this doesn't seems necessary for the other use case.

@pepone pepone closed this Jan 9, 2025
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.

MaxConnection tests Android failure
3 participants