[mem] some more memory reductions

Defect Number:
    Reviewed By:
   Testing Done:
pull/112/head
Timothy Stack 10 years ago
parent f410c9eeb8
commit 708490e3b0

@ -470,11 +470,12 @@ static int json_array_end(void *ctx)
if (ypc->ypc_path_index_stack.size() == 1) {
const intern_string_t field_name = ypc->get_path_fragment_i(0);
size_t sub_end = yajl_get_bytes_consumed(jlu->jlu_handle);
tmp_shared_buffer tsb(&jlu->jlu_line_value[jlu->jlu_sub_start],
sub_end - jlu->jlu_sub_start);
shared_buffer_ref sbr;
sbr.subset(jlu->jlu_shared_buffer, jlu->jlu_sub_start,
sub_end - jlu->jlu_sub_start);
jlu->jlu_format->jlf_line_values.push_back(
logline_value(field_name, tsb.tsb_ref));
logline_value(field_name, sbr));
jlu->jlu_format->jlf_line_values.back().lv_kind = logline_value::VALUE_JSON;
}
@ -578,6 +579,8 @@ bool external_log_format::scan(std::vector<logline> &dst,
ypc.ypc_ignore_unused = true;
ypc.ypc_alt_callbacks.yajl_start_array = json_array_start;
ypc.ypc_alt_callbacks.yajl_start_map = json_array_start;
ypc.ypc_alt_callbacks.yajl_end_array = NULL;
ypc.ypc_alt_callbacks.yajl_end_map = NULL;
jlu.jlu_format = this;
jlu.jlu_base_line = &ll;
jlu.jlu_line_value = sbr.get_data();

@ -700,7 +700,7 @@ public:
NULL,
this->jlf_parse_context.get()));
yajl_config(this->jlf_yajl_handle.in(), yajl_dont_validate_strings, 1);
this->jlf_cached_line.reserve(1024 * 1024);
this->jlf_cached_line.reserve(16 * 1024);
}
else if (this->lf_fmt_lock != -1) {
pcrepp *pat = this->elf_pattern_order[this->lf_fmt_lock]->p_pcre;

@ -50,7 +50,6 @@
using namespace std;
static const size_t MAX_UNRECOGNIZED_LINES = 1000;
static const size_t INDEX_RESERVE_LOW_MARK = 10;
static const size_t INDEX_RESERVE_INCREMENT = 1024;
logfile::logfile(string filename, auto_fd fd)
@ -249,12 +248,6 @@ throw (line_buffer::error, logfile::error)
throw error(this->lf_filename, errno);
}
if ((this->lf_index.capacity() - this->lf_index.size()) <
INDEX_RESERVE_LOW_MARK) {
this->lf_index.reserve(
this->lf_index.capacity() + INDEX_RESERVE_INCREMENT);
}
/* Check for new data based on the file size. */
if (this->lf_index_size < st.st_size) {
bool has_format = this->lf_format.get() != NULL;

Loading…
Cancel
Save