Pre loader

Performance issues when accessing YMin & YMax properties of data series containing lots of NaN’s

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

Hi

I have experienced some performance issues when accessing YMin & YMax properties of data series containing lots of NaN’s.

I have a chart with the following setup:

XAxis = DateTime / YAxis = Numeric
1 FastLineRenderableSeries series / XyDataSeries<DateTime, double>

I have prefilled the data series with 1 million datapoints. Some of the values are randomly made NaN’s.

If 1/2 of the Y values are NaN’s – accessing YMin or YMax property takes ~117ms.
If 1/10 of the values are NaN’s it “only” takes ~27 ms.
…and if no NaN’s are added to the data series – it takes ~3ms;

This is a huge problem for us – as we have large data series including lots of NaN’s – and we must access the YMin / YMax each time data is added to do special scale fitting. This is normally once per second – but with up to 20 data series – (117ms * 2 *20 ) it takes over 4 seconds.

If I have 10 million datapoints – it takes 10 times as long – so it looks like it is recalculating the min/max each time.

/Flemming

Version
5.1.1
  • You must to post comments
0
0

I am considering applying server-side licensing for my javerScript application.

In the document below, there is a phrase “Our server-side licensing component is written in C++.”
(https://support.scichart.com/index.php?/Knowledgebase/Article/View/17256/42/)

However, there is only asp.net sample code on the provided github.
(https://github.com/ABTSoftware/SciChart.JS.Examples/tree/master/Sandbox/demo-dotnet-server-licensing)

I wonder if there is a sample code implemented in C++ for server-side licensing.

Can you provide c++ sample code?
Also, are there any examples to run on Ubuntu?

  • You must to post comments
0
0

Update:

We used to have an implementation in an older version of SciChart where YMin, YMax was computed whenever the series was updated. I think you could reproduce it if you did something like this:

   public class XyDataSeriesCalculateOnAppend<TX> : XyDataSeries<TX, double>
        where TX : IComparable
    {
        private DoubleRange _yrange;

        public XyDataSeriesCalculateOnAppend()
        {
            ResetYRange();
        }

        private void ResetYRange()
        {
            _yrange = new DoubleRange(double.MaxValue, double.MinValue);
        }

        public override IRange YRange => _yrange;

        public override void Append(TX x, double y)
        {
            _yrange.Min = Math.Min(_yrange.Min, y);
            _yrange.Max = Math.Max(_yrange.Max, y);
            base.Append(x, y);
        }

        protected override void ClearColumns()
        {
            ResetYRange();
            base.ClearColumns();
        }
    }

Notice you would need to override methods that you use, such as Append, Insert, Remove, Clear and reset and update the YRange. If you do the calculation on append or update, then you will take a small performance hit on updating the series, but the getter for YMin, YMax will be instantaneous.

If you’re appending to your dataseries in a background thread, dont forget to lock(SyncRoot) around critical operations

public class XyDataSeriesCalculateOnAppend<TX> : XyDataSeries<TX, double>
    where TX : IComparable
{
    private DoubleRange _yrange;

    public XyDataSeriesCalculateOnAppend()
    {
        ResetYRange();
    }


    private void ResetYRange()
    {
        _yrange = new DoubleRange(double.MaxValue, double.MinValue);
    }

    public override IRange YRange
    {
        get
        {
            lock (SyncRoot)
            {
                return _yrange;
            }                
        }
    }

    public override void Append(TX x, double y)
    {
        lock (SyncRoot)
        {
            _yrange.Min = Math.Min(_yrange.Min, y);
            _yrange.Max = Math.Max(_yrange.Max, y);
            base.Append(x, y);
        }            
    }

    protected override void ClearColumns()
    {
        lock (SyncRoot)
        {
            ResetYRange();
            base.ClearColumns();
        }
    }
}

Let me know if this helps!

Best regards,
Andrew

  • You must to post comments
0
0

I am considering applying server-side licensing for my javerScript application.

In the document below, there is a phrase “Our server-side licensing component is written in C++.”
(https://support.scichart.com/index.php?/Knowledgebase/Article/View/17256/42/)

However, there is only asp.net sample code on the provided github.
(https://github.com/ABTSoftware/SciChart.JS.Examples/tree/master/Sandbox/demo-dotnet-server-licensing)

I wonder if there is a sample code implemented in C++ for server-side licensing.

Can you provide c++ sample code?
Also, are there any examples to run on Ubuntu?

  • Andrew Burnett-Thompson
    See my second answer – I think it’ll work for you. That will reduce performance on append. For removes you can make your life easier by simply resetting the YRange. We used to have this but removed it in preference for recalculate YRAnge every time you call it because users complained about Append performance and did not often call YRange. You are the exception :) :D
  • Andrew Burnett-Thompson
    To skip a NaN you have to test for NaN using double.IsNaN(d). When you call this 10,000,000 times it is a bottleneck.
  • You must to post comments
0
0

I am considering applying server-side licensing for my javerScript application.

In the document below, there is a phrase “Our server-side licensing component is written in C++.”
(https://support.scichart.com/index.php?/Knowledgebase/Article/View/17256/42/)

However, there is only asp.net sample code on the provided github.
(https://github.com/ABTSoftware/SciChart.JS.Examples/tree/master/Sandbox/demo-dotnet-server-licensing)

I wonder if there is a sample code implemented in C++ for server-side licensing.

Can you provide c++ sample code?
Also, are there any examples to run on Ubuntu?

Attachments
  • You must to post comments
0
0

Hi Andrew

Did you have the chance to look at this issue ?

/Flemming

  • Andrew Burnett-Thompson
    Hi Flemming, I profiled your application and most of the time is spent fetching coordinates, we don’t know the cause of the issue (why it slows down when you have 50% of the points NaN) however I did noticed that you set RenderSurface type to HighQuality (the slowest rendersurface) and you have ResamplingPrecision=3 (ensuring 2^3 more points drawn than the default). In order to investigate further, I suggest we convert this to a support ticket since the forum is suited to Q&A. Your task for tracking the issue progress is here: https://abtsoftware.myjetbrains.com/youtrack/issue/SC-4723
  • Flemming Rosenbrandt
    Hi Andrew, Thanks – I will look forward to a solution – and in the mean while try playing with the quality settings :) /Flemming
  • You must to post comments
0
0

Update:

After deeper investigation of the provided sample we have found a solution. Please see the blog post below with youtube video showing how we solved it!

Performance debugging: Improving the speed of charts when many NaN

Best regards,
Andrew

  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies