Konstantin Orlov created IGNITE-23682:
-----------------------------------------

             Summary: Sql. Avoid unnecessary task scheduling for simple plan
                 Key: IGNITE-23682
                 URL: https://issues.apache.org/jira/browse/IGNITE-23682
             Project: Ignite
          Issue Type: Improvement
          Components: sql
            Reporter: Konstantin Orlov


KvPlan unconditionally schedules completion of prefetch callback to another 
thread pool:
{code:java}
// KeyValueGetPlan.java
public <RowT> AsyncCursor<InternalSqlRow> execute(...) {
    ...
    if (firstPageReadyCallback != null) { // firstPageReadyCallback is never 
null
        Executor executor = task -> ctx.execute(task::run, 
firstPageReadyCallback::onPrefetchComplete);

        result.whenCompleteAsync((res, err) -> 
firstPageReadyCallback.onPrefetchComplete(err), executor);
    }
    ...
{code}
The problem is that for single statement read operations this callback is not 
used, yet scheduling results in moderate performance penalty. Below are results 
acquired on MBP M3 simply replacing {{result.whenCompleteAsync}} --> 
{{{}result.whenComplete{}}}:
{code:java}
Before
Benchmark               (clusterSize)  (fsync)  Mode  Cnt  Score   Error  Units
SelectBenchmark.sqlGet              1    false  avgt   20  9.056 ± 0.407  us/op

After 
Benchmark               (clusterSize)  (fsync)  Mode  Cnt  Score   Error  Units
SelectBenchmark.sqlGet              1    false  avgt   20  6.236 ± 0.448  us/op
{code}
Let's revise usage of prefetchCallback and get rid of unnecessary scheduling, 
when possible.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to