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
Show HN: Plotting 3 years of hourly data in 150ms
101–110 of 118 posts
Re: Show HN: Plotting 3 years of hourly data in 150ms
#102I 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)
Re: Show HN: Plotting 3 years of hourly data in 150ms
#103Earlier 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.
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
#104Super 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…
- 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
#105Re: Show HN: Plotting 3 years of hourly data in 150ms
#106Re: Show HN: Plotting 3 years of hourly data in 150ms
#107Re: Show HN: Plotting 3 years of hourly data in 150ms
#108Earlier 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…
Re: Show HN: Plotting 3 years of hourly data in 150ms
#109Earlier 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.
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
#110Earlier 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!
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...