diff options
author | EuAndreh <eu@euandre.org> | 2024-12-31 06:28:15 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-12-31 06:28:15 -0300 |
commit | adf70c80b292bbf73aaf49725464a50ef2c2facc (patch) | |
tree | 2a414daf395aca1f8d24996bf7564435e70f949f | |
parent | src/dedo.go: remove unused constants and methods (diff) | |
download | dedo-adf70c80b292bbf73aaf49725464a50ef2c2facc.tar.gz dedo-adf70c80b292bbf73aaf49725464a50ef2c2facc.tar.xz |
src/dedo.go: Remove Tx.WriteFlag option
Thrashing is an OS issue, not an application one. The OS should be the one
tweaking the page cache to prevent it. If the OS is not doing it by itself, one
needs to tweak their system's page cache size and configuration.
-rw-r--r-- | src/dedo.go | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/dedo.go b/src/dedo.go index c4a5532..ead56b8 100644 --- a/src/dedo.go +++ b/src/dedo.go @@ -291,14 +291,6 @@ type Tx struct { pages map[pgid]*page stats TxStats commitHandlers []func() - - // WriteFlag specifies the flag for write-related methods like WriteTo(). - // Tx opens the database file with the specified flag to copy the data. - // - // By default, the flag is unset, which works well for mostly in-memory - // workloads. For databases that are much larger than available RAM, - // set the flag to syscall.O_DIRECT to avoid trashing the page cache. - WriteFlag int } // TxStats represents statistics about the actions performed by the transaction. @@ -3766,12 +3758,11 @@ func (tx *Tx) Copy(w io.Writer) error { // WriteTo writes the entire database to a writer. // If err == nil then exactly tx.Size() bytes will be written into the writer. func (tx *Tx) WriteTo(w io.Writer) (n int64, err error) { - // Attempt to open reader with WriteFlag - f, err := os.OpenFile(tx.db.path, os.O_RDONLY|tx.WriteFlag, 0) + f, err := os.OpenFile(tx.db.path, os.O_RDONLY, 0) if err != nil { return 0, err } - defer func() { _ = f.Close() }() + defer f.Close() // Generate a meta page. We use the same page data for both meta pages. buf := make([]byte, tx.db.pageSize) |