blob: eb631f825fff754a0a879f5e411d7c19b356df15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
Runtime library: Cached vs shared files
=======================================
Cached files:
* Are about static content.
* Useful for e.g. things in /usr on *nix.
- But also for configuration or web pages, documents, etc.
if the expiration time is low enough.
* Files are considered (and expected to be) immutable.
* May be cached on subsequent opens.
* May be cached by the runtime, if the process is invoked multiple times.
* May or may not have an underlying file descriptor.
* Might not reload from disk within the expiration time.
* Reads can be "merged" across threads. For example, if there are 200 reqs/s,
and the expiration time is 1 second, then there can be a 200x reduction of
reads at the OS level.
* Not guaranteed to be read in any particular order
(e.g. a read "after" a write might actually happen before the write).
* May be pre-fetched arbitrarily by the runtime.
Buffered files:
* Are about dynamic content.
* Useful for files that are generated in "one shot" by other processes.
* For ordering, the time the file is opened matters. But after that point
in time, the reads may be buffered (and hence be executed at different
points in time than in the source code).
Shared files:
* Are about state.
* Useful for e.g. databases.
* Guaranteed to be read in order.
* No caching.
* No buffering.
* All I/O operations immediately result in a syscall invocation.
Class names to use
------------------
Theme 1: What they are:
CachedFile
BufferedFile
SharedFile
Theme 2: What they do:
CachingReader
BufferingReader
DirectSyscallReader
Theme 3: When they should be used:
StaticReader
DynamicReader
DirectReader
Theme 4: What the are used for:
ContentFile
GeneratedFile
MutableFile
|