Commit f4214df
committed
fix(core): tighten cache-wrapper guards and fix __contains__ atime bump
Roborev jobs NVIDIA#1756 and NVIDIA#1757 surfaced four medium findings:
* (NVIDIA#1756 medium @ _program_cache.py:1390) ``FileStreamProgramCache.__contains__``
routed through ``__getitem__``, which read the full payload and called
``_touch_atime``. Membership probes thus counted as LRU reads,
inverting eviction relative to genuine reads. Fixed by making
``__contains__`` a stat-only ``self._path_for_key(key).exists()``
check.
* (NVIDIA#1756 medium @ _program_cache.py:440) NVRTC uses ``options.name`` as
the source filename and resolves quoted ``#include "x.h"`` directives
relative to its directory. The cache cannot observe edits to
neighbour headers, so an ``options.name`` with a directory
component must require an ``extra_digest`` -- the same treatment
``include_path``/``pre_include`` already get. Added the guard in
``make_program_cache_key`` (rejecting ``"/"`` and ``"\\"`` in
``options.name`` on the NVRTC backend when ``extra_digest`` is
``None``).
* (NVIDIA#1757 medium @ _program.pyx:156) Cache hits dropped
``ObjectCode.symbol_mapping`` even when ``name_expressions`` were
provided. The first call (miss) returned an ObjectCode WITH
mappings; every subsequent call (hit) returned one WITHOUT --
silently breaking later ``get_kernel(name_expression)`` lookups
that worked on the uncached path. Fixed by rejecting non-empty
``name_expressions`` in ``Program.compile(cache=...)`` so hit and
miss behavior cannot diverge. Compiles that need
``name_expressions`` should run without ``cache=``, or look up
mangled symbols by hand from the cached ``ObjectCode``.
* (NVIDIA#1757 medium @ _program.pyx:142) The ``Program.compile`` docstring
claimed NVRTC ``options.name`` with a directory component is
rejected, but the wrapper just delegated to
``make_program_cache_key`` without that helper enforcing it. Now
enforced (via the helper, per the previous bullet) and tested
end-to-end via the wrapper.
Tests cover the new rejections (parametrized over ``/``, ``\\``,
absolute paths, parent-relative paths), the ``extra_digest`` escape
hatch, the ``name_expressions`` rejection (and that an empty
``name_expressions`` is still accepted), and the ``__contains__``
atime-preservation invariant (hammer membership on a cold key, then
write a third entry; the cold key must evict, proving the
membership probes did not promote it).1 parent 2607234 commit f4214df
4 files changed
Lines changed: 183 additions & 46 deletions
File tree
- cuda_core
- cuda/core
- utils
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
109 | | - | |
110 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
124 | 126 | | |
125 | 127 | | |
126 | 128 | | |
| |||
130 | 132 | | |
131 | 133 | | |
132 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
133 | 155 | | |
134 | 156 | | |
135 | 157 | | |
| |||
150 | 172 | | |
151 | 173 | | |
152 | 174 | | |
153 | | - | |
154 | 175 | | |
155 | 176 | | |
156 | 177 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
607 | 607 | | |
608 | 608 | | |
609 | 609 | | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
616 | | - | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
617 | 619 | | |
618 | 620 | | |
619 | 621 | | |
| |||
678 | 680 | | |
679 | 681 | | |
680 | 682 | | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
681 | 700 | | |
682 | 701 | | |
683 | 702 | | |
| |||
1388 | 1407 | | |
1389 | 1408 | | |
1390 | 1409 | | |
1391 | | - | |
1392 | | - | |
1393 | | - | |
1394 | | - | |
1395 | | - | |
1396 | | - | |
1397 | | - | |
1398 | | - | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
1399 | 1415 | | |
1400 | 1416 | | |
1401 | 1417 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
945 | 945 | | |
946 | 946 | | |
947 | 947 | | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
948 | 990 | | |
949 | 991 | | |
950 | 992 | | |
| |||
1239 | 1281 | | |
1240 | 1282 | | |
1241 | 1283 | | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
1242 | 1309 | | |
1243 | 1310 | | |
1244 | 1311 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
120 | | - | |
121 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
122 | 127 | | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | 128 | | |
127 | 129 | | |
128 | | - | |
129 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
130 | 137 | | |
131 | | - | |
132 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
133 | 151 | | |
134 | 152 | | |
135 | 153 | | |
| |||
148 | 166 | | |
149 | 167 | | |
150 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
151 | 188 | | |
152 | 189 | | |
153 | 190 | | |
| |||
200 | 237 | | |
201 | 238 | | |
202 | 239 | | |
203 | | - | |
204 | | - | |
205 | | - | |
| 240 | + | |
206 | 241 | | |
207 | 242 | | |
208 | 243 | | |
| |||
217 | 252 | | |
218 | 253 | | |
219 | 254 | | |
220 | | - | |
221 | | - | |
222 | | - | |
| 255 | + | |
223 | 256 | | |
224 | 257 | | |
225 | 258 | | |
| |||
0 commit comments