CUBRID Engine
latest
|
#include "binaryheap.h"
#include "filter_pred_cache.h"
#include "lock_free.h"
#include "query_executor.h"
#include "stream_to_xasl.h"
#include "system_parameter.h"
#include "thread_lockfree_hash_map.hpp"
#include "thread_manager.hpp"
#include "xasl.h"
#include "xasl_unpack_info.hpp"
#include <algorithm>
Go to the source code of this file.
Classes | |
struct | fpcache_ent |
struct | fpcache_cleanup_candidate |
Macros | |
#define | FPCACHE_PTR_TO_KEY(ptr) ((BTID *) ptr) |
#define | FPCACHE_PTR_TO_ENTRY(ptr) ((FPCACHE_ENTRY *) ptr) |
#define | FPCACHE_CLEANUP_RATIO 0.2 |
#define | FPCACHE_DELETE_BTIDS_SIZE 1024 |
Typedefs | |
typedef struct fpcache_ent | FPCACHE_ENTRY |
using | fpcache_hashmap_type = cubthread::lockfree_hashmap< BTID, fpcache_ent > |
using | fpcache_hashmap_iterator = fpcache_hashmap_type::iterator |
typedef struct fpcache_cleanup_candidate | FPCACHE_CLEANUP_CANDIDATE |
Functions | |
static void * | fpcache_entry_alloc (void) |
static int | fpcache_entry_free (void *entry) |
static int | fpcache_entry_init (void *entry) |
static int | fpcache_entry_uninit (void *entry) |
static int | fpcache_copy_key (void *src, void *dest) |
static void | fpcache_cleanup (THREAD_ENTRY *thread_p) |
static BH_CMP_RESULT | fpcache_compare_cleanup_candidates (const void *left, const void *right, BH_CMP_ARG ingore_arg) |
int | fpcache_initialize (THREAD_ENTRY *thread_p) |
void | fpcache_finalize (THREAD_ENTRY *thread_p) |
int | fpcache_claim (THREAD_ENTRY *thread_p, BTID *btid, or_predicate *or_pred, pred_expr_with_context **filter_pred) |
int | fpcache_retire (THREAD_ENTRY *thread_p, OID *class_oid, BTID *btid, pred_expr_with_context *filter_pred) |
void | fpcache_remove_by_class (THREAD_ENTRY *thread_p, const OID *class_oid) |
void | fpcache_dump (THREAD_ENTRY *thread_p, FILE *fp) |
void | fpcache_drop_all (THREAD_ENTRY *thread_p) |
Variables | |
static bool | fpcache_Enabled = false |
static INT32 | fpcache_Soft_capacity = 0 |
static fpcache_hashmap_type | fpcache_Hashmap |
static LF_HASH_TABLE | fpcache_Ht = LF_HASH_TABLE_INITIALIZER |
static LF_FREELIST | fpcache_Ht_freelist = LF_FREELIST_INITIALIZER |
static volatile INT32 | fpcache_Entry_counter = 0 |
static volatile INT32 | fpcache_Clone_counter = 0 |
static int | fpcache_Clone_stack_size |
INT32 | fpcache_Cleanup_flag |
BINARY_HEAP * | fpcache_Cleanup_bh |
static INT64 | fpcache_Stat_lookup |
static INT64 | fpcache_Stat_miss |
static INT64 | fpcache_Stat_hit |
static INT64 | fpcache_Stat_discard |
static INT64 | fpcache_Stat_add |
static INT64 | fpcache_Stat_clone_miss |
static INT64 | fpcache_Stat_clone_hit |
static INT64 | fpcache_Stat_clone_discard |
static INT64 | fpcache_Stat_clone_add |
static INT64 | fpcache_Stat_cleanup |
static INT64 | fpcache_Stat_cleanup_entry |
static LF_ENTRY_DESCRIPTOR | fpcache_Entry_descriptor |
#define FPCACHE_CLEANUP_RATIO 0.2 |
Definition at line 90 of file filter_pred_cache.c.
Referenced by fpcache_initialize().
#define FPCACHE_DELETE_BTIDS_SIZE 1024 |
Referenced by fpcache_remove_by_class().
#define FPCACHE_PTR_TO_ENTRY | ( | ptr | ) | ((FPCACHE_ENTRY *) ptr) |
Definition at line 63 of file filter_pred_cache.c.
Referenced by fpcache_entry_init(), and fpcache_entry_uninit().
#define FPCACHE_PTR_TO_KEY | ( | ptr | ) | ((BTID *) ptr) |
Definition at line 62 of file filter_pred_cache.c.
typedef struct fpcache_cleanup_candidate FPCACHE_CLEANUP_CANDIDATE |
Definition at line 81 of file filter_pred_cache.c.
typedef struct fpcache_ent FPCACHE_ENTRY |
Definition at line 38 of file filter_pred_cache.c.
Definition at line 67 of file filter_pred_cache.c.
Definition at line 66 of file filter_pred_cache.c.
int fpcache_claim | ( | THREAD_ENTRY * | thread_p, |
BTID * | btid, | ||
or_predicate * | or_pred, | ||
pred_expr_with_context ** | filter_pred | ||
) |
Definition at line 359 of file filter_pred_cache.c.
References assert, ASSERT_ERROR, fpcache_ent::clone_stack, fpcache_ent::clone_stack_head, db_change_private_heap(), cubthread::lockfree_hashmap< Key, T >::find(), fpcache_Clone_counter, fpcache_Clone_stack_size, fpcache_Enabled, fpcache_Stat_clone_hit, fpcache_Stat_clone_miss, fpcache_Stat_hit, fpcache_Stat_lookup, fpcache_Stat_miss, fpcache_ent::mutex, NO_ERROR, NULL, or_predicate::pred_stream, or_predicate::pred_stream_size, pthread_mutex_unlock, and stx_map_stream_to_filter_pred().
Referenced by locator_eval_filter_predicate().
|
static |
Definition at line 642 of file filter_pred_cache.c.
References assert, assert_release, bh_element_at(), bh_try_insert(), fpcache_ent::btid, fpcache_cleanup_candidate::btid, binary_heap::element_count, fpcache_Cleanup_flag, fpcache_Enabled, fpcache_Entry_counter, fpcache_Soft_capacity, fpcache_Stat_cleanup, fpcache_Stat_cleanup_entry, fpcache_Stat_discard, cubthread::lockfree_hashmap< Key, T >::iterator::iterate(), NULL, fpcache_ent::time_last_used, and fpcache_cleanup_candidate::time_last_used.
Referenced by fpcache_retire().
|
static |
Definition at line 730 of file filter_pred_cache.c.
References BH_EQ, BH_GT, and BH_LT.
Referenced by fpcache_initialize().
|
static |
Definition at line 342 of file filter_pred_cache.c.
void fpcache_drop_all | ( | THREAD_ENTRY * | thread_p | ) |
Definition at line 757 of file filter_pred_cache.c.
References cubthread::lockfree_hashmap< Key, T >::clear(), fpcache_Clone_counter, fpcache_Entry_counter, fpcache_Stat_clone_discard, and fpcache_Stat_discard.
Referenced by xqmgr_drop_all_query_plans().
void fpcache_dump | ( | THREAD_ENTRY * | thread_p, |
FILE * | fp | ||
) |
Definition at line 591 of file filter_pred_cache.c.
References assert, fpcache_ent::btid, fpcache_ent::clone_stack_head, vfid::fileid, fpcache_Clone_counter, fpcache_Enabled, fpcache_Entry_counter, fpcache_Soft_capacity, fpcache_Stat_add, fpcache_Stat_cleanup, fpcache_Stat_cleanup_entry, fpcache_Stat_clone_add, fpcache_Stat_clone_discard, fpcache_Stat_clone_hit, fpcache_Stat_clone_miss, fpcache_Stat_discard, fpcache_Stat_hit, fpcache_Stat_lookup, fpcache_Stat_miss, cubthread::lockfree_hashmap< Key, T >::iterator::iterate(), NULL, btid::root_pageid, btid::vfid, and vfid::volid.
Referenced by xqmgr_dump_query_plans().
|
static |
Definition at line 247 of file filter_pred_cache.c.
References fpcache_ent::mutex, NULL, and pthread_mutex_init.
|
static |
Definition at line 265 of file filter_pred_cache.c.
References fpcache_ent::mutex, NO_ERROR, and pthread_mutex_destroy.
|
static |
Definition at line 279 of file filter_pred_cache.c.
References ARG_FILE_LINE, fpcache_ent::clone_stack, fpcache_ent::clone_stack_head, ER_ERROR_SEVERITY, ER_OUT_OF_VIRTUAL_MEMORY, er_set(), fpcache_Clone_stack_size, FPCACHE_PTR_TO_ENTRY, NO_ERROR, and NULL.
|
static |
Definition at line 303 of file filter_pred_cache.c.
References assert, fpcache_ent::clone_stack, fpcache_ent::clone_stack_head, db_change_private_heap(), db_private_free_and_init, FPCACHE_PTR_TO_ENTRY, free_and_init, free_xasl_unpack_info(), NO_ERROR, NULL, qexec_clear_pred_context(), thread_get_thread_entry_info(), and pred_expr_with_context::unpack_info.
void fpcache_finalize | ( | THREAD_ENTRY * | thread_p | ) |
Definition at line 206 of file filter_pred_cache.c.
References bh_destroy(), db_change_private_heap(), cubthread::lockfree_hashmap< Key, T >::destroy(), fpcache_Enabled, and NULL.
Referenced by boot_restart_server(), and xboot_shutdown_server().
int fpcache_initialize | ( | THREAD_ENTRY * | thread_p | ) |
Definition at line 143 of file filter_pred_cache.c.
References ASSERT_ERROR_AND_SET, bh_create(), db_change_private_heap(), fpcache_Cleanup_flag, FPCACHE_CLEANUP_RATIO, fpcache_Clone_counter, fpcache_Clone_stack_size, fpcache_compare_cleanup_candidates(), fpcache_Enabled, fpcache_Entry_counter, fpcache_Soft_capacity, fpcache_Stat_add, fpcache_Stat_cleanup, fpcache_Stat_cleanup_entry, fpcache_Stat_clone_discard, fpcache_Stat_clone_hit, fpcache_Stat_clone_miss, fpcache_Stat_discard, fpcache_Stat_hit, fpcache_Stat_lookup, fpcache_Stat_miss, fpcache_Ts, cubthread::lockfree_hashmap< Key, T >::init(), lf_freelist_destroy(), lf_hash_destroy(), max, NO_ERROR, NULL, prm_get_integer_value(), PRM_ID_FILTER_PRED_MAX_CACHE_CLONES, PRM_ID_FILTER_PRED_MAX_CACHE_ENTRIES, and THREAD_TS_FPCACHE.
Referenced by boot_restart_server().
void fpcache_remove_by_class | ( | THREAD_ENTRY * | thread_p, |
const OID * | class_oid | ||
) |
Definition at line 503 of file filter_pred_cache.c.
References assert, fpcache_ent::btid, fpcache_ent::class_oid, FPCACHE_DELETE_BTIDS_SIZE, fpcache_Enabled, fpcache_Entry_counter, fpcache_Stat_discard, fpcache_ent::mutex, NULL, OID_EQ, pthread_mutex_unlock, and success().
Referenced by locator_delete_force_internal(), locator_update_force(), and log_cleanup_modified_class().
int fpcache_retire | ( | THREAD_ENTRY * | thread_p, |
OID * | class_oid, | ||
BTID * | btid, | ||
pred_expr_with_context * | filter_pred | ||
) |
Definition at line 427 of file filter_pred_cache.c.
References assert, fpcache_ent::class_oid, fpcache_ent::clone_stack, fpcache_ent::clone_stack_head, COPY_OID, db_change_private_heap(), db_private_free_and_init, ER_FAILED, cubthread::lockfree_hashmap< Key, T >::find_or_insert(), fpcache_cleanup(), fpcache_Clone_counter, fpcache_Clone_stack_size, fpcache_Enabled, fpcache_Entry_counter, fpcache_Soft_capacity, fpcache_Stat_add, fpcache_Stat_clone_add, fpcache_Stat_clone_discard, free_xasl_unpack_info(), fpcache_ent::mutex, NO_ERROR, NULL, OID_EQ, pthread_mutex_unlock, fpcache_ent::time_last_used, and pred_expr_with_context::unpack_info.
Referenced by locator_eval_filter_predicate().
BINARY_HEAP* fpcache_Cleanup_bh |
Definition at line 88 of file filter_pred_cache.c.
INT32 fpcache_Cleanup_flag |
Definition at line 87 of file filter_pred_cache.c.
Referenced by fpcache_cleanup(), and fpcache_initialize().
|
static |
Definition at line 77 of file filter_pred_cache.c.
Referenced by fpcache_claim(), fpcache_drop_all(), fpcache_dump(), fpcache_initialize(), and fpcache_retire().
|
static |
Definition at line 78 of file filter_pred_cache.c.
Referenced by fpcache_claim(), fpcache_entry_init(), fpcache_initialize(), and fpcache_retire().
|
static |
Definition at line 70 of file filter_pred_cache.c.
Referenced by fpcache_claim(), fpcache_cleanup(), fpcache_dump(), fpcache_finalize(), fpcache_initialize(), fpcache_remove_by_class(), and fpcache_retire().
|
static |
Definition at line 76 of file filter_pred_cache.c.
Referenced by fpcache_cleanup(), fpcache_drop_all(), fpcache_dump(), fpcache_initialize(), fpcache_remove_by_class(), and fpcache_retire().
|
static |
Definition at line 116 of file filter_pred_cache.c.
|
static |
Definition at line 72 of file filter_pred_cache.c.
|
static |
Definition at line 73 of file filter_pred_cache.c.
|
static |
Definition at line 74 of file filter_pred_cache.c.
|
static |
Definition at line 71 of file filter_pred_cache.c.
Referenced by fpcache_cleanup(), fpcache_dump(), fpcache_initialize(), and fpcache_retire().
|
static |
Definition at line 97 of file filter_pred_cache.c.
Referenced by fpcache_dump(), fpcache_initialize(), and fpcache_retire().
|
static |
Definition at line 102 of file filter_pred_cache.c.
Referenced by fpcache_cleanup(), fpcache_dump(), and fpcache_initialize().
|
static |
Definition at line 103 of file filter_pred_cache.c.
Referenced by fpcache_cleanup(), fpcache_dump(), and fpcache_initialize().
|
static |
Definition at line 101 of file filter_pred_cache.c.
Referenced by fpcache_dump(), and fpcache_retire().
|
static |
Definition at line 100 of file filter_pred_cache.c.
Referenced by fpcache_drop_all(), fpcache_dump(), fpcache_initialize(), and fpcache_retire().
|
static |
Definition at line 99 of file filter_pred_cache.c.
Referenced by fpcache_claim(), fpcache_dump(), and fpcache_initialize().
|
static |
Definition at line 98 of file filter_pred_cache.c.
Referenced by fpcache_claim(), fpcache_dump(), and fpcache_initialize().
|
static |
Definition at line 96 of file filter_pred_cache.c.
Referenced by fpcache_cleanup(), fpcache_drop_all(), fpcache_dump(), fpcache_initialize(), and fpcache_remove_by_class().
|
static |
Definition at line 95 of file filter_pred_cache.c.
Referenced by fpcache_claim(), fpcache_dump(), and fpcache_initialize().
|
static |
Definition at line 93 of file filter_pred_cache.c.
Referenced by fpcache_claim(), fpcache_dump(), and fpcache_initialize().
|
static |
Definition at line 94 of file filter_pred_cache.c.
Referenced by fpcache_claim(), fpcache_dump(), and fpcache_initialize().