Changeset 1200


Ignore:
Timestamp:
07/07/17 15:52:44 (7 years ago)
Author:
rlacroix
Message:

Improve the buffer size estimation.

This in fact reverts r1190 but with an improved version of the old code to avoid mispredicting the maximum number of bufferable events.

Also add comments so that I don't remove that code again in 6 months...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/context.cpp

    r1191 r1200  
    268268   void CContext::setClientServerBuffer() 
    269269   { 
    270      size_t minBufferSize = CXios::minBufferSize; 
     270     // Estimated minimum event size for small events (10 is an arbitrary constant just for safety) 
     271     const size_t minEventSize = CEventClient::headerSize + getIdServer().size() + 10 * sizeof(int); 
     272     // Ensure there is at least some room for 20 of such events in the buffers 
     273     size_t minBufferSize = std::max(CXios::minBufferSize, 20 * minEventSize); 
    271274#define DECLARE_NODE(Name_, name_)    \ 
    272275     if (minBufferSize < sizeof(C##Name_##Definition)) minBufferSize = sizeof(C##Name_##Definition); 
     
    276279#undef DECLARE_NODE_PAR 
    277280 
     281     // Compute the buffer sizes needed to send the attributes and data corresponding to fields 
    278282     std::map<int, StdSize> maxEventSize; 
    279283     std::map<int, StdSize> bufferSize = getAttributesBufferSize(maxEventSize); 
     
    284288       if (it->second > bufferSize[it->first]) bufferSize[it->first] = it->second; 
    285289 
     290     // Apply the buffer size factor and check that we are above the minimum buffer size 
    286291     ite = bufferSize.end(); 
    287292     for (it = bufferSize.begin(); it != ite; ++it) 
     
    289294       it->second *= CXios::bufferSizeFactor; 
    290295       if (it->second < minBufferSize) it->second = minBufferSize; 
     296     } 
     297 
     298     // Leaders will have to send some control events so ensure there is some room for those in the buffers 
     299     if (client->isServerLeader()) 
     300     { 
     301       const std::list<int>& ranks = client->getRanksServerLeader(); 
     302       for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     303       { 
     304         if (!bufferSize.count(*itRank)) 
     305         { 
     306           bufferSize[*itRank] = minBufferSize; 
     307           maxEventSize[*itRank] = minEventSize; 
     308         } 
     309       } 
    291310     } 
    292311 
Note: See TracChangeset for help on using the changeset viewer.