{"action":"opened","issue":{"url":"https://api.github.com/repos/cojen/Tupl/issues/45","labels_url":"https://api.github.com/repos/cojen/Tupl/issues/45/labels{/name}","comments_url":"https://api.github.com/repos/cojen/Tupl/issues/45/comments","events_url":"https://api.github.com/repos/cojen/Tupl/issues/45/events","html_url":"https://github.com/cojen/Tupl/issues/45","id":107429069,"number":45,"title":"Support fully direct mode","user":{"login":"broneill","id":2822640,"avatar_url":"https://avatars.githubusercontent.com/u/2822640?v=3","gravatar_id":"","url":"https://api.github.com/users/broneill","html_url":"https://github.com/broneill","followers_url":"https://api.github.com/users/broneill/followers","following_url":"https://api.github.com/users/broneill/following{/other_user}","gists_url":"https://api.github.com/users/broneill/gists{/gist_id}","starred_url":"https://api.github.com/users/broneill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broneill/subscriptions","organizations_url":"https://api.github.com/users/broneill/orgs","repos_url":"https://api.github.com/users/broneill/repos","events_url":"https://api.github.com/users/broneill/events{/privacy}","received_events_url":"https://api.github.com/users/broneill/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cojen/Tupl/labels/performance","name":"performance","color":"02e10c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-21T01:21:16Z","updated_at":"2015-09-21T01:21:16Z","closed_at":null,"body":"A fully direct mode doesn't have an explicit cache, but it does still have Node instances. Instead of pointing to pages of memory allocated by the process, they point to a mapped file. The mapping is actually to a block device, avoiding remapping problems when the file grows. The operating system is free to cache the mapping itself.\r\n\r\nIn this mode, node read and write operations don't really do anything. When a node is dirtied, the original contents are copied to the new page. This is a true copy-on-write mode.\r\n\r\n1. Must be using direct access mode.\r\n2. No cache is allocated, other than the Node instances themselves.\r\n3. All Node page pointers are initialized to null.\r\n4. File mapping is performed using JNA, to map a 64-bit size.\r\n5. Node.read sets the page pointer to `id * pageSize + fileStartPointer`\r\n6. Node dirtying copies memory from old page to new page.\r\n7. Node.write only calls prepareWrite, which only verifies that the page isn't split.\r\n8. Node.doEvict calls prepareWrite and sets the page pointer to null.\r\n9. Node compaction performs double copy instead of pointer swap.\r\n\r\nThis mode cannot be used when encryption is enabled. Cached pages are required to hold decrypted content.\r\n"}}