Skip to content

Commit 5af06a7

Browse files
authored
Merge pull request #961 from lonvia/harmonize-cache-documentation
put different advise on cache size in sync
2 parents 9d1e4f3 + d8ecb82 commit 5af06a7

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

docs/osm2pgsql.1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,11 @@ imported into database columns and which tags get dropped. Defaults to /usr/shar
112112
\fB\-C\fR|\-\-cache num
113113
Only for slim mode: Use up to num many MB of RAM for caching nodes. Giving osm2pgsql sufficient cache
114114
to store all imported nodes typically greatly increases the speed of the import. Each cached node
115-
requires 8 bytes of cache, plus about 10% \- 30% overhead. For a current OSM full planet import with
116-
its ~ 3 billion nodes, a good value would be 27000 if you have enough RAM. If you don't have enough
117-
RAM, it is likely beneficial to give osm2pgsql close to the full available amount of RAM. Defaults to 800.
115+
requires 8 bytes of cache, plus about 10% \- 30% overhead. As a rule of thumb,
116+
give a bit more than the size of the import file in PBF format. If the RAM is not
117+
big enough, use about 75% of memory. Make sure to leave enough RAM for PostgreSQL.
118+
It needs at least the amount of `shared_buffers` given in its configuration.
119+
Defaults to 800.
118120
.TP
119121
\fB\ \fR\-\-cache\-strategy strategy
120122
There are a number of different modes in which osm2pgsql can organize its

docs/usage.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,15 @@ use them.
2525
Performance is heavily influenced by other options, but there are some options
2626
that only impact performance.
2727

28-
* ``--cache`` specifies how much memory to allocate for caching information. In
29-
``--slim`` mode, this is just node positions while in non-slim it has to
30-
store information about ways and relations too. The maximum RAM it is useful
31-
to set this to in slim mode is 8 bytes * number of nodes / efficiency, where
32-
efficiency ranges from 50% on small imports to 80% for a planet.
28+
* ``--cache`` specifies how much memory in MB to allocate for caching information.
29+
In ``--slim`` mode, this is just node positions while in non-slim it has to
30+
store information about ways and relations too. The rule of thumb in slim mode
31+
is as follows: use the size of the PBF file you are trying to import or about
32+
75% of RAM, whatever is smaller. Make sure there is enough RAM left for
33+
PostgreSQL. It needs at least the amount of `shared_buffers` given in its
34+
configuration. You may also set ``--cache`` to 0 to disable node caching
35+
completely. This makes only sense when a flat node file is given and there
36+
is not enough RAM to fit most of the cache.
3337

3438
* ``--number-processes`` sets the number of processes to use. This should
3539
typically be set to the number of CPU threads, but gains in speed are minimal

options.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ namespace
227227
printf(" %s -c -d gis --slim -C <cache size> -k \\\n", name);
228228
printf(" --flat-nodes <flat nodes> planet-latest.osm.pbf\n");
229229
printf("where\n");
230-
printf(" <cache size> is 50000 on machines with 64GB or more RAM \n");
230+
printf(" <cache size> should be equivalent to the size of the \n");
231+
printf(" pbf file to be imported if there is enough RAM \n");
231232
printf(" or about 75%% of memory in MB on machines with less\n");
232233
printf(" <flat nodes> is a location where a 50+GB file can be saved.\n");
233234
printf("\n");

0 commit comments

Comments
 (0)