summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2021-11-05 17:03:34 +1100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-11-05 06:33:39 +0000
commitd95111ef044a8fb1a8a820e9e396e84f64088033 (patch)
tree185b13e44674eb77b9aa0d1fab883e6b13341316
parentaaae2fd469009f0a424d1788e5ecaf7ad6a5a785 (diff)
downloadmongo-d95111ef044a8fb1a8a820e9e396e84f64088033.tar.gz
Import wiredtiger: 57cbf83a794976ed443d0f0a493147fe7d70800c from branch mongodb-master
ref: 5339c184e8..57cbf83a79 for: 5.2.0 WT-8342 Coverity: CID 121074: UNINTENDED_INTEGER_DIVISION in src/support/float.c
-rw-r--r--src/third_party/wiredtiger/dist/filelist1
-rw-r--r--src/third_party/wiredtiger/import.data2
-rw-r--r--src/third_party/wiredtiger/src/block/block_cache.c32
-rw-r--r--src/third_party/wiredtiger/src/include/block_cache.h18
-rw-r--r--src/third_party/wiredtiger/src/include/extern.h1
-rw-r--r--src/third_party/wiredtiger/src/support/float.c45
6 files changed, 24 insertions, 75 deletions
diff --git a/src/third_party/wiredtiger/dist/filelist b/src/third_party/wiredtiger/dist/filelist
index 0d6bc232e4c..a37d0e116e0 100644
--- a/src/third_party/wiredtiger/dist/filelist
+++ b/src/third_party/wiredtiger/dist/filelist
@@ -202,7 +202,6 @@ src/support/hash_fnv.c
src/support/hazard.c
src/support/hex.c
src/support/huffman.c
-src/support/float.c
src/support/lock_ext.c
src/support/modify.c
src/support/mtx_rw.c
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data
index cfca5b7b9b6..5e22f5226ec 100644
--- a/src/third_party/wiredtiger/import.data
+++ b/src/third_party/wiredtiger/import.data
@@ -2,5 +2,5 @@
"vendor": "wiredtiger",
"github": "wiredtiger/wiredtiger.git",
"branch": "mongodb-master",
- "commit": "5339c184e86d5bc64706b5d7c6fd60ccd5cf60e5"
+ "commit": "57cbf83a794976ed443d0f0a493147fe7d70800c"
}
diff --git a/src/third_party/wiredtiger/src/block/block_cache.c b/src/third_party/wiredtiger/src/block/block_cache.c
index ff1486bc6a5..b0e060b6d19 100644
--- a/src/third_party/wiredtiger/src/block/block_cache.c
+++ b/src/third_party/wiredtiger/src/block/block_cache.c
@@ -127,14 +127,12 @@ static inline bool
__blkcache_high_overhead(WT_SESSION_IMPL *session)
{
WT_BLKCACHE *blkcache;
+ uint64_t ops;
blkcache = &S2C(session)->blkcache;
- if ((double)(blkcache->inserts + blkcache->removals) / (double)(blkcache->lookups) >
- (double)blkcache->overhead_pct)
- return (true);
-
- return (false);
+ ops = blkcache->inserts + blkcache->removals;
+ return (blkcache->lookups > ops && ((ops * 100) / blkcache->lookups) > blkcache->overhead_pct);
}
/*
@@ -343,8 +341,8 @@ __wt_blkcache_get_or_check(
* If more than the configured fraction of all file objects is likely to fit in the OS buffer
* cache, don't use this cache.
*/
- if (blkcache->system_ram >=
- __blkcache_estimate_filesize(session) * blkcache->fraction_in_os_cache) {
+ if ((__blkcache_estimate_filesize(session) * blkcache->percent_file_in_os_cache) / 100 <
+ blkcache->system_ram) {
WT_STAT_CONN_INCR(session, block_cache_bypass_get);
return (WT_BLKCACHE_BYPASS);
}
@@ -428,8 +426,8 @@ __wt_blkcache_put(WT_SESSION_IMPL *session, wt_off_t offset, size_t size, uint32
* If more than the configured fraction of the file is likely to fit into the OS buffer cache,
* don't use this cache.
*/
- if (blkcache->system_ram >=
- __blkcache_estimate_filesize(session) * blkcache->fraction_in_os_cache) {
+ if ((__blkcache_estimate_filesize(session) * blkcache->percent_file_in_os_cache) / 100 <
+ blkcache->system_ram) {
WT_STAT_CONN_INCR(session, block_cache_bypass_put);
return (WT_BLKCACHE_BYPASS);
}
@@ -591,7 +589,7 @@ __wt_blkcache_remove(WT_SESSION_IMPL *session, wt_off_t offset, size_t size, uin
static int
__blkcache_init(WT_SESSION_IMPL *session, size_t cache_size, u_int hash_size, u_int type,
char *nvram_device_path, size_t system_ram, u_int percent_file_in_os_cache, bool cache_on_writes,
- float overhead_pct, u_int evict_aggressive, uint64_t full_target, bool cache_on_checkpoint)
+ u_int overhead_pct, u_int evict_aggressive, uint64_t full_target, bool cache_on_checkpoint)
{
WT_BLKCACHE *blkcache;
WT_DECL_RET;
@@ -601,7 +599,7 @@ __blkcache_init(WT_SESSION_IMPL *session, size_t cache_size, u_int hash_size, u_
blkcache->cache_on_checkpoint = cache_on_checkpoint;
blkcache->cache_on_writes = cache_on_writes;
blkcache->hash_size = hash_size;
- blkcache->fraction_in_os_cache = (float)percent_file_in_os_cache / 100;
+ blkcache->percent_file_in_os_cache = percent_file_in_os_cache;
blkcache->full_target = full_target;
blkcache->max_bytes = cache_size;
blkcache->overhead_pct = overhead_pct;
@@ -726,7 +724,7 @@ done:
static int
__blkcache_reconfig(WT_SESSION_IMPL *session, bool reconfig, size_t cache_size, size_t hash_size,
u_int type, char *nvram_device_path, size_t system_ram, u_int percent_file_in_os_cache,
- bool cache_on_writes, float overhead_pct, u_int evict_aggressive, uint64_t full_target,
+ bool cache_on_writes, u_int overhead_pct, u_int evict_aggressive, uint64_t full_target,
bool cache_on_checkpoint)
{
WT_BLKCACHE *blkcache;
@@ -738,10 +736,9 @@ __blkcache_reconfig(WT_SESSION_IMPL *session, bool reconfig, size_t cache_size,
if (blkcache->cache_on_checkpoint != cache_on_checkpoint ||
blkcache->cache_on_writes != cache_on_writes || blkcache->hash_size != hash_size ||
- __wt_floatcmp(blkcache->fraction_in_os_cache, (float)percent_file_in_os_cache / 100) != 0 ||
+ blkcache->percent_file_in_os_cache != percent_file_in_os_cache ||
blkcache->full_target != full_target || blkcache->max_bytes != cache_size ||
- __wt_floatcmp(blkcache->overhead_pct, overhead_pct) != 0 ||
- blkcache->system_ram != system_ram ||
+ blkcache->overhead_pct != overhead_pct || blkcache->system_ram != system_ram ||
blkcache->evict_aggressive != -((int)evict_aggressive) || blkcache->type != type ||
(nvram_device_path != NULL && blkcache->nvram_device_path == NULL) ||
(nvram_device_path == NULL && blkcache->nvram_device_path != NULL) ||
@@ -765,9 +762,8 @@ __wt_block_cache_setup(WT_SESSION_IMPL *session, const char *cfg[], bool reconfi
WT_BLKCACHE *blkcache;
WT_CONFIG_ITEM cval;
WT_DECL_RET;
- float overhead_pct;
uint64_t cache_size, full_target, system_ram;
- u_int cache_type, evict_aggressive, hash_size, percent_file_in_os_cache;
+ u_int cache_type, evict_aggressive, hash_size, overhead_pct, percent_file_in_os_cache;
char *nvram_device_path;
bool cache_on_checkpoint, cache_on_writes;
@@ -837,7 +833,7 @@ __wt_block_cache_setup(WT_SESSION_IMPL *session, const char *cfg[], bool reconfi
cache_on_writes = false;
WT_RET(__wt_config_gets(session, cfg, "block_cache.max_percent_overhead", &cval));
- overhead_pct = (float)cval.val / (float)100;
+ overhead_pct = (u_int)cval.val;
WT_RET(__blkcache_reconfig(session, reconfig, cache_size, hash_size, cache_type,
nvram_device_path, system_ram, percent_file_in_os_cache, cache_on_writes, overhead_pct,
diff --git a/src/third_party/wiredtiger/src/include/block_cache.h b/src/third_party/wiredtiger/src/include/block_cache.h
index 01cdcdbcb70..0686a3eaf66 100644
--- a/src/third_party/wiredtiger/src/include/block_cache.h
+++ b/src/third_party/wiredtiger/src/include/block_cache.h
@@ -101,22 +101,22 @@ struct __wt_blkcache {
char *nvram_device_path; /* The absolute path of the file system on NVRAM device */
uint64_t full_target; /* Number of bytes in the block cache that triggers eviction */
- float overhead_pct; /* Overhead percentage that suppresses population and eviction */
+ u_int overhead_pct; /* Overhead percentage that suppresses population and eviction */
size_t estimated_file_size; /* Estimated size of all files used by the workload. */
int refs_since_filesize_estimated; /* Counter for recalculating the aggregate file size */
/*
- * This fraction tells us the good enough ratio of file data cached in the DRAM
- * resident OS buffer cache, which makes the use of this block cache unnecessary.
- * Suppose we set that fraction to 50%. Then if half of our file data fits into
- * system DRAM, we consider this block cache unhelpful.
+ * This fraction tells us the good enough ratio of file data cached in the DRAM resident OS
+ * buffer cache, which makes the use of this block cache unnecessary. Suppose we set that
+ * fraction to 50%. Then if half of our file data fits into system DRAM, we consider this block
+ * cache unhelpful.
*
- * E.g., if the fraction is set to 50%, our aggregate file size is
- * 500GB, and we have 300GB of RAM, then we will not use this block cache,
- * because we know that half of our files (250GB) must be cached by the OS in DRAM.
+ * E.g., if the fraction is set to 50%, our aggregate file size is 500GB, and we have 300GB of
+ * RAM, then we will not use this block cache, because we know that half of our files (250GB)
+ * must be cached by the OS in DRAM.
*/
- float fraction_in_os_cache;
+ u_int percent_file_in_os_cache;
u_int hash_size; /* Number of block cache hash buckets */
u_int type; /* Type of block cache (NVRAM or DRAM) */
diff --git a/src/third_party/wiredtiger/src/include/extern.h b/src/third_party/wiredtiger/src/include/extern.h
index c8c1f974f20..bb132a1c31d 100644
--- a/src/third_party/wiredtiger/src/include/extern.h
+++ b/src/third_party/wiredtiger/src/include/extern.h
@@ -761,7 +761,6 @@ extern int __wt_filename(WT_SESSION_IMPL *session, const char *name, char **path
extern int __wt_filename_construct(WT_SESSION_IMPL *session, const char *path,
const char *file_prefix, uintmax_t id_1, uint32_t id_2, WT_ITEM *buf)
WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
-extern int __wt_floatcmp(float f1, float f2) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
extern int __wt_flush_tier(WT_SESSION_IMPL *session, const char *config)
WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
extern int __wt_fopen(WT_SESSION_IMPL *session, const char *name, uint32_t open_flags,
diff --git a/src/third_party/wiredtiger/src/support/float.c b/src/third_party/wiredtiger/src/support/float.c
deleted file mode 100644
index 93bec6da69a..00000000000
--- a/src/third_party/wiredtiger/src/support/float.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*-
- * Public Domain 2014-present MongoDB, Inc.
- * Public Domain 2008-2014 WiredTiger, Inc.
- *
- * This is free and unencumbered software released into the public domain.
- *
- * Anyone is free to copy, modify, publish, use, compile, sell, or
- * distribute this software, either in source code form or as a compiled
- * binary, for any purpose, commercial or non-commercial, and by any
- * means.
- *
- * In jurisdictions that recognize copyright laws, the author or authors
- * of this software dedicate any and all copyright interest in the
- * software to the public domain. We make this dedication for the benefit
- * of the public at large and to the detriment of our heirs and
- * successors. We intend this dedication to be an overt act of
- * relinquishment in perpetuity of all present and future rights to this
- * software under copyright law.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include "wt_internal.h"
-#include <math.h>
-/*
- * __wt_floatcmp --
- * Compares floats in a way that does not generate compiler warnings. Returns an integer greater
- * than, equal to, or less than 0, according to d1 being greater than, equal to, or less than
- * d2.
- */
-int
-__wt_floatcmp(float f1, float f2)
-{
-#define WT_FLOAT_PRECISION 1000
- if (fabsf(f1 - f2) < 1 / WT_FLOAT_PRECISION)
- return (0);
- else
- return (int)((f1 - f2) * WT_FLOAT_PRECISION);
-}