Skip to content

Conversation

@Simon-Laux
Copy link
Contributor

@Simon-Laux Simon-Laux commented Nov 21, 2025

new jsonrpc api: get_storage_usage_report_string(accountId)
new rust API: get_storage_usage(&context)

This pr should help us in debugging issues like #7345

image

it also is part of output of Context.get_info(), but in my test it seemed to slow desktop startup,
so we may want to remove that and instead make PRs to the UIs to fetch the pretty formatted report from the jsonrpc api.
and do whatever makes most sense with it:

  • call it and log result
  • new screen to show the text
  • or just a button to copy the report to clipboard, so users can send it to us easily.

@hpk42
Copy link
Contributor

hpk42 commented Nov 22, 2025 via email

@link2xt
Copy link
Collaborator

link2xt commented Nov 22, 2025

but as it involves cross-platform UI work, and there is no corresponding UI PR, it's thin.

In the current state PR adds the information to the context info, it is already displayed on Android at the top of the log, so no changes are required. Dedicated API is not used and can probably be removed, but it is also not a problem.

@link2xt
Copy link
Collaborator

link2xt commented Nov 22, 2025

but maybe some external script/tool that just goes to core's sqlite and does some analysis, is sufficient, and can be done without any cross-team synchronization.

The problem is mostly on Android and if you look at the original issue, it is very unlikely that users will run this tool: #7345
It is repeated for years, users report a problem and then as soon as they find a workaround (e.g. removing the messages manually) they don't follow up, don't send any more logs and likely don't respond to any questions.

@hpk42
Copy link
Contributor

hpk42 commented Nov 22, 2025 via email

@Simon-Laux
Copy link
Contributor Author

If a jsonrpc API is not required, let's not introduce it. One thing less to worry/consider.

the jsonrpc api is better:

  • easy to add a simple button to copy the returned string to clipboard
  • jsonrpc apis have close to no cost. especially this one which only returns a string and is not machine readable, so we can change output at any time.
  • when we are not limited by time (get_info needs to be fast, jsonrpc apis don't), then we can also do data collection operations that are slower:
    • like checking size of every blob on disk, to show the largest blob files
    • or analyzing and showing how much space the blob de-duplication saves
    • and so on...

adding it to get_info has the following downsides:

  • risk of slowing desktop startup
  • get_config output gets formatted differently on desktop than on android so it would look ugly on desktop.
  • not easy to copy for users

So I want to remove it from get_info and only keep the jsonrpc api to get the report as formatted string.

As stated in the updated pr description there are many possibilities to what the UIs can do with it, all of them are just displaying or offering to copy formatted text, so the PRs will be VERY EASY and probably could even be under 10 lines of code (copy button). Also this is only needed by android for now, and when we only have a jsonrpc API instead of calling it every time we run get_config then it won't affect the other platforms at all until they decide to use the API as well.

@r10s
Copy link
Contributor

r10s commented Nov 22, 2025

first, i agree info about usage is welcome

then, why is get_info() called on startup?

ftr, get_info() was always meant as debug info for devs. it was never meant to be show formatted to the user as currently in the about dialog - we just never came to doing that differently, as not important enough, but it should also not be a used as a reason to manifest that usage

so, maybe remove the formatter output on desktop alltogether and add a "get debug info" button

i am also sceptical in introducing more ways for the user to gather information. more to explain and to go wrong. already current info/log differantiation is more complex than on mobile. on android/ios getting the log anyways takes some time, so having a moment more does not make much of a difference. how long does getting the information really take currently?

@Simon-Laux
Copy link
Contributor Author

Simon-Laux commented Nov 22, 2025

Update:

  • adding it to get_info makes the python CI fail
  • link2xt told me that it should be part of log, so that users always share it when giving us the log. (so no dedicated/seperate action/screen/copy-button)

So plan is now remove from get_info and keep the jsonrpc method. then in UI call the method and prepend the space usage report to the start of the log.

@Simon-Laux
Copy link
Contributor Author

Simon-Laux commented Nov 22, 2025

why is get_info() called on startup?

it is called when you switch accounts so that it gets added to the logfile. If we want to change that, then we should make an issue on desktop repo and discuss it there.

@link2xt
Copy link
Collaborator

link2xt commented Nov 22, 2025

why is get_info() called on startup?

It is called on selectAccount and printed to the terminal, probably should not really be done, it just slows down account selection and user can anyway access this info from about window. EDIT: opened deltachat/deltachat-desktop#5755

But regardless of that, diskspace should not go into get_info anyway because everything else there is currently a bunch of single-line values, not a huge report. As it is placing huge multi-line string breaks legacy python test that parses get_info() by splitting it into lines and then by =.

UI-wise on Android nothing will change, but it will need to call not only get_info but this new API and put it at the top of the log, so users who normally don't care and just send us a text file will also have this report in the .txt already.

@Simon-Laux Simon-Laux marked this pull request as ready for review November 22, 2025 22:45
@Simon-Laux Simon-Laux requested a review from link2xt November 22, 2025 22:45
Copy link
Collaborator

@link2xt link2xt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM expect for the naming and MsgId represented as usize in the public API.

@Simon-Laux Simon-Laux changed the title feat: add api to get information about diskspace usage of database. feat: add api to get information about diskspace usage of database. (jsonrpc method: get_storage_usage_report_string) Nov 23, 2025
@Simon-Laux Simon-Laux enabled auto-merge (squash) November 23, 2025 15:12
@Simon-Laux Simon-Laux merged commit 94d2d8c into main Nov 23, 2025
29 checks passed
@Simon-Laux Simon-Laux deleted the simon/i7345-db-space-usage-info branch November 23, 2025 15:18
@hpk42
Copy link
Contributor

hpk42 commented Nov 25, 2025 via email

@link2xt
Copy link
Collaborator

link2xt commented Nov 25, 2025

Which UI required this API?

Android has this merged: deltachat/deltachat-android#4060
No buttons, the info is just attached to the top of the log.

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.

6 participants