Skip to content

Commit

Permalink
run with scissors
Browse files Browse the repository at this point in the history
Switch we switched to processes for concurrency, we can tell SQLite to
disable its intra-process locks.
  • Loading branch information
cldellow committed Oct 5, 2024
1 parent e471648 commit 28c377a
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions src/tilemaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,28 +107,22 @@ int main(const int argc, const char* argv[]) {
return 1;
}

if (false) {
// See https://github.com/xerial/sqlite-jdbc/issues/59#issuecomment-162115704
int rv;
rv = sqlite3_config(SQLITE_CONFIG_MEMSTATUS, 0);
if (rv) {
std::cerr << "fatal: sqlite3_config(SQLITE_CONFIG_MEMSTATUS)=" << std::to_string(rv) << std::endl;
return 1;
}
// See https://github.com/xerial/sqlite-jdbc/issues/59#issuecomment-162115704
int rv;
rv = sqlite3_config(SQLITE_CONFIG_MEMSTATUS, 0);
if (rv) {
std::cerr << "fatal: sqlite3_config(SQLITE_CONFIG_MEMSTATUS)=" << std::to_string(rv) << std::endl;
return 1;
}

// Per https://www.sqlite.org/c3ref/c_config_covering_index_scan.html#sqliteconfigsinglethread,
// this should break everything.
//
// But things seem to still work, and this avoids the locking we were seeing.
//
// I would have thought we needed SQLITE_CONFIG_MULTITHREAD ? I feel like
// I'm missing something pretty big here, but let's go until we hit a wall.
rv = sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
if (rv) {
std::cerr << "fatal: sqlite3_config(SQLITE_CONFIG_SINGLETHREAD)=" << std::to_string(rv) << std::endl;
return 1;
}
// We only use a single thread, so tell SQLite to skip its internal locking.
// See https://www.sqlite.org/c3ref/c_config_covering_index_scan.html#sqliteconfigsinglethread
rv = sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
if (rv) {
std::cerr << "fatal: sqlite3_config(SQLITE_CONFIG_SINGLETHREAD)=" << std::to_string(rv) << std::endl;
return 1;
}

std::vector<std::shared_ptr<Input>> inputs;
for (auto filename : filenames) {
std::shared_ptr<Input> input = std::make_shared<Input>();
Expand Down

0 comments on commit 28c377a

Please sign in to comment.