Merge pull request #683 from gardster/nomem_routing_fix

Nomem routing fix.
This commit is contained in:
Sergey Yershov 2015-12-08 11:06:50 +03:00
commit 0d54e7a5b4
3 changed files with 10 additions and 6 deletions

View file

@ -4,6 +4,8 @@
#include "coding/internal/file_data.hpp"
#ifndef OMIM_OS_WINDOWS
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/stat.h>
@ -169,7 +171,7 @@ MappedFile::Handle MappedFile::Map(uint64_t offset, uint64_t size, string const
#else
void * pMap = mmap(0, length, PROT_READ, MAP_SHARED, m_fd, alignedOffset);
if (pMap == MAP_FAILED)
MYTHROW(Reader::OpenException, ("Can't map section:", tag, "with [offset, size]:", offset, size));
MYTHROW(Reader::OpenException, ("Can't map section:", tag, "with [offset, size]:", offset, size, "errno:", strerror(errno)));
#endif
char const * data = reinterpret_cast<char const *>(pMap);

View file

@ -272,6 +272,10 @@ public:
{
Clear();
// Map huge data first, as we hope it will reduce fragmentation of the program address space.
m_handleFanoMatrix.Assign(container.Map(ROUTING_MATRIX_FILE_TAG));
ASSERT(m_handleFanoMatrix.IsValid(), ());
m_handleEdgeData.Assign(container.Map(ROUTING_EDGEDATA_FILE_TAG));
ASSERT(m_handleEdgeData.IsValid(), ());
@ -281,11 +285,7 @@ public:
m_handleShortcuts.Assign(container.Map(ROUTING_SHORTCUTS_FILE_TAG));
ASSERT(m_handleShortcuts.IsValid(), ());
m_handleFanoMatrix.Assign(container.Map(ROUTING_MATRIX_FILE_TAG));
ASSERT(m_handleFanoMatrix.IsValid(), ());
LoadRawData(m_handleEdgeData.GetData<char>(), m_handleEdgeId.GetData<char>(), m_handleShortcuts.GetData<char>(), m_handleFanoMatrix.GetData<char>());
}
void Clear()

View file

@ -222,7 +222,6 @@ OsrmRouter::ResultCode OsrmRouter::CalculateRoute(m2::PointD const & startPoint,
RouterDelegate const & delegate, Route & route)
{
my::HighResTimer timer(true);
m_indexManager.Clear(); // TODO (Dragunov) make proper index manager cleaning
TRoutingMappingPtr startMapping = m_indexManager.GetMappingByPoint(startPoint);
TRoutingMappingPtr targetMapping = m_indexManager.GetMappingByPoint(finalPoint);
@ -286,6 +285,9 @@ OsrmRouter::ResultCode OsrmRouter::CalculateRoute(m2::PointD const & startPoint,
// 4. Find route.
RawRoutingResult routingResult;
// Manually load facade to avoid unmaping files we routing on.
startMapping->LoadFacade();
// 4.1 Single mwm case
if (startMapping->GetMwmId() == targetMapping->GetMwmId())
{