-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Is your feature request related to a problem? Please describe.
If I understand correctly, traffic stats, like settings, are saved in SQLite. This causes write amplification, CPU spikes, I/O spikes and trashes storage devices. It also causes some strange bugs when there's a WAL queue.
Describe the solution you'd like
Storing the counters in memory and syncing it to disk every five minutes or so, in a batched transaction updating/inserting records for all clients/outbounds/inbounds at once.
Describe alternatives you've considered
I guess moving the database to tmpfs would improve the situation somewhat.
Additional context
Add any other context or screenshots about the feature request here.
On a similar tangent, please consider either dropping SQLite, using an ORM, and/or defining proper schemas. As of now it serves no purpose but to reduce performance and complicate things. A giant JSON file would the serve the current program just as well as SQLite.
From a cursory glance at the database, it seems that it doesn't use joined tables but rather string names. This means that there are roundtrips to the database for data that could be retrieved in a single transaction if properly specified. The settings are also all json. This makes migrating them more difficult.