wsky / top-link

embedded duplex multi-channel endpoint and connection management for c#/java/...
6 stars 1 forks source link

make scheduler support batch process for certain task #69

Closed wsky closed 11 years ago

wsky commented 11 years ago

some kind of task is lightweight and has many,

process one task per thread will course large cost at thread switch, threadpool size will alwasy not enough.

so, we need batch them, process more than one task per thread

wsky commented 11 years ago

39

wsky commented 11 years ago

endpoint should support schedule certain type of task by msg.messageType

https://github.com/wsky/top-link/blob/c6fdce2b16aa9c3a715b9669ea0331c6d2ca891e/java/src/main/java/com/taobao/top/link/endpoint/EndpointChannelHandler.java#L143

// dispatch
        this.scheduler.schedule(msgFrom, new Runnable() {
            @Override
            public void run() {
                try {
                    internalOnMessage(context, msg, msgFrom);
                } catch (LinkException e) {
                    logger.error(e);
                }
            }
        });
wsky commented 11 years ago

scheduler's job looks like actor does. :)

wsky commented 11 years ago

TODO: test perf on batched lightweight task

wsky commented 11 years ago

37

wsky commented 11 years ago

in EndpointPerf test, using BatchedScheduler, server will have low cpu cost, but if batchSize is so large, 1000, client got execution timeout

wsky commented 11 years ago

in some case, it's about balance problem, that server have fixed biz threadpool, 400 e.g.

lightweight request maybe fill them at moment, then other request maybe hold or reject, batch maybe make it more balanced,

or, maybe we need add different thread pool for differentr request, make it easy.

wsky commented 11 years ago

if we provided async io operation to task, like nix_lua coroutine does,