mirror of
https://github.com/gomson/TimothyLottes.github.io.git
synced 2026-11-14 10:10:07 -08:00
Add files via upload
This commit is contained in:
1 parent
8d23cd1435
commit
82d08406fe
2 files changed
+10
No files matched your search
@@ -0,0 +1,9 @@
|
||||
<html><head><link rel="stylesheet" href="style.css"></head><body><div class="page">
|
||||
<h1>20090604 - Thread Scheduling Part 2</h1>
|
||||
<br>
|
||||
|
||||
<i>Part 2 is all about the IO side of Thread Scheduling, CPU IO in a parallel world.</i><br /><br /><b>Review, Blocking vs Non-Blocking</b><br /><br />BLOCKING - Thread which issues the IO call is put to sleep until the operation is "finished". At some point in the IO call, a kernel call is made (to service the IO request) which results in a run-level task switch to kernel mode. In kernel mode, the kernel queues the IO request, sleeps the calling thread and does a task switch to another runnable thread. At some point later after the kernel services the IO request, the original thread (which issued the IO) is again scheduled to run (latency can be a function of IO latency plus how often the blocking thread gets rescheduled to run).<br /><br />LIKELY BLOCKING, POSSIBLY NON-BLOCKING - In the case of reads, sometimes the data is cached (perhaps disk cache) and thus the IO call can be serviced right away. This can also be the case for writes when the kernel call copies the write request to a queue (or to the page cache) and immediately returns (note when queue is full or page isn't in page cache, kernel call can become a blocking call).<br /><br />MOST LIKELY NON-BLOCKING, POSSIBLY BLOCKING - This is the troubling case where an interface is almost completely non-blocking, but has some caveats. Caveats in that the interface doesn't return some error code indicating that the call would block. Often this is the case when buffer or queue space is full. The v-sync section in the previous post is a good example of this!<br /><br />NON-BLOCKING - Correct fully non-blocking API, if a call would block, the call returns with an error code. Non-blocking APIs might provide a polling function to return the status of pending operations. Non-blocking APIs might also provide a callback interface. In this case a user supplied function is called on pending IO. Callback interface can be lower latency at the expense of loosing control over job synchronization.<br /><br /><br /><b>Disk Access Re-ordering To Reduce Seek Time</b><br /><br />All operating systems which have good file IO performance on rotating disc based storage do this (else performance would suck worse than it does now). The operating system queues up the disk accesses required to service the file IO (virtual memory IO, etc) from all processes and threads, and orders the accesses to reduce seek time.<br /><br />This should be kept in mind when thinking about application file IO. It is often smart to queue up file IO requests from many files at once, instead of just following the read->process->read->process model. Likewise, having just one asych thread servicing file requests using a blocking interface might not yield the best throughput depending on access patterns. <br /><br /><br /><b>Read Ahead</b><br /><br />The operating system provides a read-ahead mechanism which attempts to predict which pages will be needed in the future (based on past access patterns) and effectively adds future requests to current requests when reading from the device. In some cases (Linux) it can get various patterns like sequential + stride, etc.<br /><br /><br /><b>Why Your Desktop User Experience Is Often a Waiting Game</b><br /><br />(1.) Same thread processing the application "GUI" event queue does file IO. Epic Fail!<br /><br />(2.) Application is creating a huge data structure, it writes into memory which was just allocated, but hasn't yet been mapped to physical pages by the OS. System is under heavy load, and not enough non-dirty pages are available to discard. Operating system needs to write out dirty pages to disc to provide pages for the application to write to. Application blocks until disc IO is finished on the dirty pages. Epic Fail!<br /><br />(3.) Application suffers from code bloat. App could even be tiny but suffer from a bloated hierarchy of dynamic link libraries. Non-accessed code likely isn't resident (or if loaded, was paged out to provide space for something else). Example, user clicks on menu and opens up a seldom used dialog, paged-out code is accessed, and App blocks on file IO. Epic Fail!<br /><br />(4.) Application access a huge number of small files, all with long path names (think bloated file structure with huge number of files per directory). Seek nightmare for two reasons, first just accessing the (possibly uncached) directory structure to find the files, and second accessing the (likely uncached) files. Epic Fail!<br /><br />Solving the first case is just good application design. Solving the third case is expert application design. One has to insure all GUI or user-input processing is in a small core amount of common code (and data) which will always be resident (often accessed likely equals always resident). Possibly blocking functions (ie ones which might access code which is seldom called, ie which is paged out) needs to be done in an asynchronous thread. This way the app is always responsive!<br /><br /><i>Point here is anything which might resulLine truncated
|
||||
|
||||
</div></body></html>
|
||||
|
||||
|
||||
@@ -189,6 +189,7 @@ O OOO ||..||OO||||||||||OOo || ||||||||||||| ||||OO|| |o| ||||||||OO||OOO
|
||||
<br>
|
||||
<b>2009</b><br>
|
||||
<a href="20090605.html">20090605 - SIMD Binning And Caches</a><br>
|
||||
<a href="20090604.html">20090604 - Thread Scheduling Part 2</a><br>
|
||||
<a href="20090602.html">20090602 - Thread Scheduling Part 1</a><br>
|
||||
<br>
|
||||
<a href="20090519.html">20090519 - GPU REYES</a><br>
|
||||
|
||||
Reference in new issue
Block a user