Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Conversation

@whuaegeanse
Copy link
Contributor

After calling the ApplyRigConfig function, the exe may experience long I/O cycles (90% utilization). Investigation revealed that the Database destructor was particularly time-consuming. Further investigation revealed that this was caused by setting auto_vacuum to 1. If auto_vacuum is 0, SQLite does not clean up deleted space when deleting data, allowing it to reuse the deleted space when adding data later.
The ApplyRigConfig function primarily deletes frames and rigs. However, frames and rigs occupy very little storage space, so clearing them would not yield significant benefits.

Changing from
SQLITE3_EXEC(database->database_, "PRAGMA auto_vacuum=1", nullptr);
to
SQLITE3_EXEC(database->database_, "PRAGMA auto_vacuum=0", nullptr);
reduces the time it takes to destroy the database, especially when the SQLite database size reaches 1-10GB.

@ahojnnes
Copy link
Contributor

ahojnnes commented Oct 7, 2025

It also means that storage is not automatically freed up when data is deleted from the database?

@whuaegeanse
Copy link
Contributor Author

It also means that storage is not automatically freed up when data is deleted from the database?

Yes.
When auto_vacuum=0, SQLite will reuse storage marked for deletion. This should be sufficient for colmap, especially for feature extraction and feature matching.

@ahojnnes
Copy link
Contributor

ahojnnes commented Oct 8, 2025

What's the runtime savings and corresponding stats (#images/frames/rigs)?

@whuaegeanse
Copy link
Contributor Author

whuaegeanse commented Oct 11, 2025

What's the runtime savings and corresponding stats (#images/frames/rigs)?

Sorry for the late reply.
I used two datasets for experiments, with the following results:
Data 1, with 309 x 2 images (1 rig, 309 frames, 718 images), a database size of 0.93 GB, reduced ApplyRigConfig time from 30.3 seconds to 0.02 seconds.
Data 2, with 1630 x 2 images (1 rig, 1630 frames, 3260 images), a database size of 6.60 GB, reduced ApplyRigConfig time from 557.5 seconds to 0.02 seconds.

@sarlinpe
Copy link
Member

sarlinpe commented Nov 3, 2025

The ApplyRigConfig function primarily deletes frames and rigs. However, frames and rigs occupy very little storage space, so clearing them would not yield significant benefits.

Ideally we would set auto_vacuum=0 only when deleting frames/rigs. There are other use cases in which one might want to remove features from the database - then auto_vacuum=1 helps reduce the database size by a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants