Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(communities)_: delay starting torrent client until connection is established #5125

Merged
merged 1 commit into from
May 9, 2024

Conversation

friofry
Copy link
Contributor

@friofry friofry commented May 7, 2024

  • Messenger is subscribed to connectivity status updates. Whenever status is updated, Messenger calls Manager.setOnline
  • Manager launches TorrentClient on first connection

Closes status-im/status-desktop#14510

@status-im-auto
Copy link
Member

status-im-auto commented May 7, 2024

Jenkins Builds

Click to see older builds (12)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 8c4682f #1 2024-05-07 16:04:57 ~4 min linux 📦zip
✔️ 8c4682f #1 2024-05-07 16:05:18 ~4 min ios 📦zip
✔️ 8c4682f #1 2024-05-07 16:06:41 ~6 min android 📦aar
✔️ 8c4682f #1 2024-05-07 16:44:02 ~43 min tests 📄log
✔️ 76538ee #2 2024-05-07 16:07:35 ~2 min linux 📦zip
✔️ 76538ee #2 2024-05-07 16:08:45 ~3 min ios 📦zip
✔️ 76538ee #2 2024-05-07 16:08:53 ~1 min android 📦aar
✔️ 76538ee #2 2024-05-07 17:25:22 ~41 min tests 📄log
✔️ 7a16a96 #3 2024-05-08 19:02:54 ~2 min android 📦aar
✔️ 7a16a96 #3 2024-05-08 19:03:04 ~2 min linux 📦zip
✔️ 7a16a96 #3 2024-05-08 19:05:45 ~5 min ios 📦zip
✔️ 7a16a96 #3 2024-05-08 19:43:13 ~42 min tests 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 5a76c98 #4 2024-05-08 19:52:50 ~1 min android 📦aar
✔️ 5a76c98 #4 2024-05-08 19:53:42 ~2 min linux 📦zip
✔️ 5a76c98 #4 2024-05-08 19:54:25 ~3 min ios 📦zip
✔️ 5a76c98 #4 2024-05-08 20:32:37 ~41 min tests 📄log

Copy link
Member

@0x-r4bbit 0x-r4bbit left a comment

Choose a reason for hiding this comment

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

LGTM, just a minor question

err := m.StartTorrentClient()
if err != nil {
m.LogStdout("couldn't start torrent client", zap.Error(err))
}
Copy link
Member

Choose a reason for hiding this comment

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

Should this also stop the client if !online ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @0x-r4bbit,
yeah, I have thought about stopping the client when !online. But I have 2 concerns:

  1. StartTorrentClient creates a new instance of TorrentClient. This means that any previous calls to torrentClient.AddTorrent may be lost (e.g. it's called from SeedHistoryArchiveTorrent). And the same for AddMagnet. Is it okay to rebuild torrentClient without restoring torrents/magents?
    To be on the safe side I only use the setOnline method to delay the creation of the TorrentClient.

  2. There is also an api call EnableCommunityHistoryArchiveProtocol (and Disable) that starts/stops the torrentClient (which could currently be called from the Desktop Settings). And I thought that the behaviour of setOnline and EnableCommunityHistoryArchiveProtocol might be inconsistent.

Maybe I'm missing other problems.

Copy link
Member

Choose a reason for hiding this comment

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

There is also an api call EnableCommunityHistoryArchiveProtocol (and Disable) that starts/stops the torrentClient (which could currently be called from the Desktop Settings). And I thought that the behaviour of setOnline and EnableCommunityHistoryArchiveProtocol might be inconsistent.

Yes, as a matter of fact, back then, it was a requirement for the torrent to always be bootstrapped when using desktop clients. The setting to enable/disable the protocol was more of a thing for development (this might have changed by now).

Considering that, it indeed makes sense to keep the client running once it has started (unless the protocol is disabled entirely).
The reason I brought this up here is because I thought, when !online, the torrent client might cause high CPU usage again, but maybe that's not the case?

Copy link
Contributor Author

@friofry friofry May 8, 2024

Choose a reason for hiding this comment

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

Yes, as a matter of fact, back then, it was a requirement for the torrent to always be bootstrapped when using desktop clients. The setting to enable/disable the protocol was more of a thing for development (this might have changed by now).

Considering that, it indeed makes sense to keep the client running once it has started (unless the protocol is disabled entirely).

I see, thank you for clarifying that.

The reason I brought this up here is because I thought, when !online, the torrent client might cause high CPU usage again, but maybe that's not the case?

Yes, the torrent client only uses a lot of CPU when it's started while offline.

Here I'm enabling and disabling the network, but the CPU usage remains low:

torrent_goes_offline.mp4

Copy link
Member

@jrainville jrainville left a comment

Choose a reason for hiding this comment

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

LGTM

@friofry friofry force-pushed the ab/issue-14510-fix-torrent-start branch from 76538ee to 7a16a96 Compare May 8, 2024 19:00
@friofry friofry force-pushed the ab/issue-14510-fix-torrent-start branch from 7a16a96 to 5a76c98 Compare May 8, 2024 19:50
@friofry friofry merged commit 6b5315b into develop May 9, 2024
9 checks passed
@friofry friofry deleted the ab/issue-14510-fix-torrent-start branch May 9, 2024 04:00
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.

100% of the CPU is used when there is no network
4 participants