[Barrelfish-users] C++ standard library performance issue

Jialin Li nick.lijl at gmail.com
Tue Oct 20 00:07:44 CEST 2015


I'm running a server application on barrelfish(actually Arrakis). The 
server has to store some key value pairs so I used the standard library 
std::unordered_map. However, I was observing the server latency getting 
higher over time (with more key value pairs installed), from ~10us to a 
few ms. I wrote a toy program (shown below) just to validate the result. 
For the toy program, I also observed there are latency spikes every few 
operations, and the latency spike increases over time. I tried the same 
program on Linux and not seeing the same problem. For the C++ compiler, 
I am using tools/build-toolchain.sh, which I also attached.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <unordered_map>
#include <list>
#include <string>

#define ITERATION 50000

using namespace std;

void randString(char * buffer, int len) {
   for (int i = 0; i < len - 1; i++) {
     buffer[i] = '0'+(random()%74);

int main() {
   unordered_map<string, string> store;
   char keybuf[32];
   char valuebuf[128];
   struct timeval st, ed;
   memset(keybuf, 0, 32);
   memset(valuebuf, 0, 128);
   long int result;
   unsigned long before, after;

   for (long int k = 0; k < ITERATION; k++) {
     gettimeofday(&st, NULL);
     randString(keybuf, 32);
     randString(valuebuf, 128);

     string key(keybuf);
     string value(valuebuf);
     store[key] = value;

     gettimeofday(&ed, NULL);

     printf("latency %lu\n", 

Let me know if any more information is needed. Thanks in advance for the 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: build-toolchain.sh
Type: application/x-shellscript
Size: 4100 bytes
Desc: not available
URL: <http://lists.inf.ethz.ch/pipermail/barrelfish-users/attachments/20151019/70c5a724/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stdtest.cc
Type: text/x-c++src
Size: 861 bytes
Desc: not available
URL: <http://lists.inf.ethz.ch/pipermail/barrelfish-users/attachments/20151019/70c5a724/attachment-0001.bin>

More information about the Barrelfish-users mailing list