Skip to content

Commit 17060df

Browse files
committedNov 21, 2024·
Fix: Better hybrid file-system management for caching.
1 parent 51dfe6d commit 17060df

File tree

7 files changed

+54
-42
lines changed

7 files changed

+54
-42
lines changed
 

‎stdlib/source/library/lux/compiler/language/lux/phase/translation/jvm/runtime.lux

+4-4
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@
9191
[Phase translation.Phase]
9292
[Handler translation.Handler]
9393
[Bundle translation.Bundle]
94-
[Extender translation.Extender]]
95-
)
94+
[Extender translation.Extender]])
9695

9796
(every .public (Expression i)
9897
(-> Phase Archive i
@@ -102,9 +101,10 @@
102101
(translation.Host (Bytecode Any) Definition))
103102

104103
(the .public (class_name [module id])
105-
(-> unit.ID Text)
104+
(-> unit.ID
105+
Text)
106106
(text "lux"
107-
"." (%.natural (++ (.universe#)))
107+
"." (%.natural (n.% 10 (++ (.universe#))))
108108
"." (%.natural module)
109109
"." (%.natural id)))
110110

‎stdlib/source/library/lux/compiler/language/lux/phase/translation/reference.lux

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
["%" \\injection]]]
1010
[macro
1111
["[0]" expansion]
12-
["[0]" template]]]]
12+
["[0]" template]]
13+
[math
14+
[number
15+
[/64
16+
["n" natural]]]]]]
1317
[////
1418
["[0]" phase (.use "[1]#[0]" monad)]
1519
["[0]" translation]
@@ -21,7 +25,7 @@
2125

2226
(the .public (artifact [module artifact])
2327
(-> unit.ID Text)
24-
(text "u" (%.natural (.universe#))
28+
(text "u" (%.natural (n.% 10 (++ (.universe#))))
2529
"m" (%.natural module)
2630
"a" (%.natural artifact)))
2731

‎stdlib/source/library/lux/compiler/meta/cache.lux

+13-1
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,24 @@
99
[error
1010
["[0]" try (.only Try)]]
1111
[world
12-
["[0]" file]]]])
12+
["[0]" file]]
13+
[function
14+
[predicate (.only Predicate)]]
15+
[data
16+
["[0]" text]]]])
1317

1418
(the .public path
1519
file.Path
1620
"cache")
1721

22+
(the .public (path? fs it)
23+
(for_any (_ !)
24+
(-> (file.System !)
25+
(Predicate file.Path)))
26+
(let [prefix (text ..path (by fs delimiter))]
27+
(or (text.starts_with? prefix it)
28+
(text.= path it))))
29+
1830
(the .public (enabled? fs)
1931
(for_any (_ !)
2032
(-> (file.System !)

‎stdlib/source/library/lux/compiler/meta/io/archive.lux

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199

200200
(the pseudo_module
201201
Text
202-
"(Lux Caching System)")
202+
"(Caching System)")
203203

204204
(the cache_of
205205
(-> (List Custom)

‎stdlib/source/library/lux/compiler/program.lux

+22-31
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,16 @@
149149
(by host delimiter))
150150
(,, (template.with [<name>]
151151
[(the (<name> path)
152-
(monad.let future.monad
153-
[?/0 (by cache <name> path)
154-
?/1 (by host <name> path)]
155-
(pure (or ?/0 ?/1))))]
152+
(if (cache.path? cache path)
153+
(by cache <name> path)
154+
(by host <name> path)))]
156155

157156
[[file?]
158157
[directory?]]))
158+
(the (read path)
159+
(if (cache.path? cache path)
160+
(by cache read path)
161+
(by host read path)))
159162
(,, (template.with [<name>]
160163
[(the <name>
161164
(by cache <name>))]
@@ -167,21 +170,9 @@
167170
[file_size]
168171
[last_modified]
169172
[can_execute?]
170-
[delete]]))
171-
(the (read path)
172-
(monad.let future.monad
173-
[it (by cache read path)]
174-
(when it
175-
{try.#Failure _}
176-
(by host read path)
177-
178-
_
179-
(pure it))))
180-
(,, (template.with [<name>]
181-
[(the <name>
182-
(by cache <name>))]
183-
184-
[[modify]
173+
[delete]
174+
175+
[modify]
185176
[write]
186177
[append]
187178
[move]]))
@@ -276,14 +267,14 @@
276267
tar)]
277268
(pure [])))))
278269

279-
(the (cache! original_fs context platform)
270+
(the (cache! host_fs context platform)
280271
(for_any (_ <parameters>)
281272
(-> (file.System Future) Context (Platform <parameters>)
282273
(Future (Try Any))))
283274
(monad.let (try.with future.monad)
284275
[cache (cache_tar context (its platform.#file_system platform))]
285-
(by original_fs write
286-
(cache_path original_fs context)
276+
(by host_fs write
277+
(cache_path host_fs context)
287278
(by tar.binary as cache))))
288279

289280
(the (with_cache it)
@@ -294,15 +285,15 @@
294285
[cache_fs
295286
(revised platform.#file_system (hybrid_fs cache_fs) it)]))
296287

297-
(the (enable_output! original_fs context)
288+
(the (enable_output! host_fs context)
298289
(-> (file.System Future) Context
299290
(Future (Try Any)))
300291
(let [target_root (its context.#target context)]
301292
(monad.let [! future.monad]
302-
[? (by original_fs directory? target_root)]
293+
[? (by host_fs directory? target_root)]
303294
(if ?
304295
(pure {try.#Success []})
305-
(file.make_directories ! original_fs target_root)))))
296+
(file.make_directories ! host_fs target_root)))))
306297

307298
(the .public (compiler lux_compiler file_context
308299
expander host_analysis platform translation_bundle host_declaration_bundle program global extender
@@ -328,10 +319,10 @@
328319
(<| (or_crash! "Compilation failed:")
329320
..timed
330321
(monad.let [! (try.with !)]
331-
[.let [original_fs (its platform.#file_system platform)
322+
[.let [host_fs (its platform.#file_system platform)
332323
[cache_fs platform] (with_cache platform)]
333-
_ (enable_output! original_fs file_context)
334-
_ (load_cache! original_fs cache_fs file_context)
324+
_ (enable_output! host_fs file_context)
325+
_ (load_cache! host_fs cache_fs file_context)
335326
import (import.import (its platform.#file_system platform) (its cli.#libraries compilation))
336327
.let [all_extensions [(analysisE.bundle host_analysis)
337328
synthesisE.bundle
@@ -375,12 +366,12 @@
375366
{try.#Success [archive state]}
376367
(monad.let !
377368
[_ (cache/archive.cache! (its platform.#file_system platform) (its cli.#configuration compilation) archive)
378-
_ (cache! original_fs file_context platform)
369+
_ (cache! host_fs file_context platform)
379370
host_dependencies (..load_host_dependencies (its platform.#file_system platform)
380371
(its cli.#host_dependencies compilation))
381372

382373
_ (..package! file_context
383-
original_fs
374+
host_fs
384375
host_dependencies
385376
packager,package
386377
archive
@@ -389,7 +380,7 @@
389380

390381
{try.#Failure error}
391382
(monad.let !
392-
[_ (cache! original_fs file_context platform)]
383+
[_ (cache! host_fs file_context platform)]
393384
(future#pure {try.#Failure error})))))
394385

395386
{cli.#Export export}

‎stdlib/source/library/lux/transduction.lux

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
... https://clojure.org/news/2012/05/08/reducers
1313
... https://clojure.org/news/2012/05/15/anatomy-of-reducer
1414
(every .public (Reduction summary detail)
15-
(-> detail summary
16-
summary))
15+
(-> detail
16+
(Change summary)))
1717

1818
(the .public functor
1919
(for_any (_ summary)

‎stdlib/source/test/lux/compiler/meta/archive.lux

+6-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,12 @@
162162
(list [module/0' @module/0' entry'])
163163
(and (same? module/0 module/0')
164164
(same? @module/0 @module/0')
165-
(same? entry entry'))
165+
(when entry'
166+
{.#Some entry'}
167+
(same? entry entry')
168+
169+
else
170+
false))
166171

167172
_
168173
false))))

0 commit comments

Comments
 (0)
Please sign in to comment.