Thread safety?

Hi

Is the Diagrams class thread safe?

Regards
Dennis

@hellagutmanndk

Thank you for contacting support.

Please note that Aspose.Diagram for .NET is multi-threaded safe as long as single thread works on a single diagram at a time. Which means access to single diagram by multiple threads at the same time is not supported. In other words, you can only edit/create single diagram per thread and run as many threads as you require.

We hope this will be helpful. Please feel free to contact us if you need any further assistance.

hmm… While processing 60.000+ Visio files and converting them to 4 different formats I am seeing a large memory buildup during the execution. Th process is using 20+GB of ram (on a 32GB RAM and 10 Core HyperThreading system).
What I am doing is locating the visio files in a specific directory, and then Parallel.ForEach on that collection. That way I am processing each file in it’s own thread.

I have done some investigation into this matter, and found that Diagrams .NET 18.8 roughly takes 2 seconds to save to any format in an regular single-thread foreach. However, when I parallelize it on my 20 core system, the time to save any format is steadily rising, which is also the case for memory, a steady climb to around 20 GB.

I have tried eliminating IO issues on save, by saving it to an memorystream, with not significant speedup.

Is there an syncronized/static save service inside the code?

@hellagutmanndk

Would you please create a narrowed down sample application reproducing this behavior so that we may try to reproduce, investigate and then share our findings with you.

I can give you the entire program, there are no secrets there :slight_smile:

In it’s current state it is initialized with a MaxDegreeOfParallelism being a quarter of the current available processors. (MaxDegreeOfParallelism = Environment.ProcessorCount / 4)

It also logs the duration of each save, and some other stuff.

VisioConverter.zip (302.0 KB)

@hellagutmanndk

Thank you for sharing requested data.

We have tried to work with eight VSDX files and the program finishes within 11 seconds while utilizing about 80MB of memory. Would you please share some test data along with values of utilized resources so that we may investigate further to help you out.

That is approximately 1,3 seconds per file. I am seeing around 2, when doing it single-threaded.

We are using vsd files (the old format).

I have attached some visio files (please remove the file after you have downloadet it)
Ford1.zip (3.0 MB)
Ford2.zip (7.9 MB)
Ford3.zip (9.2 MB)

Some files may be too old to convert. Let me know if all of these files can’t be converted.

I will get some more specific information to you shortly.

@hellagutmanndk

Thank you for sharing requested data.

We have been able to convert the files included in Ford1.zip and Ford2.zip and processing these files consumes about 51 seconds and 140 seconds with 484 MB and 561 MB of memory consumption respectively. The files in Ford3.zip directory do not convert because they are too old. Would you please share the application that you have used to compare the same process in single threaded environment so that we may investigate further. Please also mention the number of seconds and amount of memory consumed, to elaborate the steady rise you have referred to in your post.

that is the exact same application, just with compiler flag DEBUG being unset (building it in release mode would do the trick). Or removing an ! in #if !DEBUG statements in program.cs

@hellagutmanndk

We have tested it by removing ! sign as suggested by you. However, there is not much difference in terms of utilized time and memory when multi-threading approach is used. Below are some values for your kind reference.

Multi-threaded processing:

  • Ford1.zip: (3 files) 51 seconds and 484 MB
  • Ford2.zip: (8 files) 2 min 19 seconds and 561 MB

Single threaded processing:

  • Ford1.zip: (3 files) 49 seconds and 601 MB
  • Ford2.zip: (8 files) 2 minutes 16 seconds and 590 MB

These tests have been conducted in Windows 10, x64 Environment with .NET Framework 4.6.1, 8 GB installed RAM and Core i5 processor. Please share the values of consumed time and memory if you are still facing drastic change in utilized resources.

Interesting that the multi-threaded version take longer to process the files…

I just tried running the same set of files as you, and this is my findings:
Multi-threaded:

  • Ford1.zip: (3 files) 15 seconds, 888 MB
  • Ford2.zip: (8 files) 33 seconds, 2.3 GB

Single-thread:

  • Ford1.zip: (3 files) 29 sec, and 280 MB
  • Ford2.zip: (8 files) 1 min 12 sec, and 300 MB

This is on a 20 proc (10 core) Xeon E5-2630 v4 @ 2.20 GHz (running at 2.4GHz) with 32 GB ram. The application is targeting 4.7.1 on a Server 2016 Standard.

I see a great time saving when multi-threading a few files, but we have an initial run on 60.000+ files. After a while (12 hours+) the process is using 20+ GB ram, and each file is taking minutes to convert/save.

I also tried a batch with 995 files, both files that it can convert and files it can’t both too old, and some with other errors. It took 57 minutes and was using upto 16GB ram.

I have attached my perf logging file: perf.zip (19.0 KB)

Each file has 4 lines, starting with the process’s workingset in bytes, then the time to save each format.

@hellagutmanndk

We have logged an investigation ticket with ID DIAGRAMNET-51517 in our issue management system. We will let you know as soon as some significant updates will be available, or we will request you if any further information is required. Please be patient and spare us little time.