iotdb icon indicating copy to clipboard operation
iotdb copied to clipboard

Improve SessionPoolExample by replacing unbounded fixed thread pool with bounded ThreadPoolExecutor

Open anusha975 opened this issue 8 months ago • 6 comments

Search before asking

  • [x] I searched in the issues and found nothing similar.

Motivation

I am sometimes frustrated when using the IoTDB CLI because the output of certain commands is difficult to read when the result set is large. The CLI currently prints results in a plain format which may be harder to interpret for users analyzing time-series data interactively.

Improving the CLI output formatting (for example better alignment or optional table-style display) would improve usability, especially for users exploring IoTDB from the command line.

Solution

One possible solution is to improve the CLI output formatting by introducing a table-style display for query results.

For example, results could be formatted with aligned columns and clearer separators so that timestamps and values are easier to read.

Additionally, an optional CLI flag (for example --pretty) could allow users to enable or disable enhanced formatting depending on their preference.

The implementation could be handled in the CLI output handling logic located in:

iotdb-client/cli/src/main/java/org/apache/iotdb/cli

Alternatives

An alternative approach could be to keep the current output format but allow users to export query results directly to formats such as CSV or JSON for easier processing in external tools.

However, improving the CLI display would provide a better interactive experience directly within the terminal.

Are you willing to submit a PR?

  • [x] I'm willing to submit a PR!

anusha975 avatar Mar 07 '26 12:03 anusha975

I have submitted a Pull Request (#17287) to optimize the thread pool in SessionPoolExample.

The implementation now uses a bounded ThreadPoolExecutor with an ArrayBlockingQueue and CallerRunsPolicy to prevent potential OOM issues and ensure better resource management. Please review the changes.

ShauryaChauhan1411 avatar Mar 11 '26 18:03 ShauryaChauhan1411

Hi, thank you for the update.

I noticed that you have submitted PR #17287 for optimizing the thread pool in SessionPoolExample. My PR #17268 also proposes replacing the unbounded fixed thread pool with a bounded ThreadPoolExecutor to prevent potential OOM issues and improve resource management.

Please let me know if there are any differences you would like me to address or if any modifications are needed in my PR. I’d be happy to update it accordingly. Thank you!

anusha975 avatar Mar 12 '26 05:03 anusha975

Hi @anusha975, I've shared my PR (#17287) as a solution for this issue. I have used a ThreadPoolExecutor with an ArrayBlockingQueue and specifically a CallerRunsPolicy. Using CallerRunsPolicy is crucial here because it provides backpressure—it makes the caller thread execute the task when the queue is full, preventing the application from being overwhelmed.

ShauryaChauhan1411 avatar Mar 12 '26 05:03 ShauryaChauhan1411

Hi @ShauryaChauhan1411, thank you for the clarification and explanation.

I understand that using CallerRunsPolicy provides backpressure and helps prevent the application from being overwhelmed, which is an important consideration.

Since your PR (#17287) already implements this approach, I am happy to close my PR (#17268) to avoid duplication. Please let me know if you think any additional contribution from my side would be helpful.

Thank you!

anusha975 avatar Mar 12 '26 06:03 anusha975

Hi @anusha975 , thank you for the support and for understanding the approach! I appreciate your willingness to collaborate to avoid duplication.

Your PR also highlighted the importance of this fix, and it's great that we're on the same page regarding the CallerRunsPolicy and resource management. Looking forward to more such collaborations in the IoTDB community. Thanks again!

ShauryaChauhan1411 avatar Mar 12 '26 13:03 ShauryaChauhan1411

Hi @ShauryaChauhan1411 , thank you for the clarification and explanation!

I understand that using CallerRunsPolicy provides backpressure and helps prevent the application from being overwhelmed. Since your PR (#17287) already implements this approach, I’m happy to close my PR (#17268) to avoid duplication.

Please let me know if there’s any other way I can contribute or if additional improvements are needed. Looking forward to collaborating more in the IoTDB community. Thanks again!

anusha975 avatar Mar 12 '26 16:03 anusha975