Skip to content
This repository has been archived by the owner on Mar 9, 2019. It is now read-only.

no need to call Truncate and Sync if size is not changed #407

Closed
wants to merge 1 commit into from

Conversation

funny-falcon
Copy link

#284 mentions that Sync should be called on size change.
But if size is not changed, why Sync is called?
It is an issue for opening file: size is really the same.
Truncate+Sync slows Open very much: if 10 concurrent small files are opening, then speed drops from 20000open/sec to 50open/sec

@@ -45,10 +45,10 @@ func funlock(f *os.File) error {
}

// mmap memory maps a DB's data file.
func mmap(db *DB, sz int) error {
func mmap(db *DB, sz int, changesize bool) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change the variable name to syncRequired? I think it makes more sense within the context of the function.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I just found that I forgot about bolt_windows.go where is no call to Sync.
Sync looks to be helper method, and call to Truncate is the main.
So, I think changeSize is semantically better name.

More: calling to Truncate looks to also take non-zero time.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, I remade it completely: move decision logic to db.mmap

it is an issue for opening file: size is really the same.
and Truncate+Sync slows Open very much: from 20000open/sec to 50open/sec
@funny-falcon
Copy link
Author

looks like it was fixed by e67705ed6348675b7b

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants