Curious about corner case in btrfs code
From: Greg Freemyer <hidden>
Date: 2014-08-27 01:49:51
On August 26, 2014 8:13:10 PM EDT, Nick [off-list ref] wrote:
On 08/26/2014 08:05 PM, Tobias Boege wrote:quoted
On Tue, 26 Aug 2014, Nick wrote:quoted
On 08/26/2014 06:58 PM, Mandeep Sandhu wrote:quoted
If it's a corner case, it won't be hit often enough right? And ifitquoted
quoted
quoted
was hit often enough, it wouldn't be corner case!? :) These 2 are mutually exclusive! On Tue, Aug 26, 2014 at 3:47 PM, Nick [off-list ref] wrote:quoted
After reading through the code in inode.c today , I am curiousabout the comment and the following code I will pastequoted
quoted
quoted
quoted
below. I am curious if this corner case is hit often enough for meto write a patch to improve the speed of thisquoted
quoted
quoted
quoted
corner case. Furthermore , compress_file_range is the functionname, in case you can't guess by the pasted code.quoted
quoted
quoted
quoted
Regards Nick 411 /* 412 * we don't want to send crud past the end of i_sizethroughquoted
quoted
quoted
quoted
413 * compression, that's just a waste of CPU time. So, ifthequoted
quoted
quoted
quoted
414 * end of the file is before the start of our current 415 * requested range of bytes, we bail out to theuncompressedquoted
quoted
quoted
quoted
416 * cleanup code that can deal with all of this. 417 * 418 * It isn't really the fastest way to fix things, but thisis aquoted
quoted
quoted
quoted
419 * very uncommon corner. 420 */ 421 if (actual_end <= start) 422 goto cleanup_and_bail_uncompressed; _______________________________________________ Kernelnewbies mailing list Kernelnewbies at kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbiesI get that my question is if this corner case is hit, enough for meto write a patch to optimize it.quoted
quoted
In addition the comment states it isn't but want to known forstandard compression workloads in btrfsquoted
quoted
if it's hit enough for me to work on this and how much speeddegradation are me we doing my not writingquoted
quoted
it better. NickHere's how I would go about it: 1. Understand when the case is met (in theory). 2. Try to trigger it on a real system multiple times. 3. Try to explore systematically under what circumstances the caseis metquoted
and rank them by plausibility (if the notion of plausibilitymakes anyquoted
sense in a real world scenario -- I don't know). 4. Estimate cost vs. benefit. I don't know if this is a good way but notice how you can do all thisonquoted
yourself which I think is a plus for everyone. And if you decide instep 4quoted
to write a patch: 5. Use your results from step 3 to create an environment thatbenefitsquoted
from your patch (notice how 4 guarantees that there exists such a system with reasonable connection to real needs). Note thenumbers.quoted
6. Test your patch on as many regular configurations as possible.Notequoted
the numbers. If it degrades performance on any of those, abort. 7. Do *NOT* send the patch out. Regards, TobiThanks Tobi,quoted
From reading the code off the bat, seems to not need to be written asthis case is rarely meet for large files or files that are huge and take a lot of time to write. Was more curious about how to test things like this if I need to :). Nick
If you want to do anything more than code beautification for btrfs, you absolutely have to learn how to write xfstest scripts. Dispute the name, the Linux kernel now uses xfstests to exercise all kernel file systems. I don't follow btrfs, but xfs as an obvious example is pretty strict about only accepting meaningful patches if they are accompanied by a user space xfstest tool to exercise it. Surprisingly that seems to be less true of new functionality. Bug fix patches have an almost mandatory request for an accompanying xfstest. The other side of that is if you read thru the kernel bugzilla and find a filesystem bug you want to fix, a good first step is to focus on writing a xfstest script that will show the bug and fail appropriately. A decade plus ago when I first got interested in using xfs for a production system, the freeze feature would randomly fail for me. I was able to update the xfstest that exercised that code and get a reproducer. I didn't do the actual kernel fix, but I still think of that as my first significant contribution to the kernel. Greg -- Sent from my Android phone with K-9 Mail. Please excuse my brevity.