We use cookies to improve your experience with our site.

Unified UDispatch: A User Dispatching Tool for Multicore Systems

  • 摘要: 一、 动机与想法
    在现今的多核心系统平台上,通常会使用多线程的方式来增加应用程序的平行度以增进其执行效能。然而,在许多简单的应用程序里,有时候使用多线程反而会使得效能降低而不如预期。使用者通常会认为是因为线程的管理导致有时候增加线程数目效能却不升反降。在我们的实验观察中,最重要的影响因素却是在于如何分派这些线程到适当的硬件核心上。我们把这分派不佳的异常状况称为线程异常 (thread anomalies)。
    线程异常大致上可分三种,第一种称为 threading anomaly。这种异常发生在当增加线程时,使得整体的执行时间变长,而造成效能下降。第二种异常是由于操作系统没有将线程排到适当的核心上,导致程序结束时间延后,称为 scheduling anomaly。而第三种异常是当一单一线程的应用程序改写成多线程时,其执行时间不减反增,所以造成效能下降,称为 main-thread anomaly。
     造成这些异常的主要原因是操作系统通常并不知道应用程序确切的执行时间长短、比例、或优先权。排程算法可能为了省电与效能相冲突,或是尚未到达启动重新排程的负载上限程序就已结束。此外一旦线程被分派后,通常不会再被迁移至另外的核心上执行。
    二、 方法
    在有限的系统信息下很难侦测到线程异常。即便能侦测到此现象,若操作系统不能提供足够的机制与信息,使用者也无能为力。因此,我们开发了一套使用者分派机制 (User Dispatching Mechanism: UDispatch),能在使用者层级控制线程,也能获得系统相关的信息。但是为了不修改核心,我们利用虚拟装置当作使用者与操作系统之间的桥梁。此外,我们还提供API 与编程范例,让使用者更方便地与操作系统沟通。
    为了避免像UDispatch必须修改原始程序,我们修改 fork() 系统呼叫来开发不需修改原始程序且效能相近的UDispatch+ 以辅助 UDispatch,并提供编程范例。
     为了让 UDispatch 与 UDispatch+ 能更有效率地合作且达到高可移植性,我们透过操作系统抽象层 (operating system abstraction layer, OSAL) 设计出一套整合两者以提供更为简单与完整的机制 (Unified UDispatch, UUD)。
    我们将 UDD 套用在多线程多媒体应用程序来验证效能。结果高平行度的二元图像编码器可加速约 112%,平行度较低的 H.264 译码器可加速约 20%。
    我们分析线程异常的出现频率。大约有 40% 至50% 的机率会发生 threading anomaly;而 scheduling anomaly 则高达 90% 以上。此外,UUD 的信息存取比 procfs机制快约 3.48 倍。由于 UDispatch 与 UDispatch+ 可根据不同应用而套用,我们也针对像是弹性、方便性、效能、额外花费及实时性…等进行比较。
     
    三、 贡献
    1. 我们探讨线程在多核心系统上执行的行为,并定义了线程异常。
    2. 为了处理线程异常,我们提出了一套使用者分派机制 (UDispatch) 在使用者层级更有效率地取得核心信息与控制线程。
    3. 为了避免像UDispatch必须修改原始程序,我们提供编程范例并开发效能相近的UDispatch+ 以辅助 UDispatch。
    4. 整合 UDispatch 与 UDispatch+ 成为一套工具 (Unified UDispatch),让整套机制更加完善且方便可携并在多核心平台上以多媒体应用程序验证其可行性与效能。

     

    Abstract: In multicore environment, multithreading is often used to improve application performance. However, even in many simple applications, the performance might degrade when the number of threads increases. Users usually impute this phenomenon to the overhead of creation or termination of threads. In our observation, how the threads are dispatched to the multiple cores might have a more significant effect. We formally defined the problems on using threads as multithreading anomalies, and presented a novel user dispatching mechanism (UDispatch) which provides controllability in user space to improve application performance. Through modification of application source codes with the UDispatch application programming interface (API), the application performance can be improved significantly. However, since the application source codes might not be available or it might be too complicated to modify application source codes, we provided an extension, called UDispatch+, to dispatch threads without any modification of application source codes. In this paper, the UDispatch and UDispatch+ are integrated and wrapped for more portability and introduced as a tool called Unified UDispatch (UUD) with more detailed experiments and description. It can dispatch the application threads to specific cores at the discretion of users with up to 171.8% performance improvement on a 4-core machine.

     

/

返回文章
返回