-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Record tx_assign_histogram correctly #1915
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
Conversation
spa_tx_assign_add_nsecs was added in 2d37239 to record the amount of time taken to assign a transaction to TXG. Unfortunately, this only kicks in for dmu_tx_try_assign with TXG_WAIT, and it misses all the interesting and important cases (such as zfs_write and all ther other ZPL functions) where dmu_tx_assign is called with TXG_NOWAIT, and ERESTART results in a new transaction created. This change introduces a new function dmu_tx_assign_add_nsecs, and make these TXG_NOWAIT callers call this function appropriately. This allows more accurate insights into the time spent on assigning TXG. Signed-off-by: Kohsuke Kawaguchi <kk@kohsuke.org>
|
I'm not sure it's useful to record assign times for TXG_NOWAIT transactions. Either they're assigned immediately or they are aborted. The idea of the histogram is to track delay times for transactions that are forced to wait. Also, #1696 includes 57b270f which converts most of the ZPL functions to use TXG_WAIT. |
|
My point is that these "if fail, abort, wait, and retry" cycle does effectively constitute "delay times for transactions that are forced to wait." since all it's doing is to wait for an available TXG to join. The context of this is that I was looking into my "dd if=/dev/zero of=/file/on/zfs" performance, which eventually led me to TXG size problem (see #1913.) During this investigation, It's good to hear that #1696 addresses (some of?) this issue. The same pull request was mentioned in #1913 as well, so it's clearly a very important change for me. Do you have any guesstimate of when it's going to go in? |
|
Yes I see the usefulness of this now. #1696 will fix I wonder if we should just move the |
|
@kohsuke @nedbass After the write throttle code is merged (soon I hope) it may make sense to move this to |
|
The write throttle code changes the remaining so they call it at most once with TXG_NOWAIT and with TXG_WAITED after that. With TXG_WAITED it will not wait again for the dirty data limit, so I think this already gives most of the performance benefit of TXG_WAIT, and still calls dmu_tx_wait() only once except in some unusual cases. |
|
@nedbass Can you take a quick look at this. Is there still remaining cleanup to be done here to make these stats useful again? |
|
I think it still makes sense to move the |
|
@nedbass That would be great, thanks. |
Some callers of dmu_tx_assign() use the TXG_NOWAIT flag and call dmu_tx_wait() themselves before retrying if the assignment fails. The wait times for such callers are not accounted for in the dmu_tx_assign kstat histogram, because the histogram only records time spent in dmu_tx_assign(). This change moves the histogram update to dmu_tx_wait() to properly account for all time spent there. One downside of this approach is that it is possible to call dmu_tx_wait() multiple times before successfully assigning a transaction, in which case the cumulative wait time would not be recorded. However, this case should not often arise in practice, because most callers currently use one of these forms: dmu_tx_assign(tx, TXG_WAIT); dmu_tx_assign(tx, waited ? TXG_WAITED : TXG_NOWAIT); The first form should make just one call to dmu_tx_delay() inside of dmu_tx_assign(). The second form retries with TXG_WAITED if the first assignment fails and incurs a delay, in which case no further waiting is performed. Therefore transaction delays normally occur in one call to dmu_tx_wait() so the histogram should be fairly accurate. Another possible downside of this approach is that the histogram will no longer record overhead outside of dmu_tx_wait() such as in dmu_tx_try_assign(). While I'm not aware of any reason for concern on this point, it is conceivable that lock contention, long list traversal, etc. could cause assignment delays that would not be reflected in the histogram. Therefore the histogram should strictly be used for visibility in to the normal delay mechanisms and not as a profiling tool for code performance. Signed-off-by: Ned Bass <bass6@llnl.gov> Closes openzfs#1915
spa_tx_assign_add_nsecswas added in 2d37239 to record the amount of time taken to assign a transaction to TXG.Unfortunately, this only kicks in for
dmu_tx_try_assignwithTXG_WAIT, and it misses all the interesting and important cases (such aszfs_writeand all ther other ZPL functions) wheredmu_tx_assignis called withTXG_NOWAIT, andERESTARTresults in a new transaction created.This change introduces a new function
dmu_tx_assign_add_nsecs, and make theseTXG_NOWAITcallers call this function appropriately. This allows more accurate insights into the time spent on assigning TXG.