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

feat(rust): avoiding memory fragmentation by reducing allocations #8640

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

davide-baldo
Copy link
Member

@davide-baldo davide-baldo commented Nov 14, 2024

This PR addresses the memory fragmentation from two sides, first many mini-allocations are avoided, mostly around Route, but also avoiding extra unused allocation in .ok_else(XXX).
To improve the benefits, the payload size was also increased to 96KB. This also means that the minimum bandwidth for a stable portal is 1Mbits.

BEFORE:

[  5] local 127.0.0.1 port 57051 connected to 127.0.0.1 port 8200
[  5] local 127.0.0.1 port 5500 connected to 127.0.0.1 port 57052
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec  1.89 GBytes  16.1 Gbits/sec
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.01   sec  1.89 GBytes  16.1 Gbits/sec
[  5]   1.01-2.01   sec  1.94 GBytes  16.7 Gbits/sec
[  5]   1.00-2.01   sec  1.94 GBytes  16.7 Gbits/sec
[  5]   2.01-3.00   sec  1.93 GBytes  16.6 Gbits/sec
[  5]   2.01-3.00   sec  1.93 GBytes  16.6 Gbits/sec
[  5]   3.00-4.01   sec  1.81 GBytes  15.6 Gbits/sec
[  5]   3.00-4.01   sec  1.81 GBytes  15.6 Gbits/sec
[  5]   4.01-5.00   sec  1.98 GBytes  17.1 Gbits/sec
[  5]   4.01-5.00   sec  1.98 GBytes  17.1 Gbits/sec
[  5]   5.00-6.01   sec  1.94 GBytes  16.6 Gbits/sec
[  5]   5.00-6.01   sec  1.94 GBytes  16.6 Gbits/sec
[  5]   6.01-7.00   sec  1.97 GBytes  17.0 Gbits/sec
[  5]   6.01-7.00   sec  1.97 GBytes  17.0 Gbits/sec
[  5]   7.00-8.01   sec  1.99 GBytes  17.0 Gbits/sec
[  5]   7.00-8.01   sec  1.99 GBytes  17.0 Gbits/sec
[  5]   8.01-9.00   sec  1.75 GBytes  15.1 Gbits/sec
[  5]   8.01-9.01   sec  1.76 GBytes  15.1 Gbits/sec
[  5]   9.01-10.00  sec  1.87 GBytes  16.1 Gbits/sec
[  5]   9.00-10.00  sec  1.88 GBytes  16.1 Gbits/sec
[  5]  10.00-11.01  sec  1.90 GBytes  16.3 Gbits/sec
[  5]  10.00-11.01  sec  1.90 GBytes  16.3 Gbits/sec
[  5]  11.01-12.00  sec  1.91 GBytes  16.5 Gbits/sec
[  5]  11.01-12.01  sec  1.92 GBytes  16.5 Gbits/sec
[  5]  12.00-13.01  sec  1.95 GBytes  16.6 Gbits/sec
[  5]  12.01-13.01  sec  1.94 GBytes  16.6 Gbits/sec
[  5]  13.01-14.00  sec  1.61 GBytes  13.9 Gbits/sec
[  5]  13.01-14.01  sec  1.61 GBytes  13.9 Gbits/sec
[  5]  14.01-15.00  sec  1.81 GBytes  15.5 Gbits/sec
[  5]  14.00-15.01  sec  1.81 GBytes  15.5 Gbits/sec
[  5]  15.01-16.01  sec  1.86 GBytes  16.0 Gbits/sec
[  5]  15.00-16.01  sec  1.87 GBytes  16.0 Gbits/sec
[  5]  16.01-17.00  sec  1.92 GBytes  16.6 Gbits/sec
[  5]  16.01-17.00  sec  1.92 GBytes  16.6 Gbits/sec
[  5]  17.00-18.00  sec  1.95 GBytes  16.7 Gbits/sec
[  5]  17.00-18.00  sec  1.95 GBytes  16.7 Gbits/sec
[  5]  18.00-19.01  sec  1.82 GBytes  15.6 Gbits/sec
[  5]  18.00-19.01  sec  1.82 GBytes  15.6 Gbits/sec
[  5]  19.01-20.00  sec  1.73 GBytes  14.9 Gbits/sec
[  5]  19.01-20.00  sec  1.73 GBytes  14.9 Gbits/sec
[  5]  20.00-21.01  sec  1.76 GBytes  15.1 Gbits/sec
[  5]  20.00-21.01  sec  1.76 GBytes  15.1 Gbits/sec
[  5]  21.01-22.01  sec  1.85 GBytes  15.9 Gbits/sec
[  5]  21.01-22.00  sec  1.85 GBytes  15.9 Gbits/sec
[  5]  22.01-23.00  sec  1.85 GBytes  15.9 Gbits/sec
[  5]  22.00-23.01  sec  1.85 GBytes  15.9 Gbits/sec
[  5]  23.00-24.00  sec  1.66 GBytes  14.3 Gbits/sec
[  5]  23.01-24.00  sec  1.66 GBytes  14.3 Gbits/sec
[  5]  24.00-25.00  sec  1.24 GBytes  10.7 Gbits/sec
[  5]  24.00-25.01  sec  1.25 GBytes  10.7 Gbits/sec
[  5]  25.01-26.00  sec   774 MBytes  6.53 Gbits/sec
[  5]  25.00-26.01  sec   778 MBytes  6.50 Gbits/sec
[  5]  26.01-27.00  sec  1001 MBytes  8.45 Gbits/sec
[  5]  26.00-27.01  sec  1008 MBytes  8.42 Gbits/sec
[  5]  27.00-28.00  sec  1.18 GBytes  10.1 Gbits/sec
[  5]  27.01-28.00  sec  1.17 GBytes  10.1 Gbits/sec
[  5]  28.00-29.00  sec  1.12 GBytes  9.63 Gbits/sec
[  5]  28.00-29.01  sec  1.13 GBytes  9.64 Gbits/sec
[  5]  29.01-30.00  sec  1.11 GBytes  9.52 Gbits/sec
[  5]  29.00-30.01  sec  1.11 GBytes  9.52 Gbits/sec
[  5]  30.01-31.00  sec   720 MBytes  6.07 Gbits/sec
[  5]  30.00-31.00  sec   726 MBytes  6.08 Gbits/sec
[  5]  31.00-32.00  sec  1.35 GBytes  11.6 Gbits/sec
[  5]  31.00-32.01  sec  1.35 GBytes  11.6 Gbits/sec
[  5]  32.01-33.00  sec  1.43 GBytes  12.3 Gbits/sec
[  5]  32.00-33.01  sec  1.44 GBytes  12.3 Gbits/sec
[  5]  33.01-34.00  sec  1.43 GBytes  12.3 Gbits/sec
[  5]  33.00-34.01  sec  1.43 GBytes  12.3 Gbits/sec
[  5]  34.01-35.01  sec  1.33 GBytes  11.4 Gbits/sec
[  5]  34.00-35.01  sec  1.33 GBytes  11.4 Gbits/sec
[  5]  35.01-36.01  sec  1.41 GBytes  12.1 Gbits/sec
[  5]  35.01-36.01  sec  1.41 GBytes  12.1 Gbits/sec
[  5]  36.01-37.01  sec  1.54 GBytes  13.2 Gbits/sec
[  5]  36.01-37.01  sec  1.53 GBytes  13.2 Gbits/sec
[  5]  37.01-38.00  sec  1.63 GBytes  14.0 Gbits/sec
[  5]  37.01-38.01  sec  1.63 GBytes  14.0 Gbits/sec
[  5]  38.00-39.00  sec  1.78 GBytes  15.3 Gbits/sec
[  5]  38.01-39.01  sec  1.79 GBytes  15.3 Gbits/sec
[  5]  39.00-40.00  sec  1.66 GBytes  14.2 Gbits/sec
[  5]  39.01-40.01  sec  1.65 GBytes  14.2 Gbits/sec
[  5]  40.00-41.00  sec  1.61 GBytes  13.8 Gbits/sec
[  5]  40.01-41.01  sec  1.61 GBytes  13.8 Gbits/sec
[  5]  41.01-42.01  sec  1.73 GBytes  14.9 Gbits/sec
[  5]  41.00-42.01  sec  1.74 GBytes  14.9 Gbits/sec
[  5]  42.01-43.00  sec  2.00 GBytes  17.2 Gbits/sec
[  5]  42.01-43.00  sec  2.00 GBytes  17.2 Gbits/sec
[  5]  43.00-44.01  sec  1.91 GBytes  16.3 Gbits/sec
[  5]  43.00-44.01  sec  1.91 GBytes  16.3 Gbits/sec
[  5]  44.01-45.01  sec  1.99 GBytes  17.1 Gbits/sec
[  5]  44.01-45.01  sec  1.99 GBytes  17.1 Gbits/sec
[  5]  45.01-46.00  sec  1.99 GBytes  17.2 Gbits/sec
[  5]  45.01-46.00  sec  2.00 GBytes  17.2 Gbits/sec
[  5]  46.00-47.01  sec  1.95 GBytes  16.7 Gbits/sec
[  5]  46.00-47.01  sec  1.96 GBytes  16.7 Gbits/sec
[  5]  47.01-48.00  sec  2.00 GBytes  17.2 Gbits/sec
[  5]  47.01-48.00  sec  2.00 GBytes  17.2 Gbits/sec
[  5]  48.00-49.01  sec  1.99 GBytes  17.1 Gbits/sec
[  5]  48.00-49.00  sec  1.99 GBytes  17.1 Gbits/sec
[  5]  49.01-50.00  sec  1.90 GBytes  16.4 Gbits/sec
[  5]  49.00-50.00  sec  1.90 GBytes  16.3 Gbits/sec
[  5]  50.00-51.01  sec  1.93 GBytes  16.6 Gbits/sec
[  5]  50.00-51.01  sec  1.93 GBytes  16.6 Gbits/sec
[  5]  51.01-52.00  sec  1.99 GBytes  17.2 Gbits/sec
[  5]  51.01-52.00  sec  2.00 GBytes  17.2 Gbits/sec
[  5]  52.00-53.00  sec  1.62 GBytes  13.9 Gbits/sec
[  5]  52.00-53.00  sec  1.61 GBytes  13.9 Gbits/sec
[  5]  53.00-54.00  sec  1.68 GBytes  14.4 Gbits/sec
[  5]  53.00-54.00  sec  1.68 GBytes  14.4 Gbits/sec
[  5]  54.00-55.00  sec  1.29 GBytes  11.1 Gbits/sec
[  5]  54.00-55.00  sec  1.29 GBytes  11.1 Gbits/sec
[  5]  55.00-56.00  sec  1.27 GBytes  10.9 Gbits/sec
[  5]  55.00-56.01  sec  1.27 GBytes  10.9 Gbits/sec
[  5]  56.01-57.00  sec  1.39 GBytes  11.9 Gbits/sec
[  5]  56.00-57.01  sec  1.39 GBytes  11.9 Gbits/sec
[  5]  57.01-58.01  sec   804 MBytes  6.75 Gbits/sec
[  5]  57.00-58.01  sec   804 MBytes  6.74 Gbits/sec
[  5]  58.01-59.00  sec  1.02 GBytes  8.79 Gbits/sec
[  5]  58.01-59.01  sec  1.02 GBytes  8.79 Gbits/sec
[  5]  59.00-60.00  sec  1.50 GBytes  12.8 Gbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-60.00  sec  98.9 GBytes  14.2 Gbits/sec                  receiver
[  5]  59.01-60.00  sec  1.49 GBytes  12.8 Gbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-60.00  sec  98.9 GBytes  14.2 Gbits/sec                  sender
[  5]   0.00-60.00  sec  98.9 GBytes  14.2 Gbits/sec                  receiver

AFTER:

[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec  2.36 GBytes  20.1 Gbits/sec
[  5]   0.00-1.01   sec  2.35 GBytes  20.1 Gbits/sec
[  5]   1.00-2.00   sec  2.35 GBytes  20.2 Gbits/sec
[  5]   1.01-2.01   sec  2.36 GBytes  20.2 Gbits/sec
[  5]   2.01-3.01   sec  2.35 GBytes  20.2 Gbits/sec
[  5]   2.00-3.00   sec  2.36 GBytes  20.2 Gbits/sec
[  5]   3.01-4.00   sec  2.40 GBytes  20.6 Gbits/sec
[  5]   3.00-4.00   sec  2.40 GBytes  20.6 Gbits/sec
[  5]   4.00-5.01   sec  2.44 GBytes  20.9 Gbits/sec
[  5]   4.00-5.00   sec  2.44 GBytes  20.9 Gbits/sec
[  5]   5.01-6.01   sec  2.34 GBytes  20.1 Gbits/sec
[  5]   5.00-6.01   sec  2.34 GBytes  20.1 Gbits/sec
[  5]   6.01-7.00   sec  2.41 GBytes  20.8 Gbits/sec
[  5]   6.01-7.01   sec  2.42 GBytes  20.8 Gbits/sec
[  5]   7.00-8.00   sec  2.40 GBytes  20.6 Gbits/sec
[  5]   7.01-8.01   sec  2.41 GBytes  20.7 Gbits/sec
[  5]   8.01-9.00   sec  2.37 GBytes  20.3 Gbits/sec
[  5]   8.00-9.01   sec  2.38 GBytes  20.3 Gbits/sec
[  5]   9.01-10.01  sec  2.38 GBytes  20.5 Gbits/sec
[  5]   9.00-10.00  sec  2.38 GBytes  20.5 Gbits/sec
[  5]  10.01-11.00  sec  2.46 GBytes  21.2 Gbits/sec
[  5]  10.00-11.00  sec  2.47 GBytes  21.2 Gbits/sec
[  5]  11.00-12.01  sec  2.39 GBytes  20.5 Gbits/sec
[  5]  11.00-12.00  sec  2.39 GBytes  20.5 Gbits/sec
[  5]  12.01-13.00  sec  2.44 GBytes  21.0 Gbits/sec
[  5]  12.00-13.01  sec  2.45 GBytes  21.0 Gbits/sec
[  5]  13.01-14.00  sec  2.45 GBytes  21.1 Gbits/sec
[  5]  13.00-14.00  sec  2.46 GBytes  21.1 Gbits/sec
[  5]  14.00-15.01  sec  2.41 GBytes  20.7 Gbits/sec
[  5]  14.00-15.01  sec  2.41 GBytes  20.7 Gbits/sec
[  5]  15.01-16.00  sec  2.46 GBytes  21.2 Gbits/sec
[  5]  15.01-16.01  sec  2.46 GBytes  21.2 Gbits/sec
[  5]  16.00-17.01  sec  2.42 GBytes  20.8 Gbits/sec
[  5]  16.01-17.01  sec  2.42 GBytes  20.8 Gbits/sec
[  5]  17.01-18.00  sec  2.42 GBytes  20.8 Gbits/sec
[  5]  17.01-18.00  sec  2.42 GBytes  20.8 Gbits/sec
[  5]  18.00-19.00  sec  2.46 GBytes  21.1 Gbits/sec
[  5]  18.00-19.00  sec  2.46 GBytes  21.1 Gbits/sec
[  5]  19.00-20.01  sec  2.43 GBytes  20.8 Gbits/sec
[  5]  19.00-20.01  sec  2.43 GBytes  20.8 Gbits/sec
[  5]  20.01-21.00  sec  2.44 GBytes  21.0 Gbits/sec
[  5]  20.01-21.01  sec  2.44 GBytes  21.0 Gbits/sec
[  5]  21.01-22.01  sec  2.44 GBytes  20.9 Gbits/sec
[  5]  21.00-22.01  sec  2.44 GBytes  20.9 Gbits/sec
[  5]  22.01-23.00  sec  2.42 GBytes  20.9 Gbits/sec
[  5]  22.01-23.01  sec  2.43 GBytes  20.9 Gbits/sec
[  5]  23.00-24.01  sec  2.45 GBytes  21.0 Gbits/sec
[  5]  23.01-24.01  sec  2.44 GBytes  21.0 Gbits/sec
[  5]  24.01-25.00  sec  2.46 GBytes  21.2 Gbits/sec
[  5]  24.01-25.01  sec  2.46 GBytes  21.2 Gbits/sec
[  5]  25.01-26.00  sec  2.44 GBytes  21.0 Gbits/sec
[  5]  25.00-26.01  sec  2.45 GBytes  21.0 Gbits/sec
[  5]  26.00-27.01  sec  2.38 GBytes  20.5 Gbits/sec
[  5]  26.01-27.01  sec  2.38 GBytes  20.5 Gbits/sec
[  5]  27.01-28.01  sec  2.46 GBytes  21.1 Gbits/sec
[  5]  27.01-28.01  sec  2.46 GBytes  21.1 Gbits/sec
[  5]  28.01-29.01  sec  2.39 GBytes  20.5 Gbits/sec
[  5]  28.01-29.01  sec  2.39 GBytes  20.5 Gbits/sec
[  5]  29.01-30.00  sec  2.45 GBytes  21.1 Gbits/sec
[  5]  29.01-30.00  sec  2.45 GBytes  21.1 Gbits/sec
[  5]  30.00-31.01  sec  2.35 GBytes  20.2 Gbits/sec
[  5]  30.00-31.00  sec  2.35 GBytes  20.2 Gbits/sec
[  5]  31.01-32.00  sec  2.42 GBytes  20.8 Gbits/sec
[  5]  31.00-32.01  sec  2.43 GBytes  20.8 Gbits/sec
[  5]  32.00-33.01  sec  2.47 GBytes  21.1 Gbits/sec
[  5]  32.01-33.00  sec  2.46 GBytes  21.1 Gbits/sec
[  5]  33.01-34.00  sec  2.41 GBytes  20.8 Gbits/sec
[  5]  33.00-34.01  sec  2.42 GBytes  20.8 Gbits/sec
[  5]  34.00-35.00  sec  2.45 GBytes  21.0 Gbits/sec
[  5]  34.01-35.00  sec  2.44 GBytes  21.0 Gbits/sec
[  5]  35.00-36.01  sec  2.40 GBytes  20.5 Gbits/sec
[  5]  35.00-36.00  sec  2.39 GBytes  20.5 Gbits/sec
[  5]  36.01-37.00  sec  2.41 GBytes  20.7 Gbits/sec
[  5]  36.00-37.00  sec  2.41 GBytes  20.7 Gbits/sec
[  5]  37.00-38.00  sec  2.40 GBytes  20.6 Gbits/sec
[  5]  37.00-38.01  sec  2.40 GBytes  20.6 Gbits/sec
[  5]  38.00-39.01  sec  2.47 GBytes  21.2 Gbits/sec
[  5]  38.01-39.01  sec  2.47 GBytes  21.2 Gbits/sec
[  5]  39.01-40.01  sec  2.41 GBytes  20.7 Gbits/sec
[  5]  39.01-40.01  sec  2.41 GBytes  20.7 Gbits/sec
[  5]  40.01-41.01  sec  2.46 GBytes  21.1 Gbits/sec
[  5]  40.01-41.01  sec  2.45 GBytes  21.1 Gbits/sec
[  5]  41.01-42.01  sec  2.43 GBytes  20.8 Gbits/sec
[  5]  41.01-42.00  sec  2.43 GBytes  20.8 Gbits/sec
[  5]  42.01-43.01  sec  2.45 GBytes  21.0 Gbits/sec
[  5]  42.00-43.01  sec  2.45 GBytes  21.0 Gbits/sec
[  5]  43.01-44.00  sec  2.45 GBytes  21.1 Gbits/sec
[  5]  43.01-44.01  sec  2.46 GBytes  21.1 Gbits/sec
[  5]  44.00-45.00  sec  2.45 GBytes  21.0 Gbits/sec
[  5]  44.01-45.01  sec  2.45 GBytes  21.0 Gbits/sec
[  5]  45.00-46.01  sec  2.44 GBytes  21.0 Gbits/sec
[  5]  45.01-46.00  sec  2.44 GBytes  21.0 Gbits/sec
[  5]  46.01-47.00  sec  2.45 GBytes  21.1 Gbits/sec
[  5]  46.00-47.00  sec  2.45 GBytes  21.1 Gbits/sec
[  5]  47.00-48.00  sec  2.38 GBytes  20.4 Gbits/sec
[  5]  47.00-48.00  sec  2.38 GBytes  20.4 Gbits/sec
[  5]  48.00-49.00  sec  2.39 GBytes  20.6 Gbits/sec
[  5]  48.00-49.01  sec  2.40 GBytes  20.6 Gbits/sec
[  5]  49.01-50.00  sec  2.45 GBytes  21.1 Gbits/sec
[  5]  49.00-50.01  sec  2.47 GBytes  21.1 Gbits/sec
[  5]  50.01-51.01  sec  2.36 GBytes  20.2 Gbits/sec
[  5]  50.00-51.01  sec  2.37 GBytes  20.2 Gbits/sec
[  5]  51.01-52.00  sec  2.41 GBytes  20.8 Gbits/sec
[  5]  51.01-52.00  sec  2.41 GBytes  20.7 Gbits/sec
[  5]  52.00-53.00  sec  2.40 GBytes  20.6 Gbits/sec
[  5]  52.00-53.01  sec  2.41 GBytes  20.6 Gbits/sec
[  5]  53.01-54.00  sec  2.44 GBytes  20.9 Gbits/sec
[  5]  53.00-54.01  sec  2.44 GBytes  20.9 Gbits/sec
[  5]  54.01-55.01  sec  2.41 GBytes  20.7 Gbits/sec
[  5]  54.00-55.00  sec  2.41 GBytes  20.7 Gbits/sec
[  5]  55.00-56.00  sec  2.24 GBytes  19.3 Gbits/sec
[  5]  55.01-56.01  sec  2.24 GBytes  19.3 Gbits/sec
[  5]  56.01-57.01  sec  2.38 GBytes  20.4 Gbits/sec
[  5]  56.00-57.00  sec  2.38 GBytes  20.4 Gbits/sec
[  5]  57.01-58.01  sec  2.37 GBytes  20.4 Gbits/sec
[  5]  57.00-58.01  sec  2.37 GBytes  20.4 Gbits/sec
[  5]  58.01-59.00  sec  2.45 GBytes  21.1 Gbits/sec
[  5]  58.01-59.01  sec  2.45 GBytes  21.1 Gbits/sec
[  5]  59.00-60.01  sec  2.42 GBytes  20.8 Gbits/sec
[  5]  60.01-60.01  sec  2.75 MBytes  20.3 Gbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-60.01  sec   145 GBytes  20.7 Gbits/sec                  receiver
[  5]  59.01-60.01  sec  2.42 GBytes  20.8 Gbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-60.01  sec   145 GBytes  20.7 Gbits/sec                  sender
[  5]   0.00-60.01  sec   145 GBytes  20.7 Gbits/sec                  receiver

@davide-baldo davide-baldo force-pushed the davide-baldo/avoid-memory-fragmentation branch 9 times, most recently from bee4614 to d432379 Compare November 14, 2024 17:40
@davide-baldo davide-baldo marked this pull request as ready for review November 14, 2024 17:49
@davide-baldo davide-baldo requested a review from a team as a code owner November 14, 2024 17:49
@davide-baldo davide-baldo force-pushed the davide-baldo/avoid-memory-fragmentation branch 2 times, most recently from d93bed7 to c73ab96 Compare November 26, 2024 16:53
Copy link
Member

@SanjoDeundiak SanjoDeundiak left a comment

Choose a reason for hiding this comment

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

Very nice improvements!

tools/profile/portal.memory_profile Outdated Show resolved Hide resolved
@@ -85,7 +80,7 @@ impl LocalMessage {

/// Prepend an address on the onward route
pub fn push_front_onward_route(mut self, address: &Address) -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

If we always clone an argument inside the function, we should pass that argument as a value instead of a reference. That will allow us avoiding clone in cases where calling side can give away ownership of the object.
P.S. It's OK if you don't want to make that change in that PR

Copy link
Member

Choose a reason for hiding this comment

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

P.P.S. We have are a lot of such places even in this file

@@ -659,7 +659,7 @@ impl NodeInfo {
pub fn status(&self) -> NodeProcessStatus {
if let Some(pid) = self.pid() {
let mut sys = System::new();
sys.refresh_processes(ProcessesToUpdate::All, false);
sys.refresh_processes(ProcessesToUpdate::Some(&[Pid::from_u32(pid)]), false);
Copy link
Member

Choose a reason for hiding this comment

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

From my memory that didn't work. @adrianbenavides could you please take a look?

Copy link
Member Author

Choose a reason for hiding this comment

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

To me, node list and node show are working

@@ -108,7 +108,7 @@ pub enum PortalInternalMessage {
}

/// Maximum allowed size for a payload
pub const MAX_PAYLOAD_SIZE: usize = 48 * 1024;
pub const MAX_PAYLOAD_SIZE: usize = 96 * 1024;
Copy link
Member

Choose a reason for hiding this comment

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

I suspect that something like 65 should be enough. I doubt we can get more than that in one read. <=== just a guess

Copy link
Member

Choose a reason for hiding this comment

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

I also wonder if we should consider how that data will be sent and split into packets after passing secure channel and getting to the TCP or UDP transport

Copy link
Member Author

@davide-baldo davide-baldo Nov 27, 2024

Choose a reason for hiding this comment

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

I suspect that something like 65 should be enough. I doubt we can get more than that in one read.

We are actually still far away from the performance impact of managing multiple TCP packets in a single read.
The only reason it actually increases the performance, it's due to the reduced number of ockam messages being processed, which reduces the overhead.
It's a diminishing return, for example locally, with 60 the throughput gets to ~13.5, with 96 it's ~16.7, and with 256 it's ~21. 96 felt like a good tradeoff.

I also wonder if we should consider how that data will be sent and split into packets after passing secure channel and getting to the TCP or UDP transport

We should definitively bring down the size to 60 to allow passing through a single UDP packet as soon as the overhead is low enough.

@davide-baldo davide-baldo force-pushed the davide-baldo/avoid-memory-fragmentation branch from c73ab96 to 0b9d541 Compare November 26, 2024 19:26
@davide-baldo davide-baldo force-pushed the davide-baldo/avoid-memory-fragmentation branch from 0b9d541 to 5b04957 Compare November 27, 2024 10:02
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.

2 participants