DBG: cache file for the command line in the database (~2x performance improvement on big databases)
This commit is contained in:
parent
aae9953c6d
commit
6e189010d2
|
@ -3,6 +3,7 @@
|
|||
#include "memory.h"
|
||||
#include "debugger.h"
|
||||
#include "console.h"
|
||||
#include "filehelper.h"
|
||||
|
||||
char commandLine[MAX_SETTING_SIZE];
|
||||
|
||||
|
@ -90,10 +91,13 @@ char* getCommandLineArgs()
|
|||
|
||||
}
|
||||
|
||||
void CmdLineCacheSave(JSON Root)
|
||||
void CmdLineCacheSave(JSON Root, const String & cacheFile)
|
||||
{
|
||||
EXCLUSIVE_ACQUIRE(LockCmdLine);
|
||||
|
||||
// Write the (possibly empty) command line to a cache file
|
||||
FileHelper::WriteAllText(cacheFile, commandLine);
|
||||
|
||||
// return if command line is empty
|
||||
if(!strlen(commandLine))
|
||||
return;
|
||||
|
@ -120,14 +124,14 @@ void CmdLineCacheLoad(JSON Root)
|
|||
|
||||
const char* cmdLine = json_string_value(json_object_get(jsonCmdLine, "cmdLine"));
|
||||
|
||||
strcpy_s(commandLine, cmdLine);
|
||||
strncpy_s(commandLine, cmdLine, _TRUNCATE);
|
||||
|
||||
json_decref(jsonCmdLine);
|
||||
}
|
||||
|
||||
void copyCommandLine(const char* cmdLine)
|
||||
{
|
||||
strcpy_s(commandLine, cmdLine);
|
||||
strncpy_s(commandLine, cmdLine, _TRUNCATE);
|
||||
}
|
||||
|
||||
bool SetCommandLine()
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
void showcommandlineerror(cmdline_error_t* cmdline_error);
|
||||
bool isCmdLineEmpty();
|
||||
char* getCommandLineArgs();
|
||||
void CmdLineCacheSave(JSON Root);
|
||||
void CmdLineCacheSave(JSON Root, const String & cacheFile);
|
||||
void CmdLineCacheLoad(JSON Root);
|
||||
void copyCommandLine(const char* cmdLine);
|
||||
bool setCommandLine();
|
||||
|
|
|
@ -40,6 +40,7 @@ void DbSave(DbLoadSaveType saveType, const char* dbfile, bool disablecompression
|
|||
EXCLUSIVE_ACQUIRE(LockDatabase);
|
||||
|
||||
auto file = dbfile ? dbfile : dbpath;
|
||||
auto cmdlinepath = file + String(".cmdline");
|
||||
dprintf(QT_TRANSLATE_NOOP("DBG", "Saving database to %s "), file);
|
||||
DWORD ticks = GetTickCount();
|
||||
JSON root = json_object();
|
||||
|
@ -47,7 +48,7 @@ void DbSave(DbLoadSaveType saveType, const char* dbfile, bool disablecompression
|
|||
// Save only command line
|
||||
if(saveType == DbLoadSaveType::CommandLine || saveType == DbLoadSaveType::All)
|
||||
{
|
||||
CmdLineCacheSave(root);
|
||||
CmdLineCacheSave(root, cmdlinepath);
|
||||
}
|
||||
|
||||
if(saveType == DbLoadSaveType::DebugData || saveType == DbLoadSaveType::All)
|
||||
|
@ -129,7 +130,10 @@ void DbSave(DbLoadSaveType saveType, const char* dbfile, bool disablecompression
|
|||
LZ4_compress_fileW(wdbpath.c_str(), wdbpath.c_str());
|
||||
}
|
||||
else //remove database when nothing is in there
|
||||
{
|
||||
DeleteFileW(wdbpath.c_str());
|
||||
DeleteFileW(StringUtils::Utf8ToUtf16(cmdlinepath).c_str());
|
||||
}
|
||||
|
||||
dprintf(QT_TRANSLATE_NOOP("DBG", "%ums\n"), GetTickCount() - ticks);
|
||||
json_decref(root); //free root
|
||||
|
@ -145,7 +149,15 @@ void DbLoad(DbLoadSaveType loadType, const char* dbfile)
|
|||
return;
|
||||
|
||||
if(loadType == DbLoadSaveType::CommandLine)
|
||||
{
|
||||
dputs(QT_TRANSLATE_NOOP("DBG", "Loading commandline..."));
|
||||
String content;
|
||||
if(FileHelper::ReadAllText(file + String(".cmdline"), content))
|
||||
{
|
||||
copyCommandLine(content.c_str());
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
dprintf(QT_TRANSLATE_NOOP("DBG", "Loading database from %s "), file);
|
||||
DWORD ticks = GetTickCount();
|
||||
|
|
Loading…
Reference in New Issue