lt_rs/alerts/
performance_warning.rs

1#[cfg_attr(feature = "safe_enums", derive(num_enum::FromPrimitive))]
2#[repr(u8)]
3pub enum PerformanceWarning {
4    /// This warning means that the number of bytes queued to be written to disk
5    /// exceeds the max disk byte queue setting (``settings_pack::max_queued_disk_bytes``).
6    /// This might restrict the download rate, by not queuing up enough write jobs
7    /// to the disk I/O thread. When this alert is posted, peer connections are
8    /// temporarily stopped from downloading, until the queued disk bytes have fallen
9    /// below the limit again. Unless your ``max_queued_disk_bytes`` setting is already
10    /// high, you might want to increase it to get better performance.
11    OutstandingDiskBufferLimitReached,
12
13    /// This is posted when libtorrent would like to send more requests to a peer,
14    /// but it's limited by ``settings_pack::max_out_request_queue``. The queue length
15    /// libtorrent is trying to achieve is determined by the download rate and the
16    /// assumed round-trip-time (``settings_pack::request_queue_time``). The assumed
17    /// round-trip-time is not limited to just the network RTT, but also the remote disk
18    /// access time and message handling time. It defaults to 3 seconds. The target number
19    /// of outstanding requests is set to fill the bandwidth-delay product (assumed RTT
20    /// times download rate divided by number of bytes per request). When this alert
21    /// is posted, there is a risk that the number of outstanding requests is too low
22    /// and limits the download rate. You might want to increase the ``max_out_request_queue``
23    /// setting.
24    OutstandingRequestLimitReached,
25
26    /// This warning is posted when the amount of TCP/IP overhead is greater than the
27    /// upload rate limit. When this happens, the TCP/IP overhead is caused by a much
28    /// faster download rate, triggering TCP ACK packets. These packets eat into the
29    /// rate limit specified to libtorrent. When the overhead traffic is greater than
30    /// the rate limit, libtorrent will not be able to send any actual payload, such
31    /// as piece requests. This means the download rate will suffer, and new requests
32    /// can be sent again. There will be an equilibrium where the download rate, on
33    /// average, is about 20 times the upload rate limit. If you want to maximize the
34    /// download rate, increase the upload rate limit above 5% of your download capacity.
35    UploadLimitTooLow,
36
37    /// This is the same warning as ``upload_limit_too_low`` but referring to the download
38    /// limit instead of upload. This suggests that your download rate limit is much lower
39    /// than your upload capacity. Your upload rate will suffer. To maximize upload rate,
40    /// make sure your download rate limit is above 5% of your upload capacity.
41    DownloadLimitTooLow,
42
43    /// We're stalled on the disk. We want to write to the socket, and we can write
44    /// but our send buffer is empty, waiting to be refilled from the disk.
45    /// This either means the disk is slower than the network connection
46    /// or that our send buffer watermark is too small, because we can
47    /// send it all before the disk gets back to us.
48    /// The number of bytes that we keep outstanding, requested from the disk, is calculated
49    /// as follows:
50    ///
51    /// .. code:: C++
52    ///
53    ///    min(512, max(upload_rate * send_buffer_watermark_factor / 100, send_buffer_watermark))
54    ///
55    /// If you receive this alert, you might want to either increase your ``send_buffer_watermark``
56    /// or ``send_buffer_watermark_factor``.
57    SendBufferWatermarkTooLow,
58
59    /// If the half (or more) of all upload slots are set as optimistic unchoke slots, this
60    /// warning is issued. You probably want more regular (rate based) unchoke slots.
61    TooManyOptimisticUnchokeSlots,
62
63    /// If the disk write queue ever grows larger than half of the cache size, this warning
64    /// is posted. The disk write queue eats into the total disk cache and leaves very little
65    /// left for the actual cache. This causes the disk cache to oscillate in evicting large
66    /// portions of the cache before allowing peers to download any more, onto the disk write
67    /// queue. Either lower ``max_queued_disk_bytes`` or increase ``cache_size``.
68    TooHighDiskQueueLimit,
69
70    AioLimitReached,
71
72    #[deprecated]
73    BittyrantWithNoUplimit,
74
75    /// This is generated if outgoing peer connections are failing because of *address in use*
76    /// errors, indicating that ``settings_pack::outgoing_ports`` is set and is too small of
77    /// a range. Consider not using the ``outgoing_ports`` setting at all, or widen the range to
78    /// include more ports.
79    TooFewOutgoingPorts,
80
81    TooFewFileDescriptors,
82
83    #[cfg(feature = "safe_enums")]
84    #[num_enum(default)]
85    UnknownError,
86}
87
88impl PerformanceWarning {
89    pub(crate) fn from_u8(v: u8) -> Self {
90        cfg_if::cfg_if! {
91            if #[cfg(feature = "safe_enums")] {
92                v.into()
93            } else {
94                unsafe { std::mem::transmute(v) }
95            }
96        }
97    }
98}