capability races (was: Re: Seeing ENOTCAPABLE from write FDs in kqueue?)
Mateusz Guzik
mjguzik at gmail.com
Wed Jun 18 20:33:21 UTC 2014
On Mon, Jun 09, 2014 at 01:00:59AM +0200, Mateusz Guzik wrote:
> So, benchmarks:
>
> http://people.freebsd.org/~mjg/patches/caps-race/dup2-bench.c
>
> 1 thread does dup2 in a loop
> 7 threads fget() the same fd and fail quickly
>
[..]
> Difference at 95.0% confidence
> 1.96987e+06 +/- 46328.7
> 16.3174% +/- 0.383763%
> (Student's t, pooled s = 167139)
>
> It would be good if someone with some time and access to higher-cpu-count
> machine could test it better.
>
pjd suggested on irc allowing a pass with inconsistent filedescent
struct and check it before we fail and before fp is accepted.
I also went ahead and modified seq_* function a little to make them easier to
use.
This is with inconsistent struct allowed:
http://people.freebsd.org/~mjg/patches/caps-race/caps-race-seq.diff
And this spins to get the right one:
http://people.freebsd.org/~mjg/patches/caps-race/caps-race-seqearly.diff
Patches differ only in fget_unlocked function.
Performnance is unfortunately still bad and an approach with
inconsistent struct is the slowest. Results are reproducible well enough.
Comments? Maybe we should try to pack this into one atomically replaced
structure after all, but I don't have time to work on that.
I checked with 2 benchmarks:
1 thread dup2 + 7 read:
x pure-kernel-dup2-bench
+ seq-dup2-bench
* seqearly-dup2-bench
+-------------------------------------------------------------------------------------------------------------------------------------+
| + * |
| + * |
| + * |
| + * x |
| + * x |
| ++ * x |
| ++ * * x x |
| +++ * * x x |
| +++ * * ** * x xxx |
| ++++ + ***** ** * x x xxxx xx |
| + ++++++ + + ***** * **** xx xx xxxx xx |
| ++++++++ +++ +****** * **** * xxxxxx xxxxxxx |
| ++++++++ ++++++******* ** **** * x xxxxxx xxxxxxxx |
| +++++++++ ++++++********* ******** * xx xxxxxxxxxxxxxxxx |
|++ ++++++++++++++**+********** *********** x x x x xxx xxxxxxxxxxxxxxxxx x|
| |___MA____| |____M_A_____| |_______A_M_____| |
+-------------------------------------------------------------------------------------------------------------------------------------+
N Min Max Median Avg Stddev
x 100 13065813 14435053 14157439 14103416 196933.44
+ 100 11071952 11615178 11351083 11374348 121160.27
Difference at 95.0% confidence
-2.72907e+06 +/- 45319.1
-19.3504% +/- 0.321334%
(Student's t, pooled s = 163497)
* 100 11517495 12111074 11774410 11828854 159139.54
Difference at 95.0% confidence
-2.27456e+06 +/- 49626.4
-16.1277% +/- 0.351875%
(Student's t, pooled s = 179037)
8 threads read:
x pure-kernel-read-pipe-bench
+ seq-read-pipe-bench
* seqearly-read-pipe-bench
+-------------------------------------------------------------------------------------------------------------------------------------+
| * |
| * |
| + * x |
| + * x |
| + ++ * xx |
| + ++ + * x xx |
| + ++++ + * * xx xx |
| + ++++ + + * **** * xx xxx |
| + ++++ +++ * **** * xxxxxxx |
| ++++++ ++++ * **** *** xxxxxxx |
| ++++++ ++++ * ****** * *** x x xxxxxxx |
|+ ++++++++++++ * * ******* ** ***** x xx xxxxxxxxxxx |
|++++++++++++++++ + ** * ******* ** * * ***** * x xx x xxxxxxxxxxxxxxxx|
|++++++++++++++++ + ++ + ** ************ * *** ****** * xxxx xxxx xxxxxxxxxxxxxxxxxx|
| |___MA_____| |____M__A_______| |_____A_M___| |
+-------------------------------------------------------------------------------------------------------------------------------------+
N Min Max Median Avg Stddev
x 100 20721201 21597446 21369536 21306748 206438.73
+ 100 17272059 18247946 17509832 17547079 178174.14
Difference at 95.0% confidence
-3.75967e+06 +/- 53448.4
-17.6454% +/- 0.250852%
(Student's t, pooled s = 192825)
* 100 18417084 19360802 18739503 18836380 269109.08
Difference at 95.0% confidence
-2.47037e+06 +/- 66477.4
-11.5943% +/- 0.312002%
(Student's t, pooled s = 239830)
--
Mateusz Guzik <mjguzik gmail.com>
More information about the freebsd-arch
mailing list