Computer Latency: 1977-2017

I’ve had this nagging feeling that the computer programs I exhaust nowadays in actuality feel slower than the computer programs I mature as a child. As a rule, I don’t believe this roughly feeling because human perception has been shown to be unreliable in empirical reports, so I carried round a high-flee digital camera and measured the response latency of devices I’ve flee into in the past few months. Listed below are the results:

These are exams of the latency between a keypress and the divulge of a character in a terminal (explore appendix for extra well-known facets). The implications are sorted from quickest to slowest. In the latency column, the background goes from green to yellow to pink to unlit as devices get slower and the background will get darker as devices get slower. No devices are green. When multiple OSes had been tested on the similar machine, the os is in plucky. When multiple refresh charges had been tested on the similar machine, the refresh fee is in italics.

In the 365 days column, the background will get darker and pink-er as devices change into outdated. If older devices had been slower, we’d explore the 365 days column get darker as we learn down the chart.

The subsequent two columns indicate the clock flee and collection of transistors in the processor. Smaller numbers are darker and blue-er. As above, if slower clocked and smaller chips correlated with longer latency, the columns would get darker as we crawl down the table, but it undoubtedly, if the relaxation, appears to be like to be the unsuitable device round.

For reference, the latency of a packet going around the globe via fiber from NYC reduction to NYC via Tokyo and London is inserted in the table.

If we glimpse at total results, the quickest machines are susceptible. Newer machines are in every single situation. Esteem gaming rigs with surprisingly high refresh-fee displays are nearly aggressive with machines from the unhurried 70s and early 80s, but “usual” popular computer programs can’t compete with thirty to forty 365 days primitive machines.

We are able to additionally glimpse at mobile devices. In this case, we’ll glimpse at scroll latency in the browser:

As above, the results are sorted by latency and color-coded from green to yellow to pink to unlit as devices get slower. Also as above, the 365 days will get pink-er (and darker) as the software will get older.

If we exclude the game boy colorwhich is a assorted class of software than the the relaxation, the full quickest devices are Apple telephones or capsules. The subsequent quickest software is the blackberry q10. Even supposing we don’t possess sufficient records to in actuality verbalize why the blackberry q10 is surprisingly fleet for a non-Apple software, one plausible guess is that it’s helped by having accurate buttons, which would be more uncomplicated to place into effect with low latency than a touchscreen. The opposite two devices with accurate buttons are the gameboy color and the kindle 4.

After that iphones and non-kindle button devices, we possess a diversity of Android devices of assorted ages. On the underside, we possess the susceptible palm pilot 1000 followed by the kindles. The palm is hamstrung by a touchscreen and divulge created in an era with worthy slower touchscreen technology and the kindles exhaust e-ink displays, which would be worthy slower than the displays mature on popular telephones, so it’s no longer unpleasant to glimpse these devices at the underside.

Why is the apple 2e so mercurial?

As in contrast with a up to date computer that’s no longer the newest ipad prothe apple 2 has critical advantages on each the enter and the output, and it additionally has an earnings between the enter and the output for all however the most moderately written code for the reason that apple 2 doesn’t must address context switches, buffers interested by handoffs between assorted processes, and loads others.

On the enter, if we glimpse at popular keyboards, it’s popular to glimpse them scan their inputs at 100 Hz to 200 Hz (eg, the ergodox claims to scan at 167 Hz). By comparison, the apple 2e successfully scans at 556 Hz. Survey appendix for well-known facets.

If we glimpse at the opposite discontinuance of the pipeline, the divulge, we are able to additionally get latency bloat there. I undoubtedly possess a divulge that advertises 1 ms switching on the box, but when we glimpse at how lengthy it takes for the divulge to in actuality indicate a character from in case that you just can well presumably first explore the designate of it on the veil till the character is solid, it ought to without concerns be 10 ms. That you just may maybe also even explore this enact with some high-refresh-fee displays which would be equipped on their allegedly correct latency.

At 144 Hzeach frame takes 7 ms. A switch to the veil can possess 0 ms to 7 ms of further latency as it waits for the next frame boundary sooner than getting rendered (on common,we query half of the maximum latency, or 3.5 ms). On high of that, even supposing my divulge at home advertises a 1 ms switching time, it undoubtedly appears to take hang of 10 ms to completely switch color once the divulge has started altering color. When we add up the latency from expecting the next frame to the latency of an accurate color switch, we get an anticipated latency of 7/2 + 10=13.5ms

With the primitive CRT in the apple 2ewe’d query half of a 60 Hz refresh (16.7 ms / 2) plus a negligible prolong, or 8.3 ms. That’s laborious to beat nowadays: a cutting-edge “gaming video display” can get the full divulge latency down into the similar vary, but when it involves marketshare, very few other americans possess such displays, and even displays which would be marketed as being mercurial aren’t constantly undoubtedly mercurial.

iOS rendering pipeline

If we glimpse at what’s going down between the enter and the output, the variations between a up to date device and an apple 2e are too many to train without writing a total e book. To get a sense of the situation in popular machines, here’s extinct iOS/UIKit engineer Andy Matuschak’s high-stage sketch of what occurs on iOS, which he says ought to be presented with the disclaimer that “this is my outdated-usual memory of outdated-usual records”:

  • hardware has its occupy scanrate (e.g. 120 Hz for contemporary contact panels), in recount that can introduce up to 8 ms latency
  • events are dropped at the kernel via firmware; this is moderately fleet but device scheduling considerations could well introduce a couple ms here
  • the kernel delivers these events to privileged subscribers (here, backboardd) over a mach port; extra scheduling loss that that you just can well presumably imagine
  • backboardd must resolve which process ought to receive the occasion; this requires taking a lock in opposition to the window server, which shares that records (a crawl to reduction into the kernel, extra scheduling prolong)
  • backboardd sends that occasion to the process in query; extra scheduling prolong that that you just can well presumably imagine sooner than it is processed
  • these events are finest dequeued on the major thread; something else can also very successfully be going down on the major thread (e.g. as results of a timer or network job), so some extra latency could well discontinuance up, reckoning on that work
  • UIKit launched 1-2 ms occasion processing overhead, CPU-trip
  • utility decides what to fabricate with the occasion; apps are poorly written, so in general this takes many ms. the penalties are batched up in a records-driven update which is sent to the render server over IPC
    • If the app wants a brand contemporary shared-memory video buffer as a end result of the occasion, which can happen anytime something non-trivial is going down, that can require round-commute IPC to the render server; extra scheduling delays
    • (trivial adjustments are things which the render server can incorporate itself, love affine transformation adjustments or color adjustments to layers; non-trivial adjustments encompass the relaxation that has to fabricate with textual tell, most raster and vector operations)
    • These forms of updates on the total discontinuance up being triple-buffered: the GPU can also very successfully be the usage of one buffer to render aesthetic now; the render server could need one other buffer queued up for its next frame; and you have to scheme into one other. More (immoral-process) locking here; extra trips into kernel-land.
  • the render server applies these updates to its render tree (a few ms)
  • every N Hzthe render tree is flushed to the GPU, which is requested to occupy a video buffer
    • In fact, despite the indisputable truth that, there’s on the total triple-buffering for the veil buffer, for the similar motive I described above: the GPU’s drawing into one now; one other can also very successfully be being learn from in preparation for one other frame
  • every N Hzthat video buffer is swapped with one other video buffer, and the divulge is driven at this time from that memory
    • (this N Hz isn’t necessarily ideally aligned with the earlier step’s N Hz)

Andy says “the actual amount of work going down here is always moderately exiguous. Just a few ms of CPU time. Key overhead comes from:”

  • periodic scanrates (enter software, render server, divulge) imperfectly aligned
  • many handoffs all the device in which via process boundaries, each a possibility for something else to get scheduled as a change of the penalties of the enter occasion
  • hundreds locking, especially all the device in which via process boundaries, necessitating trips into kernel-land

By comparison, on the Apple 2e, there in general aren’t handoffs, locks, or process boundaries. Some moderately straight forward code runs and writes the discontinuance end result to the divulge memory, which causes the divulge to stand up to this level on the next scan.

Refresh fee vs. latency

One element that’s uncommon about the computer results is the influence of refresh fee. We get a 90 ms enchancment from going from 24 Hz to 165 Hz. At 24 Hz each frame takes 41.67 ms and at 165 Hz each frame takes 6.061 ms. As we seen above, if there weren’t any buffering, we’d query the common latency added by frame refreshes to be 20.8ms in the extinct case and 3.03 ms in the latter case (because we’d query to end at a uniform random level in the frame and must wait between 0ms and the plump frame time), which is a difference of about 18ms. Nonetheless the adaptation is de facto 90 msimplying we possess latency much like (90 - 18) / (41.67 - 6.061)=2 buffered frames.

If we field the results from the opposite refresh charges on the similar machine (no longer shown), we are able to explore that they’re roughly in step with a “finest match” curve that we get if we rob that, for that machine working powershell, we get 2.5 frames rate of latency no subject refresh fee. This lets us estimate what the latency could well be if we equipped this low latency gaming machine with an infinity Hz divulge — we’d query latency to be 140 - 2.5 * 41.67=36 msnearly as mercurial as fleet but recurring machines from the 70s and 80s.


Virtually every computer and mobile software that folks have interaction nowadays is slower than popular devices of computer programs from the 70s and 80s. Low-latency gaming desktops and the ipad pro can get into the similar vary as fleet machines from thirty to forty years ago, but most off-the-shelf devices aren’t even end.

If we needed to know one root motive in the aid of latency bloat, we could deliver that it’s due to “complexity”. Clearly, every person knows that complexity is depraved. For these who’ve been to a non-academic non-venture tech convention in the past decade, there’s a correct chance that there develop into once at the least one talk on how complexity is the basis of all unsuitable and we ought to aspire to lower complexity.

Unfortunately, it is loads more difficult to take hang of away complexity than to present a chat asserting that we ought to take hang of away complexity. Many of the complexity buys us something, either at this time or circuitously. When we checked out the enter of a treasure popular keyboard vs. the apple 2 keyboard, we seen that the usage of a moderately great and expensive general motive processor to address keyboard inputs can also additionally be slower than dedicated good judgment for the keyboard, which would each be extra unbiased correct and more cost-effective. Nevertheless, the usage of the processor offers other americans the facility to without concerns customize the keyboard, and additionally pushes the situation of “programming” the keyboard from hardware into software, which reduces the cost of making the keyboard. The extra expensive chip increases the manufacturing price, but all for how worthy of the cost of these exiguous-batch artisanal keyboards is the construct price, it appears love a secure decide to alternate manufacturing price for ease of programming.

We explore this roughly tradeoff in every portion of the pipeline. One of many finest examples of this is the OS that you just can flee on a up to date desktop vs. the loop that’s working on the apple 2. Fashioned OSes let programmers write generic code that can address having other functions simultaneously working on the similar machine, and manufacture so with moderately cheap general performance, but we pay an colossal complexity price for this and the handoffs interested by making this easy discontinuance in a critical latency penalty.

Many of the complexity can also very successfully be known as accidental complexitybut most of that accidental complexity is there because it’s so handy. At every stage from the hardware structure to the syscall interface to the I/O framework we exhaust, we take hang of on complexity, worthy of that would maybe be eradicated if we could well sit down down and re-write the full programs and their interfaces nowadays, but it undoubtedly’s too inconvenient to re-construct the universe to lower complexity and we get advantages from economies of scale, so we reside with what we possess.

For these reasons and further, in prepare, the approach to poor performance precipitated by “excess” complexity is on the total so to add extra complexity. In specific, the positive aspects we’ve viewed that get us reduction to the quickness of the quickest machines from thirty to forty years ago possess near no longer from paying consideration to exhortations to lower complexity, but from piling on extra complexity.

The ipad pro is a feat of popular engineering; the engineering that went into increasing the refresh fee on each the enter and the output moreover to rising definite the software pipeline doesn’t possess pointless buffering is advanced! The construct and secure of high-refresh-fee displays that can push device latency down is additionally non-trivially advanced in techniques that aren’t obligatory for bathroom recurring 60 Hz displays.

Here’s undoubtedly a popular theme when engaged on latency reduction. A popular trick to lower latency is so to add a cache, but in conjunction with a cache to a device makes it extra advanced. For programs that generate contemporary records and can’t tolerate a cache, the solutions are on the total even extra advanced. An instance of this could also very successfully be immense scale RoCE deployments. These can push far off records get admission to latency from from the millisecond vary down to the microsecond vary, which permits contemporary courses of functions. Nevertheless, this has near at a immense price in complexity. Early immense-scale RoCE deployments without concerns took tens of particular person years of effort to get aesthetic and additionally got here with a colossal operational burden.


It’s a bit absurd that a up to date gaming machine working at 4,000x the fee of an apple 2with a CPU that has 500,000x as many transistors (with a GPU that has 2,000,000x as many transistors) can perchance organize the similar latency as an apple 2 in very moderately coded functions if we possess a video display with almost about 3x the refresh fee. It’s even perchance extra absurd that the default configuration of the powerspec g405which had the quickest single-threaded performance that you just can get till October 2017, had extra latency from keyboard-to-veil (approximately 3 feetperchance 10 feet of accurate cabling) than sending a packet around the globe (16187 mi from NYC to Tokyo to London reduction to NYC, extra as a result of the cost of working the shortest that that you just can well presumably imagine size of fiber).

On the intense facet, we’re arguably emerging from the latency darkish ages and it’s now that that you just can well presumably imagine to assemble a computer or have interaction a tablet with latency that’s in the similar vary as that you just can get off-the-shelf in the 70s and 80s. This rings a bell in my memory somewhat the veil resolution & density darkish ages, the set CRTs from the 90s equipped larger resolution and bigger pixel density than realistic non-notebook computer LCDs till moderately no longer too lengthy ago. 4k displays possess now change into usual and realistic 8k displays are on the horizon, blowing past the relaxation we seen on user CRTs. I don’t know that we’ll explore the similar variety enchancment with respect to latency, but one can hope. There are particular particular person builders bettering the skills for folks who exhaust definite, very moderately coded, functions, but it undoubtedly’s no longer sure what power could well region off a critical enchancment in the default skills most users explore.

Appendix: why measure latency?

Latency issues! For moderately straight forward initiatives, other americans can focus on latencies down to 2 ms or less. Moreover, increasing latency is no longer finest noticeable to users, it causes users to enact straight forward initiatives less precisely. For these who would love a visual demonstration of what latency looks love and you don’t possess a tidy-mercurial primitive computer lying round, strive this MSR demo on touchscreen latency.

Potentially the most ceaselessly cited story on response time is the nielsen community article on response instances, which claims that latncies below 100ms in actuality feel equivalent and perceived as instantaneous. One easy components to glimpse that this is fallacious is to enter your terminal and take hang of a conception at sleep 0; echo "pong" vs. sleep 0.1; echo "test" (or for that subject, strive playing an primitive game that doesn’t possess latency compensation, love quake 1, with 100 ms ping, or even 30 ms ping, or strive typing in a terminal with 30 ms ping). For added records on this and other latency fallacies, explore this story on popular misconceptions about latency.

Throughput additionally issues, but this is widely understood and measured. For these who crawl to moderately worthy any mainstream review or benchmarking internet page, that you just can get a huge diversity of throughput measurements, so there’s less price in writing up extra throughput measurements.

Appendix: apple 2 keyboard

The apple 2eas a change of the usage of a programmed microcontroller to learn the keyboard, uses a worthy extra unbiased correct personalized chip designed for reading keyboard enter, the AY 3600. If we glimpse at the AY 3600 datasheet,we are able to explore that the scan time is (90 * 1/f) and the debounce time is listed as strobe_delay. These quantities are sure by some capacitors and a resistor, which appear to be 47pf, 100k ohmsand 0.022uf for the Apple 2e. Plugging these numbers into the AY3600 datasheetwe are able to explore that f=50 kHzgiving us a 1.8 ms scan prolong and a 6.8 ms debounce prolong (assuming the values are aesthetic — capacitors can degrade over timeso we ought to query the actual delays to be shorter on our primitive Apple 2e), giving us lower than 8.6 ms for the interior keyboard good judgment.

Evaluating to a keyboard with a 167 Hz scan fee that scans two extra instances to debouncethe equivalent resolve is 3 * 6 ms=18 ms. With a 100Hz scan fee, that turns into 3 * 10 ms=30 ms. 18 ms to 30 ms of keyboard scan plus debounce latency is in step with what we seen once we did some preliminary keyboard latency measurements.

For reference, the ergodox uses a 16 MHz microcontroller with ~80k transistors and the apple 2e CPU is a 1 MHz chip with 3.5k transistors.

Appendix: why ought to android telephones possess larger latency than primitive apple telephones?

As we possess viewed, uncooked processing energy doesn’t reduction worthy with many of the causes of latency in the pipeline, love handoffs between assorted processes, so telephones that an android telephone with a 10x extra great processor than an susceptible iphone is just not in actuality assured to be quicker to respond, despite the indisputable truth that it ought to render javascript heavy pages quicker.

For these who talk to other americans who work on non-Apple mobile CPUs, that you just can get that they flee benchmarks love dhrystone (a synthetic benchmark that develop into once beside the level even when it develop into once created, in 1984) and SPEC2006 (an up to this level version of a workstation benchmark that develop into once linked in the 90s and even perchance as unhurried as the early 2000s while you happen to care about workstation workloads, which would be completely assorted from mobile workloads). This instance the set the supplier who makes the element has an intermediate target that’s finest weakly correlated to the actual user skills. I’ve heard that there are other americans engaged on the pixel telephones who care about discontinuance-to-discontinuance latency, but it undoubtedly’s no longer easy to get correct latency in case that you just can must exhaust parts which would be optimized for things love dhrystone and SPEC2006.

For these who talk to other americans at Apple, that you just can get that they’re moderately cagey, but that they’ve got been targeting the discontinuance-to-discontinuance user skills for moderately a truly lengthy time and they they’ll manufacture “plump stack” optimizations which would be no longer easy for android distributors to drag of. They’re no longer actually very no longer going, but making a switch to a chip that must be threaded up via the OS is something that you just can successfully be most no longer going to glimpse unless google is doing the optimization, and google hasn’t in actuality been interested by the discontinuance-to-discontinuance skills till no longer too lengthy ago.

Having moderately poor performance in facets that don’t appear to be measured is a popular theme and one we seen once we checked out terminal latency. Before inspecting temrinal latency, public benchmarks had been all throughput oriented and the terminals that priortized performance worked on increasing throughput, even supposing increasing terminal throughput is just not in actuality in actuality helpful. After these terminal latency benchmarks, some terminal authors seemed into their latency and figured out areas they may maybe tidy down buffering and take hang of away latency. You get what you measure.

Appendix: experimental setup

Most measurements had been enthusiastic in the 240fps digital camera (4.167 ms resolution) in the iPhone SE. Devices with response instances below 40 ms had been re-measured with a 1000fps digital camera (1 ms resolu tion), the Sony RX100 V in PAL mode. Ends in the tables are the results of multiple runs and are rounded to the nearest 10 ms to know far from the influence of fallacious precision. For desktop results, results are measured from when the major started exciting till the veil performed updating. Show veil that this is assorted from most key-to-veil-update measurements that you just can get on-line, which most ceaselessly exhaust a setup that successfully will get rid of worthy or the full keyboard latency, which, as an discontinuance-to-discontinuance dimension, is extra healthy life like while you happen to can possess a psychic hyperlink to your computer (this is just not in actuality to claim the measurements don’t appear to be helpful — if, as a programmer, you’ll need a reproducible benchmark, it is good to lower dimension noise from sources which would be past your regulate, but that’s no longer linked to total users). Of us on the total advocate measuring from one of: {the major bottoming out, the tactile in actuality feel of the swap}. Utterly different than for dimension consolation, there appears to be like to be no motive to fabricate any of these, but other americans on the total convey that’s when the user expects the keyboard to “in actuality” work. Nonetheless these are unbiased of when the swap undoubtedly fires. Both the gap between the major bottoming out and activiation moreover to the gap between feeling solutions and activation are arbitrary and can also additionally be tuned. Survey this put up on keyboard latency measurements for extra records on keyboard fallacies.

One more critical difference is that measurements had been done with settings as end to the default OS settings as that that you just can well presumably imagine since approximately 0% of users will futz round with divulge settings to lower buffering, disable the compositor, and loads others. Waiting till the veil has performed updating is additionally assorted from most discontinuance-to-discontinuance measurements manufacture — most take hang of into consideration the update “done” when any circulate has been detected on the veil. Waiting till the veil is performed altering is much like webpagetest’s “visually total” time.

Computer results had been taken the usage of the “default” terminal for the device (e.g., powershell on windows, lxterminal on lubuntu), which could well without concerns region off 20 ms to 30 ms difference between a fleet terminal and a late terminal. Between measuring time in a terminal and measuring the plump discontinuance-to-discontinuance time, measurements in this article ought to be slower than measurements in other, the same, articles (which tend to measure time to first switch in video games).

The powerspec g405 baseline end result’s the usage of integrated graphics (the machine doesn’t near with a graphics card) and the 60 Hz end result’s with a low-price video card. The baseline develop into once end result develop into once at 30 Hz for the reason that integrated graphics finest helps hdmi output and the divulge it develop into once linked to finest runs at 30 Hz over hdmi.

Mobile results had been done by the usage of the default browser, browsing to //danluu.comand measuring the latency from finger circulate till the veil first updates to train that scrolling has took place. In the situations the set this didn’t construct sense, (kindles, gameboy color, and loads others.), some action that is smart for the platform develop into once taken (altering pages on the kindle, pressing the joypad on the gameboy color in a game, and loads others.). No longer like with the desktop/notebook computer measurements, this discontinuance-time for the dimension develop into once on the first visual switch to know far from in conjunction with many frames of scrolling. To construct the dimension easy, the dimension develop into once enthusiastic in a finger on the touchscreen and the timer develop into once started when the finger started exciting (to know far from having to get out when the finger first contacted the veil).

In the case of “ties”, results are ordered by the unrounded latency as a tiebreaker, but this shouldn’t be even handed as critical. Differences of 10 ms ought to presumably additionally no longer be even handed as critical.

The custom haswell-e develop into once tested with gsync on and there develop into once no observable difference. The 365 days for that box is critically arbitrary, for the reason that CPU is from 2014however the divulge is more moderen (I feel you couldn’t get a 165 Hz divulge till 2015.

The collection of transistors for some popular machines is a rough estimate because accurate numbers aren’t public. Be at liberty to ping me while you happen to can possess the next estimate!

The color scales for latency and 365 days are linear and the color scales for clock flee and collection of transistors are log scale.

All Linux results had been done with a pre-KPTI kernel. It is that that you just can well presumably imagine that KPTI will influence user perceivable latency.

Measurements had been done as cleanly as that that you just can well presumably imagine (without other things working on the machine/software when that that you just can well presumably imagine, with a software that develop into once almost about plump on battery for devices with batteries). Latencies when other software is working on the software or when devices are low on battery can also very successfully be worthy larger.

For these who would love a reference to study the kindle in opposition to, a pretty fleet page flip in a bodily e book appears to be like to be about 200 ms.

Here’s a piece in development. I query to get benchmarks from loads extra primitive computer programs the next time I talk to Seattle. For these who perceive of primitive computer programs I will take a look at in the NYC field (that possess their authentic displays or something love them), let me know! For these who can possess a software you’d love to donate for checking out, in actuality feel free to mail it to

And Lou
Recurse Heart
455 Broadway, 2nd Ground
Original York, NY 10013

Thanks to RCDavid Albert, Bert Muthalaly, Christian Ternus, Kate Murphy, Ikhwan Lee, Peter Bhat Harkins, Leah Hanson, Alicia Thilani Singham Goodwin, Amy Huang, Dan Bentley, Jacquin Mininger, Bag, Susan Steinman, Raph Levien, Max McCrea, Peter Metropolis, Jon Cinque, Nameless, and Jonathan Dahan for donating devices to study and thanks to Leah Hanson, Andy Matuschak, Milosz Danczak, amos (@fasterthanlime), @emitter_coupled, Josh Jordan, mrob, and David Albert for feedback/corrections/discussion.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button