Commit b8be884
authored
fix(sync-service): reduce live request wait memory (#4680)
## Motivation
Live shape requests spend most of their long-poll lifetime parked in a
receive while waiting for either a shape change or timeout. Under high
concurrency, parking inside the larger request-handling function kept
more heap live than the small wait state actually needed, which made the
per-request memory floor significant.
## Changes
- Move the blocking live-request receive into a narrow
`wait_for_live_change/2` helper that only holds the change reference and
timeout while parked.
- Convert receive outcomes into small event values and handle response
construction after the wait returns.
- Keep garbage collection immediately before the parked receive, but run
it inside the narrow helper so collection happens with a smaller root
set.
- Remove a dead `SystemMonitor` timer fallback branch that Elixir 1.20
reports as unreachable under warnings-as-errors.
- Add changesets for sync-service and electric-telemetry.
## Decisions
This keeps the waiter in the existing request process instead of
introducing a central waiter registry. That avoids adding a new
register/deregister bottleneck while still reducing the heap retained by
parked live requests. The existing behavior is preserved for new
changes, shape rotation, out-of-bounds checks, read-only timeout
handling, and ordinary no-change responses.1 parent 1b611ca commit b8be884
3 files changed
Lines changed: 92 additions & 60 deletions
File tree
- .changeset
- packages
- electric-telemetry/lib/electric/telemetry
- sync-service/lib/electric/shapes
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
174 | | - | |
175 | 173 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
859 | 859 | | |
860 | 860 | | |
861 | 861 | | |
862 | | - | |
| 862 | + | |
863 | 863 | | |
864 | 864 | | |
865 | 865 | | |
866 | 866 | | |
867 | | - | |
868 | | - | |
869 | | - | |
870 | | - | |
871 | | - | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
872 | 875 | | |
873 | 876 | | |
874 | 877 | | |
875 | 878 | | |
876 | | - | |
877 | | - | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
878 | 929 | | |
879 | 930 | | |
880 | 931 | | |
881 | 932 | | |
882 | 933 | | |
883 | | - | |
884 | | - | |
885 | | - | |
886 | | - | |
887 | | - | |
888 | | - | |
889 | | - | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
890 | 938 | | |
891 | | - | |
892 | | - | |
893 | | - | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
894 | 943 | | |
895 | | - | |
896 | | - | |
897 | | - | |
898 | | - | |
899 | | - | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
900 | 950 | | |
| 951 | + | |
| 952 | + | |
901 | 953 | | |
902 | 954 | | |
903 | 955 | | |
| |||
907 | 959 | | |
908 | 960 | | |
909 | 961 | | |
910 | | - | |
911 | | - | |
912 | | - | |
913 | | - | |
914 | | - | |
915 | | - | |
916 | | - | |
917 | | - | |
918 | | - | |
919 | | - | |
920 | | - | |
921 | | - | |
922 | | - | |
923 | | - | |
924 | | - | |
925 | | - | |
926 | | - | |
927 | | - | |
928 | | - | |
929 | | - | |
930 | | - | |
931 | | - | |
932 | | - | |
933 | | - | |
934 | | - | |
935 | | - | |
936 | | - | |
937 | | - | |
938 | | - | |
939 | | - | |
940 | | - | |
941 | 962 | | |
942 | 963 | | |
943 | 964 | | |
944 | | - | |
945 | | - | |
946 | | - | |
947 | | - | |
948 | 965 | | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
949 | 975 | | |
950 | 976 | | |
951 | 977 | | |
| |||
0 commit comments