Commit 0b589ff
committed
Stop using IOChannel in NetworkCache
https://bugs.webkit.org/show_bug.cgi?id=290211
rdar://142645876
Reviewed by Per Arne Vollan.
This is a speculative fix for a hard-to-repro issue where page loads sometimes hang for minutes
while the system is under heavy load.
What we see in logs is that the disk network cache lookup ends up on a pri 4 default overcommit
dispatch queue. That thread is parked in a pread and gets preempted for minutes while other higher
pri work is occurring. The thing that is enqueuing the pread on to that dispatch queue is
`dispatch_io_read`, which enqueues that block on to a queue that it controls. We think that probably
something is going wrong with the priority propagation to that queue sometimes, as the network cache
lookup hops from main thread => network cache I/O queue => dispatch_io private queue and back.
As a speculative fix:
- Stop using `dispatch_io` / `IOChannel` altogether. It buys us nothing other than adding extra
thread hops, making things harder to debug, and perhaps exposing some latent bug in priority
propagation. Instead, just do the I/O directly on the network cache's I/O queues.
- Change the priority of the read-only I/O queue from default to UserInteractive, since it's on the
blocking path for resource fetching.
- Change the priority of the write I/O queues from Background to Utility, since Background is very
punitive (capped at max pri 4), and if we get anything wrong, getting capped at max pri 4 can
cause minutes of starvation.
WriteOperations also had an completion handler that received an integer errno as an argument. This
was unused, so I removed it.
* Source/WebKit/NetworkProcess/cache/NetworkCacheData.cpp:
(WebKit::NetworkCache::Data::Data):
* Source/WebKit/NetworkProcess/cache/NetworkCacheData.h:
* Source/WebKit/NetworkProcess/cache/NetworkCacheDataCocoa.mm:
(WebKit::NetworkCache::Data::Data):
* Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::WriteOperation::WriteOperation):
(WebKit::NetworkCache::Storage::WriteOperation::~WriteOperation):
(WebKit::NetworkCache::Storage::Storage):
(WebKit::NetworkCache::Storage::dispatchReadOperation):
(WebKit::NetworkCache::Storage::readRecordFromData):
(WebKit::NetworkCache::Storage::dispatchWriteOperation):
(WebKit::NetworkCache::Storage::finishWriteOperationActivity):
(WebKit::NetworkCache::Storage::store):
(WebKit::NetworkCache::Storage::WriteOperation::invokeCompletionHandler): Deleted.
* Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h:
(WebKit::NetworkCache::Storage::store): Deleted.
Canonical link: https://commits.webkit.org/292576@main1 parent baef96f commit 0b589ff
5 files changed
Lines changed: 40 additions & 39 deletions
File tree
- Source/WebKit/NetworkProcess/cache
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
42 | 54 | | |
43 | 55 | | |
44 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| 63 | + | |
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
| |||
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
76 | | - | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
50 | 56 | | |
51 | 57 | | |
52 | 58 | | |
| |||
Lines changed: 17 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
209 | | - | |
| 209 | + | |
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
214 | 213 | | |
215 | 214 | | |
216 | 215 | | |
217 | 216 | | |
218 | 217 | | |
219 | 218 | | |
220 | 219 | | |
221 | | - | |
222 | | - | |
223 | 220 | | |
224 | 221 | | |
225 | 222 | | |
226 | 223 | | |
227 | 224 | | |
228 | | - | |
229 | 225 | | |
230 | 226 | | |
231 | 227 | | |
232 | 228 | | |
233 | 229 | | |
234 | | - | |
235 | 230 | | |
236 | 231 | | |
237 | 232 | | |
| |||
242 | 237 | | |
243 | 238 | | |
244 | 239 | | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | 240 | | |
252 | 241 | | |
253 | 242 | | |
| |||
414 | 403 | | |
415 | 404 | | |
416 | 405 | | |
417 | | - | |
418 | | - | |
419 | | - | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
420 | 409 | | |
421 | 410 | | |
422 | 411 | | |
| |||
884 | 873 | | |
885 | 874 | | |
886 | 875 | | |
887 | | - | |
888 | | - | |
889 | | - | |
890 | | - | |
891 | | - | |
892 | | - | |
| 876 | + | |
893 | 877 | | |
894 | 878 | | |
895 | 879 | | |
896 | 880 | | |
897 | | - | |
| 881 | + | |
898 | 882 | | |
899 | 883 | | |
900 | | - | |
901 | | - | |
| 884 | + | |
| 885 | + | |
902 | 886 | | |
903 | 887 | | |
904 | 888 | | |
| |||
1039 | 1023 | | |
1040 | 1024 | | |
1041 | 1025 | | |
| 1026 | + | |
1042 | 1027 | | |
1043 | | - | |
1044 | | - | |
1045 | | - | |
1046 | | - | |
1047 | | - | |
1048 | | - | |
| 1028 | + | |
| 1029 | + | |
1049 | 1030 | | |
1050 | | - | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
1051 | 1034 | | |
1052 | 1035 | | |
1053 | 1036 | | |
| |||
1065 | 1048 | | |
1066 | 1049 | | |
1067 | 1050 | | |
1068 | | - | |
| 1051 | + | |
1069 | 1052 | | |
1070 | 1053 | | |
1071 | 1054 | | |
1072 | 1055 | | |
1073 | 1056 | | |
1074 | 1057 | | |
1075 | 1058 | | |
1076 | | - | |
1077 | 1059 | | |
1078 | 1060 | | |
1079 | 1061 | | |
| |||
1108 | 1090 | | |
1109 | 1091 | | |
1110 | 1092 | | |
1111 | | - | |
| 1093 | + | |
1112 | 1094 | | |
1113 | 1095 | | |
1114 | 1096 | | |
1115 | 1097 | | |
1116 | 1098 | | |
1117 | 1099 | | |
1118 | 1100 | | |
1119 | | - | |
| 1101 | + | |
1120 | 1102 | | |
1121 | 1103 | | |
1122 | 1104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
| 169 | + | |
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
| 175 | + | |
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| |||
0 commit comments