aboutsummaryrefslogtreecommitdiff
path: root/notes/cached_vs_shared_files.txt
diff options
context:
space:
mode:
Diffstat (limited to 'notes/cached_vs_shared_files.txt')
-rw-r--r--notes/cached_vs_shared_files.txt64
1 files changed, 64 insertions, 0 deletions
diff --git a/notes/cached_vs_shared_files.txt b/notes/cached_vs_shared_files.txt
new file mode 100644
index 0000000..eb631f8
--- /dev/null
+++ b/notes/cached_vs_shared_files.txt
@@ -0,0 +1,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