Errors, bugs, questions - page 2777

 
Alain Verleyen:

Update :

Maximum peak now seriously increased:

2020.06.13 08: 18: 25.187 342152 (EURGBP, H1) Number = 23520
2020.06.13 08: 18: 25.187 342152 (EURGBP, H1) Min = 33
2020.06.13 08: 18: 25.187 342152 (EURGBP, H1) Max = 81011
2020.06.13 08: 18: 25.187 342152 (EURGBP, H1) Avg = 149

For the sake of purity of the experiment, this script has to be run in parallel in several charts and several terminals. Then compare the time of hangups.

 
Stanislav Korotky :

For the sake of the experiment, run this script in parallel on several charts and several terminals. Then compare the hiccups time.

Ok, but if it already happened with 1 chart, it will not improve with multiple charts.

What would it give you more to run it on multiple charts/terminals?

 
Alain Verleyen:

OK, but if it has already happened with 1 chart, it will not improve with multiple charts.

What will it give you more to run it on multiple charts/terminals?

If it will be the same in different terminals, then the problem lies in the OS plane.

 
Stanislav Korotky :

If this is the same in different terminals, then the problem lies with the OS.

Got it. I'll give it a try.
 
Stanislav Korotky :

For the sake of the experiment, run this script in parallel on several charts and several terminals. Then compare hovering times.

Another Terminal, but 20 charts (different symbols), started simultaneously.

I checked on AUDUSD where the peak comes in:

2020.06.13 09: 16: 35.151 342152 (USDJPY, H1) Number = 240
2020.06.13 09: 16: 35.151 342152 (USDJPY, H1) Min = 38
2020.06.13 09: 16: 35.151 342152 (USDJPY, H1) Max = 2235
2020.06.13 09: 16: 35.151 342152 (USDJPY, H1) Avg = 472
2020.06.13 09: 16: 35.151 342152 (CADCHF, H1) Avg = 240
2020.06.13 09: 16: 35.151 342152 (CADCHF, H1) Min = 48
2020.06.13 09: 16: 35.151 342152 (CADCHF, H1) Max = 2323
2020.06.06.13 09: 16: 35.152 342152 (CADCHF, H1) Avg = 606
2020.06.13 09: 16: 35.152 342152 (EURAUD, H1) Quantity = 240
2020.06.13 09: 16: 35.152 342152 (EURCHF, H1) Quantity = 240
2020.06.13 09: 16: 35.152 342152 (GBPCHF, H1) Quantity = 240
2020.06.13 09: 16: 35.152 342152 (EURCHF, H1) Min = 141
2020.06.13 09: 16: 35.152 342152 (EURGBP, H1) Quantity = 240
2020.06.13 09: 16: 35.152 342152 (CHFJPY, H1) Quantity = 240
2020.06.13 09: 16: 35.152 342152 (AUDJPY, H1) Quantity = 240
2020.06.13 09: 16: 35.152 342152 (AUDJPY, H1) Min = 47
2020.06.13 09: 16: 35.152 342152 (EURUSD, H1) Quantity = 240
2020.06.13 09: 16: 35.152 342152 (EURUSD, H1) Min. = 23
2020.06.13 09: 16: 35.152 342152 (EURUSD, H1) Max = 2368
2020.06.13 09: 16: 35.152 342152 (AUDUSD, H1) Quantity = 240
2020.06.13 09: 16: 35.152 342152 (EURUSD, H1) Avg = 607
2020.06.13 09: 16: 35.152 342152 (AUDUSD, H1) Min = 74
2020.06.13 09: 16: 35.152 342152 (GBPJPY, H1) Avg = 240
2020.06.13 09: 16: 35.152 342152 (AUDNZD, H1) Avg = 240
2020.06.13 09: 16: 35.152 342152 (USDCHF, H1) Avg = 240
2020.06.06.13 09: 16: 35.152 342152 (AUDNZD, H1) Min = 122
2020.06.13 09: 16: 35.152 342152 (AUDCHF, H1) Quantity = 240
2020.06.13 09: 16: 35.152 342152 (AUDNZD, H1) Max = 2402
2020.06.13 09: 16: 35.152 342152 (AUDNZD, H1) Avg = 660
2020.06.06.13 09: 16: 35.152 342152 (AUDCHF, H1) Min = 157
2020.06.13 09: 16: 35.152 342152 (AUDCHF, H1) Max = 2354
2020.06.13 09: 16: 35.152 342152 (AUDCHF, H1) Avg = 663
2020.06.13 09: 16: 35.152 342152 (GBPCHF, H1) Min = 32
2020.06.06.13 09: 16: 35.152 342152 (GBPCHF, H1) Max = 2380
2020.06.13 09: 16: 35.152 342152 (GBPCHF, H1) Avg = 616
2020.06.13 09: 16: 35.152 342152 (EURCHF, H1) Max = 2327
2020.06.13 09: 16: 35.152 342152 (EURCHF, H1) Avg = 618
2020.06.13 09: 16: 35.152 342152 (EURGBP, H1) Min = 36
2020.06.13 09: 16: 35.152 342152 (EURGBP, H1) Max = 2233
2020.06.13 09: 16: 35.152 342152 (EURGBP, H1) Avg = 503
2020.06.13 09: 16: 35.152 342152 (CHFJPY, H1) Min = 11
2020.06.13 09: 16: 35.152 342152 (EURGBP, H1)13 09: 16: 35.152 342152 (CHFJPY, H1) Max = 2387
2020.06.13 09: 16: 35.152 342152 (CHFJPY, H1) Avg = 657
2020.06.13 09: 16: 35.152 342152 (AUDJPY, H1) Max = 2292
2020.06.13 09: 16: 35.152 342152 (AUDJPY, H1) Avg = 612
2020.06.13 09: 16: 35.152 342152 (EURNZD, H1) Quantity = 240
2020.06.13 09: 16: 35.152 342152 (EURNZD, H1) Min = 54
2020.06.13 09: 16: 35.152 342152 (EURNZD, H1) Max = 2361
2020.06.13 09: 16: 35.152 342152 (EURNZD, H1) Avg = 612
2020.06.06.13 09: 16: 35.152 342152 (AUDCAD, H1) Avg = 240
2020.06.13 09: 16: 35.152 342152 (AUDCAD, H1) Min = 121
2020.06.13 09: 16: 35.152 342152 (EURCAD, H1) Avg = 240
2020.06.13 09: 16: 35.152 342152 (AUDCAD, H1) Max = 2328
2020.06.13 09: 16: 35.152 342152 (AUDCAD, H1) Avg = 605
2020.06.13 09: 16: 35.152 342152 (AUDUSD, H1) Max = 2361
2020.06.13 09: 16: 35.152 342152 (AUDUSD, H1) Avg = 611
2020.06.13 09: 16: 35.152 342152 (GBPJPY, H1) Min = 13
2020.06.13 09: 16: 35.152 342152 (GBPJPY, H1) Max = 2411
2020.06.13 09: 16: 35.152 342152 (GBPJPY, H1) Avg = 661
2020.06.13 09: 16: 35.153 342152 (GBPUSD, H1) Avg = 240
2020.06.13 09: 16: 35.13 09: 16: 35.153 342152 (GBPUSD, H1) Min = 113
2020.06.13 09: 16: 35.153 342152 (GBPUSD, H1) Max = 2362
2020.06.13 09: 16: 35.153 342152 (GBPUSD, H1) Avg = 667
2020.06.13 09: 16: 35.153 342152 (USDCAD, H1) Quantity = 240
2020.06.06.13 09: 16: 35.153 342152 (USDCAD, H1) Min = 151
2020.06.13 09: 16: 35.153 342152 (USDCAD, H1) Max = 2386
2020.06.13 09: 16: 35.153 342152 (EURAUD, H1) Min = 35
2020.06.13 09: 16: 35.153 342152 (USDCAD, H1) Avg = 671
2020.06.13 09: 16: 35.153 342152 (EURAUD, H1) Max = 2233
2020.06.13 09: 16: 35.153 342152 (EURAUD, H1) Avg = 478
2020.06.13 09: 16: 35.153 342152 (EURJPY, H1) Quantity = 240
2020.06.13 09: 16: 35.153 342152 (EURJPY, H1) Min = 10
2020.06.06.13 09: 16: 35.153 342152 (EURCAD, H1) Min = 123
2020.06.13 09: 16: 35.153 342152 (EURCAD, H1) Max = 2384
2020.06.13 09: 16: 35.153 342152 (EURCAD, H1) Avg = 658
2020.06.13 09: 16: 35.153 342152 (USDCHF, H1) Min = 32
2020.06.06.13 09: 16: 35.153 342152 (USDCHF, H1) Max = 2369
2020.06.13 09: 16: 35.153 342152 (USDCHF, H1) Avg = 614
2020.06.13 09: 16: 35.153 342152 (EURJPY, H1) Max = 2344
2020.06.13 09: 16: 35.153 342152 (EURJPY, H1) Avg = 658

And this is when the tops come in:

2020.06.13 09: 17: 35.151 342152 (USDJPY, H1) Avg = 480
2020.06.13 09: 17: 35.151 342152 (USDJPY, H1) Min = 38
2020.06.13 09: 17: 35.151 342152 (USDJPY, H1) Max = 17421
2020.06.06.13 09: 17: 35.151 342152 (USDJPY, H1) Avg = 533
2020.06.13 09: 17: 35.151 342152 (EURAUD, H1) Quantity = 480
2020.06.13 09: 17: 35.151 342152 (EURAUD, H1) Min = 35
2020.06.06.13 09: 17: 35.151 342152 (EURAUD, H1) Max = 17406
2020.06.13 09: 17: 35.151 342152 (EURAUD, H1) Avg = 518
2020.06.13 09: 17: 35.151 342152 (EURGBP, H1) Quantity = 480
2020.06.13 09: 17: 35.151 342152 (EURGBP, H1) Min = 36
2020.06.13 09: 17: 35.151 342152 (EURGBP, H1) Max = 17425
2020.06.13 09: 17: 35.151 342152 (EURGBP, H1) Avg = 515
2020.06.13 09: 17: 35.151 342152 (EURUSD, H1) Quantity = 480
2020.06.13 09: 17: 35.151 342152 (EURUSD, H1) Min = 18
2020.06.13 09: 17: 35.151 342152 (EURUSD, H1) Max = 17366
2020.06.13 09: 17: 35.151 342152 (EURCHF, H1) Max = 480
2020.06.13 09: 17: 35.151 342152 (EURUSD, H1) Avg = 618
2020.06.13 09: 17: 35.151 342152 (AUDCHF, H1) Max = 480
2020.06.13 09: 17: 35.151 342152 (USDCHF, H1) Quantity = 480
2020.06.13 09: 17: 35.151 342152 (AUDCHF, H1) Min = 126
2020.06.13 09: 17: 35.151 342152 (CADCHF, H1) Quantity = 480
2020.06.13 09: 17: 35.151 342152 (AUDCHF, H1) Max = 10477
2020.06.13 09: 17: 35.151 342152 (EURCAD, H1) Quantity = 480
2020.06.13 09: 17: 35.151 342152 (GBPUSD, H1) Quantity = 480
2020.06.13 09: 17: 35.152 342152 (EURCAD, H1) Min = 123
2020.06.13 09: 17: 35.152 342152 (GBPUSD, H1) Min = 112
2020.06.13 09: 17: 35.152 342152 (EURCAD, H1) Max = 10485
2020.06.13 09: 17: 35.152 342152 (EURCAD, H1) Avg = 663
2020.06.13 09: 17: 35.152 342152 (GBPUSD, H1) Max = 10435
2020.06.13 09: 17: 35.152 342152 (GBPUSD, H1) Avg = 661
2020.06.13 09: 17: 35.152 342152 (EURCHF, H1) Min = 71
2020.06.06.13 09: 17: 35.152 342152 (EURJPY, H1) Avg = 480
2020.06.13 09: 17: 35.152 342152 (USDCAD, H1) Avg = 480
2020.06.13 09: 17: 35.152 342152 (USDCAD, H1) Min = 54
2020.06.13 09: 17: 35.152 342152 (EURJPY, H1) Min = 10
2020.06.13 09: 17: 35.152 342152 (EURJPY, H1) Max = 10487
2020.06.13 09: 17: 35.152 342152 (EURJPY, H1) Avg = 664
2020.06.13 09: 17: 35.152 342152 (EURJPY, H1) Avg = 664.13 09: 17: 35.152 342152 (EURNZD, H1) Quantity = 480
2020.06.13 09: 17: 35.152 342152 (EURNZD, H1) Min = 54
2020.06.13 09: 17: 35.152 342152 (EURNZD, H1) Max = 17426
2020.06.06.13 09: 17: 35.152 342152 (EURNZD, H1) Avg = 620
2020.06.13 09: 17: 35.152 342152 (USDCHF, H1) Min = 32
2020.06.13 09: 17: 35.152 342152 (USDCHF, H1) Max = 17427
2020.06.13 09: 17: 35.152 342152 (USDCHF, H1) Avg = 649
2020.06.13 09: 17: 35.152 342152 (GBPCHF, H1) Max = 480
2020.06.13 09: 17: 35.152 342152 (GBPCHF, H1) Min = 32
2020.06.13 09: 17: 35.152 342152 (GBPCHF, H1) Max = 17433
2020.06.13 09: 17: 35.152 342152 (GBPCHF, H1) Avg = 647
2020.06.13 09: 17: 35.152 342152 (AUDJPY, H1) Min = 480
2020.06.13 09: 17: 35.152 342152 (AUDJPY, H1) Min. = 47
2020.06.13 09: 17: 35.152 342152 (AUDJPY, H1) Max = 17415
2020.06.13 09: 17: 35.152 342152 (AUDJPY, H1) Avg = 640
2020.06.13 09: 17: 35.152 342152 (CADCHF, H1) Min = 48
2020.06.13 09: 17: 35.152 342152 (CADCHF, H1) Max = 17435
2020.06.13 09: 17: 35.152 342152 (CADCHF, H1) Avg = 637
2020.06.13 09: 17: 35.152 342152 (AUDCHF, H1) Avg = 662
2020.06.13 09: 17: 35.152 342152 (AUDUSD, H1) Quantity = 480
2020.06.13 09: 17: 35.152 342152 (AUDUSD, H1) Min = 43
2020.06.13 09: 17: 35.152 342152 (AUDUSD, H1) Max = 17416
2020.06.13 09: 17: 35.152 342152 (AUDUSD, H1) Avg = 620
2020.06.13 09: 17: 35.152 342152 (GBPJPY, H1) Quantity = 480
2020.06.13 09: 17: 35.13 09: 17: 35.152 342152 (GBPJPY, H1) Min = 13
2020.06.13 09: 17: 35.152 342152 (GBPJPY, H1) Max = 10468
2020.06.13 09: 17: 35.152 342152 (GBPJPY, H1) Avg = 660
2020.06.13 09: 17: 35.152 342152 (CHFJPY, H1) Quantity = 480
2020.06.06.13 09: 17: 35.152 342152 (CHFJPY, H1) Min = 11
2020.06.13 09: 17: 35.152 342152 (CHFJPY, H1) Max = 10474
2020.06.13 09: 17: 35.152 342152 (AUDNZD, H1) Quantity = 480
2020.06.13 09: 17: 35.152 342152 (AUDNZD, H1) Min = 61
2020.06.13 09: 17: 35.152 342152 (AUDNZD, H1) Max = 10491
2020.06.13 09: 17: 35.152 342152 (AUDNZD, H1) Avg = 663
2020.06.13 09: 17: 35.152 342152 (EURCHF, H1) Max = 17414
2020.06.13 09: 17: 35.152 342152 (EURCHF, H1) Avg = 646
2020.06.13 09: 17: 35.152 342152 (AUDCAD, H1) Max = 480
2020.06.13 09: 17: 35.152 342152 (AUDCAD, H1) Min = 100
2020.06.13 09: 17: 35.152 342152 (AUDCAD, H1) Max = 17421
2020.06.06.13 09: 17: 35.152 342152 (AUDCAD, H1) Avg = 638
2020.06.13 09: 17: 35.152 342152 (USDCAD, H1) Max = 10488
2020.06.13 09: 17: 35.152 342152 (USDCAD, H1) Avg = 666
2020.06.13 09: 17: 35.152 342152 (CHFJPY, H1) Avg = 656

So it all happened at the same time. But this could still be an MT5 problem. I will check with other simultaneous terminals.

 
Stanislav Korotky:

If it will be the same in different terminals, then the problem lies in the OS plane.

The problem is not in OS, but in MT.
I checked it on MT5 (build 2009) - everything flies, time of execution is less than 5 ms
While in MT5 (build 2485) - everything slows down, the execution time often exceeds 200 ms (especially when 50+ charts are open)
I used code from the description of the problem:https://www.mql5.com/en/forum/342152

I compared realization of ChartGetInteger function for two versions of MT5 2009 and MT5 2485, maybe there is the problem:
1. In 2485 for reading "atomic" fields of a chart object quite slow operations are used:
mfence; lock mov eax,[rax+2C];
While in 2009 build it is done using: lock xadd [rcx+2C],eax

2. It also seems that the logic and possible dwell time in ntdll_RtlEnterCriticalSection have significantly changed.
Previously, in 2009, a critical section would only check a pair of received values, without any atomic operations.
And in 2485, the linked-list objects of the chart could additionally be enumerated.


Presumably, the problem could happen when crash was fixed when working with chart functions as part of migration to the new compiler (about 2-3 months ago).
Assembler code for ChartGetInteger call in MT5 (build 2485) is attached.

 
Sergey Dzyublik :

The problem is not in OS, but in MT.
I checked it on MT5 (build 2009) - everything flies, the execution time is less than 5 ms
While in MT5 (build 2485) - everything slows down, the execution time often exceeds 200 ms (especially when 50+ charts are open)
The code from the problem description was used: https://www.mql5.com/en/forum/342152

I compared realization of ChartGetInteger function for two versions of MT5 2009 and MT5 2485, maybe there is the problem:
1. In 2485 for reading "atomic" fields of a chart object quite slow operations are used:
mfence; lock mov eax,[rax+2C];
While in 2009 build it is done using: lock xadd [rcx+2C],eax

2. It also seems that the logic and possible dwell time in ntdll_RtlEnterCriticalSection have significantly changed.
Previously, in 2009, a critical section would only check a pair of received values, without any atomic operations.
And in 2485, the linked-list objects of the chart could additionally be enumerated.


Presumably, the problem could happen when crash was fixed when working with chart functions as part of migration to the new compiler (about 2-3 months ago).
Assembler code for ChartGetInteger call in MT5 (build 2485) is attached.

The official builds were 2005 Build and then 2085 Build, do you have any? I only have 2007 Build.
 
Sergey Dzyublik:

You have some misunderstanding of the terms asynchronous and synchronous.
When you say that a function is asynchronous, it means that it will be executed not in the current thread of execution, but in some other thread.

Calling an asynchronous as ChartSetInteger function from the main thread is fast as the actual execution occurs in a different thread.

On the other hand, a call of a ChartGetInteger synchronous function will require synchronization of threads and this may require additional time.
Delays are especially noticeable when the parallel thread is constantly updating the chart structure's data (for example, when the user moves the chart window or scrolls through the history).
Most likely, for simplicity and reliability, a single synchronization object is used for its chart data structure.
You can try to improve the speed of execution using "data segmentation", but on the other hand now you can run into deadlocks, or under-updated data, or slowdowns in other more critical places.
In general, it's better not to touch something that is already working steadily.

Ilyas:

I'll assume that the peak is rendering chart comment, otherwise, when the chart queue is empty, ChartGetXXX function call (note, the call with synchronization) takes 0.13 milliseconds.

I'm more used to speaking in code.
I, for example, sketched such an indicator:


ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR, 0) is executed when the mouse moves;
the red graph is the execution time statistics of this function.
A simple query for one digit runs many times slower than the BildChart function that clears the whole screen, forms a chart of several thousand lines, draws a scale, forms a text information block and displays it all on the screen.

All the academic talk about how it should be like that due to synchronicity-asynchronicity is perceived as "black is white".
With a complete array of quotes, I will have no problem creating my own independent chart based on the kanvas and have a complete table of characteristics of that chart, which can be accessed in a matter of nanoseconds. And with that the kanvas of the chart will be rendered in a different thread.

Files:
 
I was dumb for a long time, not understanding what the compiler doesn't like in this line.
  else (Type != -1) // expression has no effect

Forgot to write if. I thought it would be a good idea to spell out the message for such dumbasses.

 
Nikolai Semko:

A simple query for a single digit is many times slower than the BildChart function, which clears the whole screen, forms a graph of several thousand lines, draws a scale, forms a text information block and outputs it all to the screen.

As far as I know, calling ChartRedraw doesn't cause immediate redrawing of the chart. Only when some Get method is called does redraw occur.
And ChartRedraw is essentially the same asynchronous method, so your BuildChart measurement is not reliable.
Reason: