Skip to content

Commit e99f334

Browse files
authored
Merge pull request #1500 from joto/node-location-for-pgsql-middle
Use new node_location_t in pgsql middle as cache
2 parents 76b032f + 1ff6e4c commit e99f334

File tree

13 files changed

+20
-833
lines changed

13 files changed

+20
-833
lines changed

docs/osm2pgsql.1

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -202,25 +202,7 @@ Defaults to 800.
202202
.RE
203203
.TP
204204
.B \-\-cache\-strategy=STRATEGY
205-
There are a number of different modes in which osm2pgsql can organize
206-
its node cache in RAM.
207-
These are optimized for different assumptions of the data and the
208-
hardware resources available.
209-
Currently available strategies are \f[B]dense\f[], \f[B]chunked\f[],
210-
\f[B]sparse\f[] and \f[B]optimized\f[].
211-
\f[B]dense\f[] assumes that the node id numbers are densely packed,
212-
i.e.\ only a few IDs in the range are missing / deleted.
213-
For planet extracts this is usually not the case, making the cache very
214-
inefficient and wasteful of RAM.
215-
\f[B]sparse\f[] assumes node IDs in the data are not densely packed,
216-
greatly increasing caching efficiency in these cases.
217-
If node IDs are densely packed, like in the full planet, this strategy
218-
has a higher overhead for indexing the cache.
219-
\f[B]optimized\f[] uses both dense and sparse strategies for different
220-
ranges of the ID space.
221-
On a block by block basis it tries to determine if it is more effective
222-
to store the block of IDs in sparse or dense mode.
223-
This is the default and should be typically used.
205+
This deprecated option will be ignored.
224206
.RS
225207
.RE
226208
.TP

docs/osm2pgsql.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,19 +144,7 @@ mandatory for short options too.
144144
Defaults to 800.
145145

146146
\--cache-strategy=STRATEGY
147-
: There are a number of different modes in which osm2pgsql can organize its
148-
node cache in RAM. These are optimized for different assumptions of the data
149-
and the hardware resources available. Currently available strategies are
150-
**dense**, **chunked**, **sparse** and **optimized**. **dense** assumes
151-
that the node id numbers are densely packed, i.e. only a few IDs in the range are
152-
missing / deleted. For planet extracts this is usually not the case, making the cache
153-
very inefficient and wasteful of RAM. **sparse** assumes node IDs in the data
154-
are not densely packed, greatly increasing caching efficiency in these cases.
155-
If node IDs are densely packed, like in the full planet, this strategy has a higher
156-
overhead for indexing the cache. **optimized** uses both dense and sparse strategies
157-
for different ranges of the ID space. On a block by block basis it tries to determine
158-
if it is more effective to store the block of IDs in sparse or dense mode. This is the
159-
default and should be typically used.
147+
: This deprecated option will be ignored.
160148

161149
-x, \--extra-attributes
162150
: Include attributes of each object in the middle tables and make them

src/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ set(osm2pgsql_lib_SOURCES
1313
middle-ram.cpp
1414
node-locations.cpp
1515
node-persistent-cache.cpp
16-
node-ram-cache.cpp
1716
options.cpp
1817
ordered-index.cpp
1918
osmdata.cpp

src/middle-pgsql.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include "logging.hpp"
3333
#include "middle-pgsql.hpp"
3434
#include "node-persistent-cache.hpp"
35-
#include "node-ram-cache.hpp"
3635
#include "options.hpp"
3736
#include "osmtypes.hpp"
3837
#include "pgsql-helper.hpp"
@@ -587,7 +586,7 @@ void middle_pgsql_t::after_relations()
587586
}
588587

589588
middle_query_pgsql_t::middle_query_pgsql_t(
590-
std::string const &conninfo, std::shared_ptr<node_ram_cache> const &cache,
589+
std::string const &conninfo, std::shared_ptr<node_locations_t> const &cache,
591590
std::shared_ptr<node_persistent_cache> const &persistent_cache)
592591
: m_sql_conn(conninfo), m_cache(cache), m_persistent_cache(persistent_cache)
593592
{
@@ -782,8 +781,8 @@ static bool check_bucket_index(pg_conn_t *db_connection,
782781

783782
middle_pgsql_t::middle_pgsql_t(options_t const *options)
784783
: m_options(options),
785-
m_cache(new node_ram_cache{options->alloc_chunkwise | ALLOC_LOSSY,
786-
options->cache}),
784+
m_cache(new node_locations_t{static_cast<std::size_t>(options->cache) *
785+
1024UL * 1024UL}),
787786
m_db_connection(m_options->database_options.conninfo()),
788787
m_copy_thread(
789788
std::make_shared<db_copy_thread_t>(options->database_options.conninfo())),

src/middle-pgsql.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
#include "db-copy-mgr.hpp"
2626
#include "middle.hpp"
27+
#include "node-locations.hpp"
2728
#include "node-persistent-cache.hpp"
28-
#include "node-ram-cache.hpp"
2929
#include "options.hpp"
3030
#include "pgsql.hpp"
3131

@@ -34,7 +34,7 @@ class middle_query_pgsql_t : public middle_query_t
3434
public:
3535
middle_query_pgsql_t(
3636
std::string const &conninfo,
37-
std::shared_ptr<node_ram_cache> const &cache,
37+
std::shared_ptr<node_locations_t> const &cache,
3838
std::shared_ptr<node_persistent_cache> const &persistent_cache);
3939

4040
size_t nodes_get_list(osmium::WayNodeList *nodes) const override;
@@ -55,7 +55,7 @@ class middle_query_pgsql_t : public middle_query_t
5555
std::size_t get_way_node_locations_db(osmium::WayNodeList *nodes) const;
5656

5757
pg_conn_t m_sql_conn;
58-
std::shared_ptr<node_ram_cache> m_cache;
58+
std::shared_ptr<node_locations_t> m_cache;
5959
std::shared_ptr<node_persistent_cache> m_persistent_cache;
6060
};
6161

@@ -147,7 +147,7 @@ struct middle_pgsql_t : public middle_t
147147

148148
options_t const *m_options;
149149

150-
std::shared_ptr<node_ram_cache> m_cache;
150+
std::shared_ptr<node_locations_t> m_cache;
151151
std::shared_ptr<node_persistent_cache> m_persistent_cache;
152152

153153
pg_conn_t m_db_connection;

0 commit comments

Comments
 (0)