<html><body><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div><br></div><div>Hello Yuri</div><div><br></div><div>El vie, 25-11-2016 a las 01:08 +0200, Yuri Benditovich escribió:</div><blockquote><div dir="ltr"><div><div><span style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px">I'm porting to [qxl-wddm-dod] set of flexvdi changes</span><br></div></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt">related to execution of '</span><span style="font-size:12pt">present display only' events</span></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt">in separate thread. There are 2<b> questions below</b> I'd like to ask and k</span><span style="font-size:12pt">now your opinion.</span></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt"><br></span></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt">I see there 2 aspects:</span></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt">- reliability</span></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt">- performance</span></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><br></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt"><span data-mce-style="text-decoration: underline;" style="text-decoration: underline;">Reliability:</span></span></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt">I see in flexvdi mailing list existing report of</span></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt">BSOD upon system shutdown. Possible cause is lack of</span></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt">synchronization between system flows, hardware availability and worker thread state </span><span style="font-size:12pt">(last patch in flexvdi 'Terminate working thread on exit' </span><span style="font-size:12pt">introduces termination procedure but nobody calls it, </span><span style="font-size:12pt">as I can see)</span></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt">The lack of synchronization may cause also races in</span></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt">power</span><span style="font-size:12pt"> management flows and (possible) on changing</span></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt">operating mode.</span></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt"><br></span></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><strong><span style="font-size:12pt">Question 1:</span></strong></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><strong><span style="font-size:12pt">Do you have some additional recommendation which</span></strong></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><strong><span style="font-size:12pt">flows shall be specially checked for races with</span></strong></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><strong><span style="font-size:12pt">rendering thread?</span></strong></div></div></blockquote><div><br></div><div>Unfortunately, the truth is, we have not thoroughly tested our code to remove these races yet. The clients this driver was intended for are still stuck using Windows XP/7, and our development is stalled. So, I cannot think of any situation you should check that you do not know about yet.</div><div><br></div><blockquote><div dir="ltr"><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><br></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt"><span data-mce-style="text-decoration: underline;" style="text-decoration: underline;">Performance:</span></span></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt">It looks like </span>the change should not affect total CPU consumption for</div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px">the rendering, it splits more or less the same operations over</div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px">2 different threads. <span style="font-size:12pt">It is still possible that the </span><span style="font-size:12pt">change can improve</span></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt">common user experience </span><span style="font-size:12pt">due to </span><span style="font-size:12pt">faster indication of operation completion to </span><span style="font-size:12pt">the OS.</span></div></div></blockquote><div><br></div><div>We were not trying to reduce total CPU consumption. After all, the driver just copies rects from main memory to VRAM and passes them to the spice server; there is little to reduce there. Rather, we tried to increase the throughput of graphic operations, by not locking the DirectX subsystem while we wait for the spice server to accept new drawables. That is, we do not mind using more CPU if that results in painting faster.</div><div>On the other hand, I was thinking that maybe we could get the DirectX subsystem to provide the rects already in VRAM if we described it as a linear memory segment on driver initialization. In that way, the copying operation could also be removed. However, I am not sure if this actually works or even how to do it, it is just an idea.</div><div><br></div><blockquote><div dir="ltr"><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><strong><span style="font-size:12pt"><br></span></strong></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><strong><span style="font-size:12pt">Question 2:</span></strong></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><strong><span style="font-size:12pt">Do you have some ideas how to make quantitive</span></strong></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><strong><span style="font-size:12pt">evaluation of this possible </span></strong><strong style="font-size:12pt"><span style="font-size:12pt">improvement of user experience? </span></strong></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt"><br></span></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt">I think about: </span></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt">- finding scenarios when we receive </span><span style="font-size:12pt">rendering calls (PresentDisplayOnly) when the worker </span><span style="font-size:12pt">thread is still processing previous operation. If they exist this can mean that some bottleneck solved in GDI.</span></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt">- writing or getting tool that loads the graphics</span></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt">adapter by heavy operations (like continuos moving of window / scrolling etc) with CPU consumption measurement</span></div></div></blockquote><div><br></div><div>We used a simple tool to measure the performance: it creates a window and continuously issues WM_PAINT events where the full background is filled with color, then measures the number of processed events per second (not CPU). It is quite naive, but it provides a good starting reference, since the tool, with the XDDM QXL driver in Windows 7, outputs almost twice as much paint events as executing it in Windows 8 with the WDDM QXL driver. There are other measurements you can try to obtain, like how much time does it take until a paint event gets to the spice server queue, ready to be sent to the client (although I'm not sure how to measure it). This delay affects the user perception of performance.</div><div><br></div><blockquote><div dir="ltr"><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><br></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><br></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt">Please share your thoughts.</span></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px"><span style="font-size:12pt"><br></span></div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px">Thanks,</div><div style="color:rgb(0,0,0);font-family:"courier new",courier,monaco,monospace,sans-serif;font-size:16px">Yuri</div></div></blockquote></blockquote><div>If you don't call StopPresentThread to stop the thread and you free the class the thread will continue</div><div>to run accessing freed data.Possibly even the code thread is executing is unloaded from memory too</div><div>so the crash is quite expected (didn't look at the code before). It seems to me that data is correctly<br></div><div>synchronized, mainly the usage of the ring is shared.<br></div><div><br></div><div>Personally I would avoid the usage of m_TerminateThread and push a NULL as drawables so sign<br></div><div>that worker thread should close. This will also avoid leaks if there are still pending drawables in the<br></div><div>ring.<br></div><div>m_PresentLock looks useless.<br></div><div><br></div><div>Frediano<br></div><div><br></div></div></body></html>