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

Don't fsync every file when installing gems #556

Merged
merged 1 commit into from
Jun 26, 2013

Conversation

grk
Copy link
Contributor

@grk grk commented May 13, 2013

d84090b introduced "similar sync behavior from old tar code". It looks like the old code was fsyncing directories, but the commit was fsyncing every single file.

This fixes a severe performance degradation in our virtualized environment. Gem install takes ~40 seconds on rubygems 2.0 compared to ~1 second on rubygems 1.8.

I looked through the last version that didn't have those performance issues - 1.8.25 - and the Gem::Package::FSyncDir module is dead code there.

I don't know rubygems well enough to say if its absolutely safe to remove this code, but from my limited testing it seems that it is. I installed a few gems with checking if any TarReader::Entry is a directory, and none of them is.

d84090b introduced "similar sync behavior from old tar code". It looks
like the old code was fsyncing directories, but the commit was fsyncing
every single file.
drbrain added a commit that referenced this pull request Jun 26, 2013
Don't fsync every file when installing gems
@drbrain drbrain merged commit d82732d into rubygems:master Jun 26, 2013
drbrain added a commit that referenced this pull request Jun 26, 2013
This assumes writes by the filesystem will be ordered which may not be a
safe, but does ensure at least the spec is written to disk before
returning from installation.
@drbrain
Copy link
Member

drbrain commented Jun 26, 2013

In @801ba9e I moved the fsync() to a single file, the gem's specification. As noted this assumes that writes are ordered and that the fsync() for the specification will force all the files installed by the gem to also be synced to disk which may be unsafe, but I would like to make a reasonable effort to commit the gem to permanent storage in case of a crash.

Let me know if this removes the performance benefit of your commit and we can reopen.

@grk
Copy link
Contributor Author

grk commented Jun 26, 2013

Thanks! I'll run a few tests to see if we see the same performance gain with fsyncing the gemspecs.

drbrain added a commit that referenced this pull request Jun 27, 2013
This assumes writes by the filesystem will be ordered which may not be a
safe, but does ensure at least the spec is written to disk before
returning from installation.
@grk
Copy link
Contributor Author

grk commented Aug 13, 2013

@drbrain Whoops, sorry for the late reply, completely forgot about it. Everything is fast now, even with added fsync for specifications. Thanks again!

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

Successfully merging this pull request may close these issues.

None yet

3 participants