You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- Note [Housekeeping rule cache and dirty key outside of hls-graph]
1284
+
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1285
+
-- Hls-graph contains its own internal running state for each key in the shakeDatabase.
1286
+
-- ShakeExtras contains `state` field (rule result cache) and `dirtyKeys` (keys that became
1287
+
-- dirty in between build sessions) that is not visible to the hls-graph
1288
+
-- Essentially, we need to keep the rule cache and dirty key and hls-graph's internal state
1289
+
-- in sync.
1290
+
1291
+
-- 1. A dirty key collected in a session should not be removed from dirty keys in the same session.
1292
+
-- Since if we clean out the dirty key in the same session,
1293
+
-- 1.1. we will lose the chance to dirty its reverse dependencies. Since it only happens during session restart.
1294
+
-- 1.2. a key might be marked as dirty in ShakeExtras while it's being recomputed by hls-graph which could lead to it's premature removal from dirtyKeys.
1295
+
-- See issue https://github.com/haskell/haskell-language-server/issues/4093 for more details.
1296
+
1297
+
-- 2. When a key is marked clean in the hls-graph's internal running
1298
+
-- state, the rule cache and dirty keys are updated in the same transaction.
1299
+
-- otherwise, some situations like the following can happen:
1300
+
-- thread 1: hls-graph session run a key
1301
+
-- thread 1: defineEarlyCutoff' run the action for the key
1302
+
-- thread 1: the action is done, rule cache and dirty key are updated
1303
+
-- thread 2: we restart the hls-graph session, thread 1 is killed, the
1304
+
-- hls-graph's internal state is not updated.
1305
+
-- This is problematic with early cut off because we are having a new rule cache matching the
1306
+
-- old hls-graph's internal state, which might case it's reverse dependency to skip the recomputation.
1307
+
-- See https://github.com/haskell/haskell-language-server/issues/4194 for more details.
0 commit comments