Live data from Hacker News

Show HN: Plotting 3 years of hourly data in 150ms

leeoniya.github.io

101–110 of 118 posts

Re: Show HN: Plotting 3 years of hourly data in 150ms

#101
post #2

Unfortunately, I have to use Google Analytics and Google Ads at work every day, and these UIs have absolutely terrible performance :( A small part of the problem is drawing the trend charts. So I decided to make uPlot [1] to see what was really possible. [1] https://github.com/leeoniya/uPlot

This is just incredible.

Re: Show HN: Plotting 3 years of hourly data in 150ms

#102
post #52

I feel like in general people underestimate just how fast computers are. Crazy to hear about libraries that choke on a couple thousand points when compared to https://hackernoon.com/drawing-2-7-billion-points-in-10s-ecc... (for instance)

Interesting read indeed. Too bad this was posted to Hackernoon, had a hard time reading it due to the header bar constantly dropping down into the text I was reading. So frustrating!

Re: Show HN: Plotting 3 years of hourly data in 150ms

#103
post #96
post #94

Earlier quoted context omitted.

> people love to rant about "JavaScript apps" while maintaining (willful?) ignorance about what the actual factors are that manifest as the slowness they experience. Are you sure you got this right? Just because JS is fast[0] doesn't mean we cannot complain about Javascript apps that should have been plain web pages? It is clearly possible to create advanced Javascript apps that are enjoyable even to people like me.…

Whether or not a given site should be client-side rendered is a valid discussion Ad bloat is a valid discussion Lazy development practices in modern sites/apps are a valid discussion But in my experience, these as well as other less-legitimate issues all tend to get lumped under the banner of "JavaScript stuff == slow", without any nuance.

Can't say for sure but the way I read them most complaints about Javascript performance are about the results of the abuse of Javascript applications everywhere.

I guess Javascript just happens to be the common thing between a number of them, and people would be just as annoyed if the multi-megabyte, cpu-hogging, data-stealing monstrosities where hand-crafted in assembly ;-)

And: If someone complained about Javascript being slow for scientific calculations I'd probably call them out on it ;-)

Re: Show HN: Plotting 3 years of hourly data in 150ms

#104

Super cool! It would be great if you could provide some insight into how you built this and the kind of tricks you had to use to make this possible. Looking forward to a blog post in the future :)

a few things: - the data is flat arrays of numbers - there is no per-datapoint memory allocation beyond whatever is necessary for the browser to construct the canvas Path2D object. this keeps the memory pressure low and the GC nearly silent. - the amount of draw commands is reduced by accumulating the min/max data values per pixel - uPlot does not generate axis ticks by walking the data. it only uses min/max of the x…

another one i forgot

- drawing at exact aligned pixel boundaries to avoid or minimize antialiasing

this makes uPlot charts a bit rougher looking, but the perf impact is quite large.

Re: Show HN: Plotting 3 years of hourly data in 150ms

#106
For a moment thought here you were plotting 3 years of data collected every 150ms - wow! What you have here still very nice. I had to work with display/charting interval data in past and having it load quickly is very nice especially when toggling new dataset intervals.

Re: Show HN: Plotting 3 years of hourly data in 150ms

#108
post #81

Earlier quoted context omitted.

No, JS is slow(ish). The GC pressure alone will kill you. This is fast despite being in JS by simply doing as little as possible (while still meeting the requirements on the end result, which is where the genius lies). The fastest code is no code. No code is fast even with pathologically slow languages/runtimes.

It's no slower than Python. Probably faster unless you're staying within a native library like NumPy. But that wasn't my main point: my main point is that people love to rant about "JavaScript apps" while maintaining (willful?) ignorance about what the actual factors are that manifest as the slowness they experience. Sometimes it's poor usage of the DOM. Usually it's ads. It's almost never the unavoidable overhead of…

For me as a user it seems to be: loading google analytics, loading fonts that seem to be improperly cached, loading chat windows, assistance widgets and spies, and dynamically adding things after page load that cause reflows.

Re: Show HN: Plotting 3 years of hourly data in 150ms

#109

Earlier quoted context omitted.

a few things: - the data is flat arrays of numbers - there is no per-datapoint memory allocation beyond whatever is necessary for the browser to construct the canvas Path2D object. this keeps the memory pressure low and the GC nearly silent. - the amount of draw commands is reduced by accumulating the min/max data values per pixel - uPlot does not generate axis ticks by walking the data. it only uses min/max of the x…

another one i forgot - drawing at exact aligned pixel boundaries to avoid or minimize antialiasing this makes uPlot charts a bit rougher looking, but the perf impact is quite large.

How much of an impact does this have?

I prefer the look of things snapped to pixels; I didn't realize it also speed things up!

Re: Show HN: Plotting 3 years of hourly data in 150ms

#110
post #109

Earlier quoted context omitted.

another one i forgot - drawing at exact aligned pixel boundaries to avoid or minimize antialiasing this makes uPlot charts a bit rougher looking, but the perf impact is quite large.

How much of an impact does this have? I prefer the look of things snapped to pixels; I didn't realize it also speed things up!

hey adam :)

it's highly dependent on what's actually drawn. i regressed it by accident and didnt notice a huge difference until i randomly opened the stress test (which is also densely packed so probably a worst case for AA)[1]. it went up by a factor of 2-4. cant remember exactly.

[1] https://github.com/leeoniya/uPlot/blob/master/bench/uPlot-60...

Post reply on HN