… | |
… | |
53 | BEGIN { |
53 | BEGIN { |
54 | $VERSION = 0.2; |
54 | $VERSION = 0.2; |
55 | |
55 | |
56 | @EXPORT = qw(aio_read aio_write aio_open aio_close aio_stat aio_lstat aio_unlink |
56 | @EXPORT = qw(aio_read aio_write aio_open aio_close aio_stat aio_lstat aio_unlink |
57 | aio_fsync aio_fdatasync aio_readahead); |
57 | aio_fsync aio_fdatasync aio_readahead); |
58 | @EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel nreqs); |
58 | @EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel max_outstanding nreqs); |
59 | |
59 | |
60 | require XSLoader; |
60 | require XSLoader; |
61 | XSLoader::load IO::AIO, $VERSION; |
61 | XSLoader::load IO::AIO, $VERSION; |
62 | } |
62 | } |
63 | |
63 | |
… | |
… | |
65 | |
65 | |
66 | Set the minimum number of AIO threads to C<$nthreads>. The default is |
66 | Set the minimum number of AIO threads to C<$nthreads>. The default is |
67 | C<1>, which means a single asynchronous operation can be done at one time |
67 | C<1>, which means a single asynchronous operation can be done at one time |
68 | (the number of outstanding operations, however, is unlimited). |
68 | (the number of outstanding operations, however, is unlimited). |
69 | |
69 | |
70 | It is recommended to keep the number of threads low, as some linux |
70 | It is recommended to keep the number of threads low, as some Linux |
71 | kernel versions will scale negatively with the number of threads (higher |
71 | kernel versions will scale negatively with the number of threads (higher |
72 | parallelity => MUCH higher latency). |
72 | parallelity => MUCH higher latency). With current Linux 2.6 versions, 4-32 |
|
|
73 | threads should be fine. |
73 | |
74 | |
74 | Under normal circumstances you don't need to call this function, as this |
75 | Under normal circumstances you don't need to call this function, as this |
75 | module automatically starts a single async thread. |
76 | module automatically starts some threads (the exact number might change, |
|
|
77 | and is currently 4). |
76 | |
78 | |
77 | =item IO::AIO::max_parallel $nthreads |
79 | =item IO::AIO::max_parallel $nthreads |
78 | |
80 | |
79 | Sets the maximum number of AIO threads to C<$nthreads>. If more than |
81 | Sets the maximum number of AIO threads to C<$nthreads>. If more than |
80 | the specified number of threads are currently running, kill them. This |
82 | the specified number of threads are currently running, kill them. This |
81 | function blocks until the limit is reached. |
83 | function blocks until the limit is reached. |
82 | |
84 | |
83 | This module automatically runs C<max_parallel 0> at program end, to ensure |
85 | This module automatically runs C<max_parallel 0> at program end, to ensure |
84 | that all threads are killed and that there are no outstanding requests. |
86 | that all threads are killed and that there are no outstanding requests. |
|
|
87 | |
|
|
88 | Under normal circumstances you don't need to call this function. |
|
|
89 | |
|
|
90 | =item $oldnreqs = IO::AIO::max_outstanding $nreqs |
|
|
91 | |
|
|
92 | Sets the maximum number of outstanding requests to C<$nreqs>. If you |
|
|
93 | try to queue up more than this number of requests, the caller will block until |
|
|
94 | some requests have been handled. |
|
|
95 | |
|
|
96 | The default is very large, so normally there is no practical limit. If you |
|
|
97 | queue up many requests in a loop it it often improves speed if you set |
|
|
98 | this to a relatively low number, such as C<100>. |
85 | |
99 | |
86 | Under normal circumstances you don't need to call this function. |
100 | Under normal circumstances you don't need to call this function. |
87 | |
101 | |
88 | =item $fileno = IO::AIO::poll_fileno |
102 | =item $fileno = IO::AIO::poll_fileno |
89 | |
103 | |