Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PPL Container performance

I am writing a Server application which takes data from multiple sources at once and stores it in it's internal database (currently a std::set).

I have just been looking at Microsoft's ConcRT PPL data structures and wondering about how their efficiency compares to using a fine-grained mutex on a std::unordered_set. For example, is there much of a performance difference between the two code snippets:

void StdWithMutex( void )
{
     std::ofstream outFile( "Test.tmp" );

     std::lock_guard<std::mutex> lockGuard( m_mutex );

     // Iterate through the data and write it to a file:
     // m_setData is of type std::unordered_set<DataType>
     for( auto data : m_setData )
     {
          outFile << data;
     }
}

And:

void ConcRT( void )
{
     std::ofstream outFile( "Test.tmp" );

     // Iterate through the data and write it to a file:
     // m_setData is of type concurrency::concurrent_unordered_set
     for( auto data : m_setData )
     {
          outFile << data;
     }
}

Moveover, I often need to print the data out in order, which is why I'm currently using std::set as opposed to std::unordered_set, so if there is a gain in using concurrency::concurrent_unordered_set, would the potential performance gain come close to the cost of reordering the data each time it needs to be printed?

like image 402
Thomas Russell Avatar asked Jun 17 '13 17:06

Thomas Russell


People also ask

How is Docker container performance measured?

You can use the docker stats command to live stream a container's runtime metrics. The command supports CPU, memory usage, memory limit, and network IO metrics. The docker stats reference page has more details about the docker stats command.

Do you lose performance with Docker?

Inadequately Allocated Resources. When Docker containers do not have access to enough resources, they quickly experience performance issues. Depending on the average image size of a project and the number of containers you are running, the hosts and network need to be able to support the workload.

Which is better VM or container?

Containers are more lightweight than VMs, as their images are measured in megabytes rather than gigabytes. Containers require fewer IT resources to deploy, run, and manage. Containers spin up in milliseconds. Since their order of magnitude is smaller.

Is Docker slower than bare metal?

Docker containers are not the fastest: While Docker is faster than virtual machines, it is still not as fast as an actual, bare-metal machine. There are various performance overheads associated with containers, primarily due to networking, communication between containers and host systems, and more.


1 Answers

Yes there is a huge difference. Try to run 100 threads in parallel writing and reading from this container and you will see the difference.

the PPL container does not lock -> it will be faster (it is probably wait free too, or using an improved allocator, while STL not except if you specified this allocator)

In single thread enrivronement although it is possible that the overhead of the lock is smaller than the one of the PPL container.

(in the same kind of idea the concurrent queue of coost or concurrent containers of TBB (intel) will be faster than STL containers which may all lock)

like image 149
dzada Avatar answered Nov 02 '22 03:11

dzada