[新闻] dactor项目
qiezi
2009-05-15
去掉了writefln,抓到点堆栈:
(gdb) thread 1 [Switching to thread 1 (Thread 0xf7d5a6e0 (LWP 4324))]#1 0xf7ef229c in __lll_unlock_wake () from /lib32/libpthread.so.0 (gdb) bt #0 0xf7f13430 in __kernel_vsyscall () #1 0xf7ef229c in __lll_unlock_wake () from /lib32/libpthread.so.0 #2 0xf7eee93b in _L_unlock_94 () from /lib32/libpthread.so.0 #3 0xf7eee53c in __pthread_mutex_unlock_usercnt () from /lib32/libpthread.so.0 #4 0x08051a34 in _d_monitor_unlock () #5 0x0804d80a in _d_monitorexit () #6 0x0804982b in _D4core6thread6Thread5startMFZv () #7 0x0804a1d7 in _D4core6thread11ThreadGroup6createMFDFZvZC4core6thread6Thread () #8 0x080492b7 in _D10test_fiber9Scheduler3runMFiZv () #9 0x080494c1 in _Dmain () #10 0x0804b534 in _D2rt6dmain24mainUiPPaZi7runMainMFZv () #11 0x0804b33d in _D2rt6dmain24mainUiPPaZi7tryExecMFMDFZvZv () #12 0x0804b576 in _D2rt6dmain24mainUiPPaZi6runAllMFZv () #13 0x0804b33d in _D2rt6dmain24mainUiPPaZi7tryExecMFMDFZvZv () #14 0x0804b2e8 in main () (gdb) thread 2 [Switching to thread 2 (Thread 0xf7c4eb90 (LWP 4327))]#0 0xf7f13430 in __kernel_vsyscall () (gdb) bt #0 0xf7f13430 in __kernel_vsyscall () #1 0xf7ef1875 in sem_wait@@GLIBC_2.1 () from /lib32/libpthread.so.0 #2 0x080515b3 in _D4core6thread17thread_suspendAllUZv7suspendMFC4core6thread6ThreadZv () #3 0x08051506 in thread_suspendAll () #4 0x0805021c in _D2gc3gcx3Gcx11fullcollectMFPvZk () #5 0x080501fa in _D2gc3gcx3Gcx16fullcollectshellMFZk () #6 0x0804e72d in _D2gc3gcx2GC12mallocNoSyncMFkkZPv () #7 0x0804e685 in _D2gc3gcx2GC6mallocMFkkZPv () #8 0x0804dfcc in gc_malloc () #9 0x0804b9b5 in _d_arrayappendcT () #10 0x0804933e in _D10test_fiber34__T9SyncQueueTC4core6thread5FiberZ9SyncQueue4pushMFC4core6thread5FiberZv () #11 0x0804930a in _D10test_fiber9Scheduler4procMFZv () #12 0x08049f09 in _D4core6thread6Thread3runMFZv () #13 0x0805125f in thread_entryPoint () #14 0xf7eeb4ff in start_thread () from /lib32/libpthread.so.0 #15 0xf7e41b9e in clone () from /lib32/libc.so.6 看来和数组操作时gc暂停线程有关,抓到几次不同的情况,但总有一个线程在gc_malloc |
|
qiezi
2009-05-15
这段代码也很简洁了,提交过去问下吧,怀疑是Fiber实现上的bug,以前测试过ucontext是没问题的
|
|
qiezi
2009-05-17
想把Fiber修改一下,目前的call方式,虽然方便了scheduler的编写,但每一次切换都要切回调用进程(这可以减少编程的错误),对应的是switchIn/switchOut,调用2次fiber_switchContext,所以性能下降了一倍。可以直接从一个fiber切到另一个fiber,这样目前我测试的每秒最高577万次的切换性能应该可以提高到1140万次,高出erlang非常多。
|
|
davesun
2009-05-18
哈哈,直接从一个fiber切到另一个就是真正的协程了,D的fiber只能叫半协程。
我测试了我的那段代码,确实是还有问题!看来是fiber的实现有问题。 持续关注你的dactor,祝你成功qiezi! |
|
qiezi
2009-05-21
最新进度:
机制的封装较为简单,比如纳入AIO/IO Event,封装成库则比较花时间,特别是要抽像出Socket Address类这种繁琐的工作(phobos里面的没有开放sockaddr),目前并没有在这方面下功夫,优先完成较大的特性。 |