Is It Worth the Effort
The Silence of the Standards
Preemptive Multitasking and Priority-Based Scheduling
To reach interactivity at the earliest possible moment, the developer needs to be able to spin off tasks that can be executed after interactivity has been achieved. However, it is important that we be able to prioritize these tasks without jumping through too many hoops. Tasks that lead up to the point of interactivity, including above-the-fold images, are the highest priority. Tasks that populate the rest of the page are a lower priority. Third-party components and ads can be even lower. Tasks that download and cache components that will be used on the next page are last.Priority-based scheduling allows us to download the needed-now components before the needed-soon components, and the needed-soon components before the maybe-needed-latercomponents.Tasks that are assigned priorities and spun off can be executed sequentially (like they are now), but the order in which they are executed should be determined by their priority levels. Creating a priority-based scheduling system is a simple change to the EcmaScript standard, and it would make it easier for programmers to execute deferred code in the order that yields the best performance.Although parallel processing and preemptive multitasking are not strictly required for us to have priority-based scheduling, they are expected to further enhance performance. They can be added later, after we properly consider interprocess (or interthread) communication, atomicity, race conditions, and all the other complexities that go along with parallelism.
Preemptive multitasking and priority-based scheduling are already available in most operating systems. Perhaps this wheel does not have to be reinvented.
The Developer’s Role
Priority-based scheduling allows the developer to execute deferred code in the order that yields the best performance. This is a simple change to the EcmaScript standard.True parallelism, along with preemptive multitasking, will further enhance performance. Adding it to the standard is not quite as easy, so it should be done as a second step. Hooking into the operating system’s scheduler would save us from reinventing the wheel, but is this a viable approach?
Post Tagged with