Skip to content

Commit e926b20

Browse files
Dan PasetteDan Pasette
authored andcommitted
Import wiredtiger-wiredtiger-mongodb-2.8-rc6-47-g5b3283e.tar.gz from wiredtiger branch mongodb-2.8
1 parent ae25857 commit e926b20

39 files changed

+509
-317
lines changed

src/third_party/wiredtiger/dist/api_data.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,18 @@ def __cmp__(self, other):
309309
]),
310310
Config('cache_size', '100MB', r'''
311311
maximum heap memory to allocate for the cache. A database should
312-
configure either a cache_size or a shared_cache not both''',
312+
configure either \c cache_size or \c shared_cache but not both''',
313313
min='1MB', max='10TB'),
314+
Config('cache_overhead', '8', r'''
315+
assume the heap allocator overhead is the specified percentage, and
316+
adjust the cache size by that amount (for example, if the cache size is
317+
100GB, a percentage of 10 means WiredTiger limits itself to allocating
318+
90GB of memory). This value is configurable because different heap
319+
allocators have different overhead and different workloads will have
320+
different heap allocation sizes and patterns, therefore applications
321+
may need to adjust this value based on allocator choice and behavior
322+
in measured workloads''',
323+
min='0', max='30'),
314324
Config('checkpoint', '', r'''
315325
periodically checkpoint the database''',
316326
type='category', subconfig=[

src/third_party/wiredtiger/dist/s_all

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ run "sh ./s_copyright" "checking copyright notices"
6969
run "sh ./s_define" "checking for unused #defines"
7070
run "sh ./s_funcs" "checking for unused functions"
7171
run "sh ./s_getopt" "checking for incorrect getopt usage"
72+
run "sh ./s_lang" "checking for SWIG generated name conflicts"
7273
run "sh ./s_longlines" "checking for long lines"
7374
run "sh ./s_stat" "checking for unused statistics fields"
7475
run "sh ./s_string" "checking string spelling"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#! /bin/sh
2+
3+
# Check lang directories for potential name conflicts
4+
t=__wt.$$
5+
trap 'rm -f $t; exit 0' 0 1 2 3 13 15
6+
7+
cd ../lang
8+
9+
for d in *; do
10+
f=`find $d -name 'wiredtiger_wrap.c'`
11+
test -z "$f" && continue
12+
13+
sed -e '/SWIGINTERN.*__wt_[a-z][a-z]*_[a-z]/!d' \
14+
-e '/__wt_[^(]*__.*(/d' \
15+
-e '/_wrap/d' \
16+
-e "/_${d}_/d" \
17+
$f > $t
18+
19+
test -s $t && {
20+
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
21+
echo "$l: potential SWIG naming conflict"
22+
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
23+
cat $t
24+
}
25+
done

src/third_party/wiredtiger/dist/s_string.ok

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Crummey
7373
CustomersPhone
7474
DATAITEMs
7575
DECL
76+
DECR
7677
DESC
7778
DHANDLE
7879
DLFCN
@@ -397,6 +398,7 @@ agc
397398
alfred
398399
alloc
399400
allocator
401+
allocators
400402
allocfile
401403
allocsize
402404
amd

src/third_party/wiredtiger/dist/stat_data.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,10 @@ def __init__(self, name, desc, flags=''):
182182
'eviction server unable to reach eviction goal'),
183183
CacheStat('cache_eviction_split', 'pages split during eviction'),
184184
CacheStat('cache_eviction_walk', 'pages walked for eviction'),
185+
CacheStat('cache_eviction_worker_evicting',
186+
'eviction worker thread evicting pages'),
185187
CacheStat('cache_inmem_split', 'in-memory page splits'),
188+
CacheStat('cache_overhead', 'percentage overhead', 'no_clear,no_scale'),
186189
CacheStat('cache_pages_dirty',
187190
'tracked dirty pages in the cache', 'no_scale'),
188191
CacheStat('cache_pages_inuse',

src/third_party/wiredtiger/lang/python/wiredtiger.i

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ from packing import pack, unpack
157157
%define DESTRUCTOR(class, method)
158158
%feature("shadow") class::method %{
159159
def method(self, *args):
160-
'''close(self, config) -> int
160+
'''method(self, config) -> int
161161
162162
@copydoc class::method'''
163163
try:
@@ -171,6 +171,26 @@ DESTRUCTOR(__wt_connection, close)
171171
DESTRUCTOR(__wt_cursor, close)
172172
DESTRUCTOR(__wt_session, close)
173173

174+
/*
175+
* OVERRIDE_METHOD must be used when overriding or extending an existing
176+
* method in the C interface. It creates Python method() that calls
177+
* _method(), which is the extended version of the method. This works
178+
* around potential naming conflicts. Without this technique, for example,
179+
* defining __wt_cursor::equals() creates the wrapper function
180+
* __wt_cursor_equals(), which may be defined in the WT library.
181+
*/
182+
%define OVERRIDE_METHOD(cclass, pyclass, method, pyargs)
183+
%extend cclass {
184+
%pythoncode %{
185+
def method(self, *args):
186+
'''method pyargs -> int
187+
188+
@copydoc class::method'''
189+
return self._##method(*args)
190+
%}
191+
};
192+
%enddef
193+
174194
/* Don't require empty config strings. */
175195
%typemap(default) const char *config { $1 = NULL; }
176196
%typemap(default) WT_CURSOR *to_dup { $1 = NULL; }
@@ -389,9 +409,9 @@ NOTFOUND_OK(__wt_cursor::remove)
389409
NOTFOUND_OK(__wt_cursor::search)
390410
NOTFOUND_OK(__wt_cursor::update)
391411

392-
COMPARE_OK(__wt_cursor::compare)
393-
COMPARE_OK(__wt_cursor::equals)
394-
COMPARE_NOTFOUND_OK(__wt_cursor::search_near)
412+
COMPARE_OK(__wt_cursor::_compare)
413+
COMPARE_OK(__wt_cursor::_equals)
414+
COMPARE_NOTFOUND_OK(__wt_cursor::_search_near)
395415

396416
/* Lastly, some methods need no (additional) error checking. */
397417
%exception __wt_connection::get_home;
@@ -428,6 +448,10 @@ COMPARE_NOTFOUND_OK(__wt_cursor::search_near)
428448
%ignore __wt_cursor::equals(WT_CURSOR *, WT_CURSOR *, int *);
429449
%ignore __wt_cursor::search_near(WT_CURSOR *, int *);
430450

451+
OVERRIDE_METHOD(__wt_cursor, WT_CURSOR, compare, (self, other))
452+
OVERRIDE_METHOD(__wt_cursor, WT_CURSOR, equals, (self, other))
453+
OVERRIDE_METHOD(__wt_cursor, WT_CURSOR, search_near, (self))
454+
431455
/* SWIG magic to turn Python byte strings into data / size. */
432456
%apply (char *STRING, int LENGTH) { (char *data, int size) };
433457

@@ -685,7 +709,7 @@ typedef int int_void;
685709
}
686710

687711
/* compare: special handling. */
688-
int compare(WT_CURSOR *other) {
712+
int _compare(WT_CURSOR *other) {
689713
int cmp = 0;
690714
int ret = 0;
691715
if (other == NULL) {
@@ -709,7 +733,7 @@ typedef int int_void;
709733
}
710734

711735
/* equals: special handling. */
712-
int equals(WT_CURSOR *other) {
736+
int _equals(WT_CURSOR *other) {
713737
int cmp = 0;
714738
int ret = 0;
715739
if (other == NULL) {
@@ -728,7 +752,7 @@ typedef int int_void;
728752
}
729753

730754
/* search_near: special handling. */
731-
int search_near() {
755+
int _search_near() {
732756
int cmp = 0;
733757
int ret = $self->search_near($self, &cmp);
734758
/*
@@ -828,7 +852,7 @@ typedef int int_void;
828852
};
829853

830854
%extend __wt_session {
831-
int log_printf(const char *msg) {
855+
int _log_printf(const char *msg) {
832856
return self->log_printf(self, "%s", msg);
833857
}
834858

@@ -892,6 +916,8 @@ int verbose_build();
892916
%ignore __wt_connection::get_extension_api;
893917
%ignore __wt_session::log_printf;
894918

919+
OVERRIDE_METHOD(__wt_session, WT_SESSION, log_printf, (self, msg))
920+
895921
%ignore wiredtiger_struct_pack;
896922
%ignore wiredtiger_struct_size;
897923
%ignore wiredtiger_struct_unpack;

src/third_party/wiredtiger/src/block/block_compact.c

Lines changed: 52 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ __wt_block_compact_end(WT_SESSION_IMPL *session, WT_BLOCK *block)
5050
block->allocfirst = block->allocfirst_save;
5151
__wt_spin_unlock(session, &block->live_lock);
5252

53+
block->compact_pct_tenths = 0;
54+
5355
return (0);
5456
}
5557

@@ -64,7 +66,7 @@ __wt_block_compact_skip(WT_SESSION_IMPL *session, WT_BLOCK *block, int *skipp)
6466
WT_EXT *ext;
6567
WT_EXTLIST *el;
6668
WT_FH *fh;
67-
wt_off_t avail, ninety;
69+
wt_off_t avail_eighty, avail_ninety, eighty, ninety;
6870

6971
*skipp = 1; /* Return a default skip. */
7072

@@ -84,31 +86,53 @@ __wt_block_compact_skip(WT_SESSION_IMPL *session, WT_BLOCK *block, int *skipp)
8486
if (WT_VERBOSE_ISSET(session, WT_VERB_COMPACT))
8587
WT_ERR(__block_dump_avail(session, block));
8688

87-
/* Sum the number of available bytes in the first 90% of the file. */
88-
avail = 0;
89+
/* Sum the available bytes in the first 80% and 90% of the file. */
90+
avail_eighty = avail_ninety = 0;
8991
ninety = fh->size - fh->size / 10;
92+
eighty = fh->size - ((fh->size / 10) * 2);
9093

9194
el = &block->live.avail;
9295
WT_EXT_FOREACH(ext, el->off)
93-
if (ext->off < ninety)
94-
avail += ext->size;
95-
96-
/*
97-
* If at least 10% of the total file is available and in the first 90%
98-
* of the file, we'll try compaction.
99-
*/
100-
if (avail >= fh->size / 10)
101-
*skipp = 0;
96+
if (ext->off < ninety) {
97+
avail_ninety += ext->size;
98+
if (ext->off < eighty)
99+
avail_eighty += ext->size;
100+
}
102101

103102
WT_ERR(__wt_verbose(session, WT_VERB_COMPACT,
104103
"%s: %" PRIuMAX "MB (%" PRIuMAX ") available space in the first "
105-
"90%% of the file, require 10%% or %" PRIuMAX "MB (%" PRIuMAX
106-
") to perform compaction, compaction %s",
104+
"80%% of the file",
105+
block->name,
106+
(uintmax_t)avail_eighty / WT_MEGABYTE, (uintmax_t)avail_eighty));
107+
WT_ERR(__wt_verbose(session, WT_VERB_COMPACT,
108+
"%s: %" PRIuMAX "MB (%" PRIuMAX ") available space in the first "
109+
"90%% of the file",
110+
block->name,
111+
(uintmax_t)avail_ninety / WT_MEGABYTE, (uintmax_t)avail_ninety));
112+
WT_ERR(__wt_verbose(session, WT_VERB_COMPACT,
113+
"%s: require 10%% or %" PRIuMAX "MB (%" PRIuMAX ") in the first "
114+
"90%% of the file to perform compaction, compaction %s",
107115
block->name,
108-
(uintmax_t)avail / WT_MEGABYTE, (uintmax_t)avail,
109116
(uintmax_t)(fh->size / 10) / WT_MEGABYTE, (uintmax_t)fh->size / 10,
110117
*skipp ? "skipped" : "proceeding"));
111118

119+
/*
120+
* If at least 20% of the total file is available and in the first 80%
121+
* of the file, we'll try compaction on the last 20% of the file; else,
122+
* if at least 10% of the total file is available and in the first 90%
123+
* of the file, we'll try compaction on the last 10% of the file.
124+
*
125+
* We could push this further, but there's diminishing returns, a mostly
126+
* empty file can be processed quickly, so more aggressive compaction is
127+
* less useful.
128+
*/
129+
if (avail_ninety >= fh->size / 10) {
130+
*skipp = 0;
131+
block->compact_pct_tenths = 1;
132+
if (avail_eighty >= ((fh->size / 10) * 2))
133+
block->compact_pct_tenths = 2;
134+
}
135+
112136
err: __wt_spin_unlock(session, &block->live_lock);
113137

114138
return (ret);
@@ -126,7 +150,7 @@ __wt_block_compact_page_skip(WT_SESSION_IMPL *session,
126150
WT_EXT *ext;
127151
WT_EXTLIST *el;
128152
WT_FH *fh;
129-
wt_off_t ninety, offset;
153+
wt_off_t limit, offset;
130154
uint32_t size, cksum;
131155

132156
WT_UNUSED(addr_size);
@@ -138,21 +162,24 @@ __wt_block_compact_page_skip(WT_SESSION_IMPL *session,
138162
WT_RET(__wt_block_buffer_to_addr(block, addr, &offset, &size, &cksum));
139163

140164
/*
141-
* If this block is in the last 10% of the file and there's a block on
142-
* the available list that's in the first 90% of the file, rewrite the
143-
* block. Checking the available list is necessary (otherwise writing
144-
* the block would extend the file), but there's an obvious race if the
145-
* file is sufficiently busy.
165+
* If this block is in the chosen percentage of the file and there's a
166+
* block on the available list that's appears before that percentage of
167+
* the file, rewrite the block. Checking the available list is
168+
* necessary (otherwise writing the block would extend the file), but
169+
* there's an obvious race if the file is sufficiently busy.
146170
*/
147171
__wt_spin_lock(session, &block->live_lock);
148-
ninety = fh->size - fh->size / 10;
149-
if (offset > ninety) {
172+
limit = fh->size - ((fh->size / 10) * block->compact_pct_tenths);
173+
if (offset > limit) {
150174
el = &block->live.avail;
151-
WT_EXT_FOREACH(ext, el->off)
152-
if (ext->off < ninety && ext->size >= size) {
175+
WT_EXT_FOREACH(ext, el->off) {
176+
if (ext->off >= limit)
177+
break;
178+
if (ext->size >= size) {
153179
*skipp = 0;
154180
break;
155181
}
182+
}
156183
}
157184
__wt_spin_unlock(session, &block->live_lock);
158185

src/third_party/wiredtiger/src/btree/bt_handle.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,8 @@ __btree_page_sizes(WT_SESSION_IMPL *session)
659659
* cache, it may not have been set.
660660
*/
661661
WT_RET(__wt_config_gets(session, cfg, "memory_page_max", &cval));
662-
btree->maxmempage = WT_MAX((uint64_t)cval.val, 50 * btree->maxleafpage);
662+
btree->maxmempage =
663+
WT_MAX((uint64_t)cval.val, 50 * (uint64_t)btree->maxleafpage);
663664
cache_size = S2C(session)->cache_size;
664665
if (cache_size > 0)
665666
btree->maxmempage = WT_MIN(btree->maxmempage, cache_size / 2);

src/third_party/wiredtiger/src/btree/bt_split.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* estimate of allocation overhead to every object.
1414
*/
1515
#define WT_MEMSIZE_ADD(total, len) do { \
16-
total += (len) + WT_ALLOC_OVERHEAD; \
16+
total += (len); \
1717
} while (0)
1818
#define WT_MEMSIZE_TRANSFER(from_decr, to_incr, len) do { \
1919
WT_MEMSIZE_ADD(from_decr, len); \
@@ -728,14 +728,6 @@ __split_multi_inmem(
728728
*/
729729
page->modify->first_dirty_txn = WT_TXN_FIRST;
730730

731-
/*
732-
* XXX Don't allow this page to be evicted immediately.
733-
*
734-
* In some cases involving forced eviction during truncates, a reader
735-
* ends up looking at an evicted page. This is a temporary workaround.
736-
*/
737-
page->modify->inmem_split_txn = __wt_txn_new_id(session);
738-
739731
err: /* Free any resources that may have been cached in the cursor. */
740732
WT_TRET(__wt_btcur_close(&cbt));
741733

@@ -889,8 +881,7 @@ __split_parent(WT_SESSION_IMPL *session, WT_REF *ref, WT_REF **ref_new,
889881
for (i = 0, deleted_entries = 0; i < parent_entries; ++i) {
890882
next_ref = pindex->index[i];
891883
WT_ASSERT(session, next_ref->state != WT_REF_SPLIT);
892-
if (next_ref->state == WT_REF_DELETED &&
893-
next_ref->page_del == NULL &&
884+
if (__wt_delete_page_skip(session, next_ref) &&
894885
WT_ATOMIC_CAS4(next_ref->state,
895886
WT_REF_DELETED, WT_REF_SPLIT))
896887
deleted_entries++;
@@ -986,6 +977,18 @@ __split_parent(WT_SESSION_IMPL *session, WT_REF *ref, WT_REF **ref_new,
986977
session, 0, ikey, size));
987978
WT_MEMSIZE_ADD(parent_decr, size);
988979
}
980+
/*
981+
* The page_del structure can be freed
982+
* immediately: it is only read when the ref
983+
* state is WT_REF_DELETED. The size of the
984+
* structures wasn't added to the parent: don't
985+
* decrement.
986+
*/
987+
if (next_ref->page_del != NULL) {
988+
__wt_free(session,
989+
next_ref->page_del->update_list);
990+
__wt_free(session, next_ref->page_del);
991+
}
989992
}
990993

991994
WT_TRET(__split_safe_free(

0 commit comments

Comments
 (0)