Skip to content

Commit 7b5350e

Browse files
committed
[perf] improve stuff related to archive extraction
1 parent ea2c2de commit 7b5350e

File tree

7 files changed

+38
-19
lines changed

7 files changed

+38
-19
lines changed

src/archive_manager.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ copy_data(const std::string& filename,
216216
entry_path.filename().string(),
217217
entry_path.parent_path().string()));
218218
}
219-
next_space_check += 1024 * 1024;
219+
next_space_check += 10 * 1024 * 1024;
220220
}
221221

222222
r = archive_read_data_block(ar, &buff, &size, &offset);

src/cmds.io.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,13 +1232,13 @@ com_open(exec_context& ec, std::string cmdline, std::vector<std::string>& args)
12321232
retval = "info: watching -- " + fn;
12331233
} else if (lnav::filesystem::is_glob(fn.c_str())) {
12341234
loo.with_init_location(file_loc);
1235-
fc.fc_file_names.emplace(fn, loo);
1235+
fc.fc_file_names.insert2(fn, loo);
12361236
files_to_front.emplace_back(
12371237
loo.loo_filename.empty() ? fn : loo.loo_filename);
12381238
retval = "info: watching -- " + fn;
12391239
} else if (stat(fn.c_str(), &st) == -1) {
12401240
if (fn.find(':') != std::string::npos) {
1241-
fc.fc_file_names.emplace(fn, loo);
1241+
fc.fc_file_names.insert2(fn, loo);
12421242
retval = "info: watching -- " + fn;
12431243
} else {
12441244
auto um = lnav::console::user_message::error(
@@ -1304,7 +1304,7 @@ com_open(exec_context& ec, std::string cmdline, std::vector<std::string>& args)
13041304
if (dir_wild[dir_wild.size() - 1] == '/') {
13051305
dir_wild.resize(dir_wild.size() - 1);
13061306
}
1307-
fc.fc_file_names.emplace(dir_wild + "/*", loo);
1307+
fc.fc_file_names.insert2(dir_wild + "/*", loo);
13081308
retval = "info: watching -- " + dir_wild;
13091309
} else if (!S_ISREG(st.st_mode)) {
13101310
auto um = lnav::console::user_message::error(
@@ -1351,7 +1351,7 @@ com_open(exec_context& ec, std::string cmdline, std::vector<std::string>& args)
13511351
}
13521352
if (file_iter == lnav_data.ld_active_files.fc_files.end()) {
13531353
loo.with_init_location(file_loc);
1354-
fc.fc_file_names.emplace(fn, loo);
1354+
fc.fc_file_names.insert2(fn, loo);
13551355
retval = "info: opened -- " + fn;
13561356
files_to_front.emplace_back(fn);
13571357

src/file_collection.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,12 @@ file_collection::merge(file_collection& other)
240240
if (!other.fc_file_names.empty()) {
241241
this->fc_files_generation += 1;
242242
}
243-
for (const auto& fn_pair : other.fc_file_names) {
244-
this->fc_file_names[fn_pair.first] = fn_pair.second;
243+
if (this->fc_file_names.empty()) {
244+
this->fc_file_names = other.fc_file_names;
245+
} else {
246+
for (const auto& fn_pair : other.fc_file_names) {
247+
this->fc_file_names[fn_pair.first] = fn_pair.second;
248+
}
245249
}
246250
if (!other.fc_files.empty()) {
247251
for (const auto& lf : other.fc_files) {
@@ -353,7 +357,7 @@ file_collection::watch_logfile(const std::string& filename,
353357
{
354358
file_collection retval;
355359

356-
retval.fc_file_names.emplace(
360+
retval.fc_file_names.insert2(
357361
wilddir,
358362
logfile_open_options()
359363
.with_non_utf_visibility(false)

src/file_collection.hh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <future>
3737
#include <list>
3838
#include <map>
39+
#include <memory>
3940
#include <set>
4041
#include <string>
4142
#include <vector>
@@ -51,6 +52,7 @@
5152
#include "file_format.hh"
5253
#include "logfile_fwd.hh"
5354
#include "safe/safe.h"
55+
#include "tlx/container/btree_map.hpp"
5456

5557
struct tailer_progress {
5658
std::string tp_message;
@@ -156,7 +158,7 @@ struct file_collection {
156158

157159
std::shared_ptr<safe_name_to_stubs> fc_name_to_stubs{
158160
std::make_shared<safe_name_to_stubs>()};
159-
std::map<std::string, logfile_open_options, strnatless> fc_file_names;
161+
tlx::btree_map<std::string, logfile_open_options, strnatless> fc_file_names;
160162
std::vector<std::shared_ptr<logfile>> fc_files;
161163
int fc_files_generation{0};
162164
std::optional<size_t> fc_files_high_mark;

src/files_sub_source.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ files_sub_source::list_input_handle_key(listview_curses& lv, const ncinput& ch)
192192
auto name_iter = fc.fc_file_names.begin();
193193
while (name_iter != fc.fc_file_names.end()) {
194194
if (name_iter->first == es.sb_iter.first) {
195-
name_iter = fc.fc_file_names.erase(name_iter);
195+
fc.fc_file_names.erase(name_iter);
196+
name_iter = fc.fc_file_names.begin();
196197
continue;
197198
}
198199

@@ -204,7 +205,8 @@ files_sub_source::list_input_handle_key(listview_curses& lv, const ncinput& ch)
204205

205206
if (fmt::to_string(rp.home()) == es.sb_iter.first) {
206207
fc.fc_other_files.erase(name_iter->first);
207-
name_iter = fc.fc_file_names.erase(name_iter);
208+
fc.fc_file_names.erase(name_iter);
209+
name_iter = fc.fc_file_names.begin();
208210
continue;
209211
}
210212
}
@@ -439,7 +441,7 @@ files_overlay_source::list_static_overlay(const listview_curses& lv,
439441
value_out.with_ansi_string(fmt::format(
440442
"{} Extracting " ANSI_COLOR(COLOR_CYAN) "{}" ANSI_NORM
441443
"... {:>8}/{}",
442-
PROG[spinner_index() % PROG_SIZE],
444+
humanize::sparkline(prog.ep_out_size, prog.ep_total_size),
443445
prog.ep_path.filename().string(),
444446
humanize::file_size(prog.ep_out_size, humanize::alignment::none),
445447
humanize::file_size(prog.ep_total_size,

src/formats/syslog_log.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
},
7575
"search-table": {
7676
"sudo_log": {
77-
"pattern": "sudo: (?<login>\\S+)\\s*: (?:(?<error_msg>[^;]+);)?\\s*TTY=(?<tty>[^;]+)\\s+;\\s*PWD=(?<pwd>[^;]+)\\s+;\\s*USER=(?<user>[^;]+)\\s+;\\s*COMMAND=(?<command>.*)$"
77+
"pattern": "sudo:\\s+(?<login>\\S+)\\s*: (?:(?<error_msg>[^;]+);)?(?:\\s*TTY=(?<tty>[^;]+)\\s+;)?\\s*PWD=(?<pwd>[^;]+)\\s+;\\s*USER=(?<user>[^;]+)\\s+;\\s*COMMAND=(?<command>.*)$"
7878
}
7979
},
8080
"sample": [

src/lnav.cc

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,10 +1931,12 @@ VALUES ('org.lnav.mouse-support', -1, DATETIME('now', '+1 minute'),
19311931
if (exec_phase.scanning() && new_files.empty()
19321932
&& indexing_pipers == 0)
19331933
{
1934-
if (!lnav_data.ld_active_files.fc_other_files.empty()
1935-
|| lnav_data.ld_active_files.fc_files.size() > 1
1936-
|| !lnav_data.ld_active_files.fc_name_to_stubs->readAccess()
1937-
->empty())
1934+
if (!opened_files
1935+
&& (!lnav_data.ld_active_files.fc_other_files.empty()
1936+
|| lnav_data.ld_active_files.fc_files.size() > 1
1937+
|| !lnav_data.ld_active_files.fc_name_to_stubs
1938+
->readAccess()
1939+
->empty()))
19381940
{
19391941
opened_files = true;
19401942
set_view_mode(ln_mode_t::FILES);
@@ -1985,6 +1987,12 @@ VALUES ('org.lnav.mouse-support', -1, DATETIME('now', '+1 minute'),
19851987
= ui_now + (std::exchange(rescan_needed, false) ? 0ms : 333ms);
19861988
}
19871989

1990+
if (!opened_files && exec_phase.scanning()
1991+
&& ui_now - ui_start_time >= 500ms)
1992+
{
1993+
set_view_mode(ln_mode_t::FILES);
1994+
}
1995+
19881996
if (!rescan_future.valid()
19891997
&& (exec_phase.spinning_up()
19901998
|| (lnav_data.ld_active_files.is_below_open_file_limit()
@@ -2109,6 +2117,9 @@ VALUES ('org.lnav.mouse-support', -1, DATETIME('now', '+1 minute'),
21092117
updated_views.emplace_back(&lnav_data.ld_user_message_view);
21102118
}
21112119
if (ui_now >= next_status_update_time) {
2120+
if (exec_phase.scanning()) {
2121+
lnav_data.ld_files_view.set_needs_update();
2122+
}
21122123
if (lnav_data.ld_status[LNS_BOTTOM].get_needs_update()
21132124
|| lnav_data.ld_status[LNS_FILTER].get_needs_update())
21142125
{
@@ -3896,10 +3907,10 @@ SELECT tbl_name FROM sqlite_master WHERE sql LIKE 'CREATE VIRTUAL TABLE%'
38963907
}
38973908
auto loo = logfile_open_options().with_time_range(
38983909
lnav_data.ld_default_time_range);
3899-
lnav_data.ld_active_files.fc_file_names.emplace(dir_wild + "/*",
3910+
lnav_data.ld_active_files.fc_file_names.insert2(dir_wild + "/*",
39003911
loo);
39013912
} else {
3902-
lnav_data.ld_active_files.fc_file_names.emplace(
3913+
lnav_data.ld_active_files.fc_file_names.insert2(
39033914
abspath.in(),
39043915
logfile_open_options()
39053916
.with_init_location(file_loc)

0 commit comments

Comments
 (0)