It makes no sense to draw such amount of points since the number of pixels in screen is much less.
I faced a similar problem time ago and I did the following process:
I reduce the number of data points to something more handy.
For example, I realised that I didn't need more than 1000 points because of the number of pixels. Actually the ideal number of points would be the canvas width.
Then, I calculate the number of data points to draw per pixel. This is, if you have 500k data points, and your canvas is 1000 pixels, it means a pixel will draw 500 data points. You see, it makes no sense to draw 500 data points in a column of pixels...
Therefore, I split data points list in groups depending on the number of pixels. For example, for the first pixels I take the first 500 points, for the second pixel, next 500 data points, and so on.
To draw 500 data points in a column of pixels, basically I locate max and min values and draw a vertical line.
Hope this approach helps you.