diff options
author | Samuel Lidén Borell <samuel@kodafritt.se> | 2025-10-05 23:31:19 +0200 |
---|---|---|
committer | Samuel Lidén Borell <samuel@kodafritt.se> | 2025-10-05 23:31:19 +0200 |
commit | 62a4a12995b9ffcbfd0dc07c6ebcb1f95740f414 (patch) | |
tree | aa9446f11620af0ccfbe87461aed6333f5cb4781 /notes/cached_vs_shared_files.txt | |
parent | 44bc6019af6bf657a77a67b7c1a5fd7aca4007be (diff) | |
download | slul-try2-main.tar.gz slul-try2-main.zip |
Diffstat (limited to 'notes/cached_vs_shared_files.txt')
-rw-r--r-- | notes/cached_vs_shared_files.txt | 64 |
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 |