Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to use posix_fadvise with CBufferedFile #14485

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
7 participants
@luke-jr
Copy link
Member

commented Oct 15, 2018

Resurrecting #12491, since it seemed fine and desirable...

@meshcollider

This comment has been minimized.

Copy link
Member

commented Oct 15, 2018

Concept ACK, would be good to hear from @eklitzke why the original was closed though

src/util.h Outdated
//! Close a file and return the result of fclose(). On POSIX systems that
//! support it, advise the kernel to remove the file contents from the page
//! cache (which can help on memory-constrained systems).
int CloseAndDiscard(FILE *file);

This comment has been minimized.

Copy link
@laanwj

laanwj Oct 18, 2018

Member

"discard" sounds to me as if writes to the file will be discarded, too
maybe CloseAndUncache?

@laanwj

This comment has been minimized.

Copy link
Member

commented Oct 18, 2018

Concept ACK though I'd really like to see benchmarks for changes like this, to know if this has any impact in practice worth making the risk/complication of the change.

@jgarzik

This comment has been minimized.

Copy link
Contributor

commented Oct 18, 2018

Probably worthing having -- rough concept ACK -- however:

  • The double-lseek will be slower than fstat() on some networked or detachable filesystems.

  • If close-and-uncache is used on just-written-to files, this action is a no-op unless a sync (fdatasync etc.) preceded it.

  • Definitely worth benchmarking on multiple filesystems to see the positive or negative value of this change.

@luke-jr

This comment has been minimized.

Copy link
Member Author

commented Feb 11, 2019

Rebased and addressed @laanwj's function rename request.

@DrahtBot DrahtBot removed the Needs rebase label Feb 11, 2019

posix_fadvise(fd, 0, end, POSIX_FADV_DONTNEED);
}
#endif
close:

This comment has been minimized.

Copy link
@practicalswift

practicalswift Feb 13, 2019

Member

Move close: inside #if … #endif?

@DrahtBot

This comment has been minimized.

Copy link
Contributor

commented Mar 23, 2019

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #15650 (Handle the result of posix_fallocate system call by lucayepa)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

Try to use posix_fadvise with CBufferedFile
This primarily affects blocks when bitcoin is launched with -reindex, as
that causes the block files to be loaded as CBufferedFile objects one at
a time as the reindex progresses.

@luke-jr luke-jr force-pushed the luke-jr:fadvise branch from f2041fe to b78cb82 Apr 13, 2019

@DrahtBot

This comment has been minimized.

Copy link
Contributor

commented May 2, 2019

Needs rebase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.