Changeset 599 for trunk/server/lib/tdb/common/io.c
- Timestamp:
- Jul 6, 2011, 8:21:13 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/lib/tdb/common/io.c
r456 r599 320 320 { 321 321 struct tdb_record rec; 322 tdb_off_t offset, new_size ;322 tdb_off_t offset, new_size, top_size, map_size; 323 323 324 324 if (tdb_lock(tdb, -1, F_WRLCK) == -1) { … … 330 330 tdb->methods->tdb_oob(tdb, tdb->map_size + 1, 1); 331 331 332 /* always make room for at least 100 more records, and at 333 least 25% more space. Round the database up to a multiple 334 of the page size */ 335 new_size = MAX(tdb->map_size + size*100, tdb->map_size * 1.25); 332 /* limit size in order to avoid using up huge amounts of memory for 333 * in memory tdbs if an oddball huge record creeps in */ 334 if (size > 100 * 1024) { 335 top_size = tdb->map_size + size * 2; 336 } else { 337 top_size = tdb->map_size + size * 100; 338 } 339 340 /* always make room for at least top_size more records, and at 341 least 25% more space. if the DB is smaller than 100MiB, 342 otherwise grow it by 10% only. */ 343 if (tdb->map_size > 100 * 1024 * 1024) { 344 map_size = tdb->map_size * 1.10; 345 } else { 346 map_size = tdb->map_size * 1.25; 347 } 348 349 /* Round the database up to a multiple of the page size */ 350 new_size = MAX(top_size, map_size); 336 351 size = TDB_ALIGN(new_size, tdb->page_size) - tdb->map_size; 337 352
Note:
See TracChangeset
for help on using the changeset viewer.