IO-AIO

 view release on metacpan or  search on metacpan

AIO.pm  view on Meta::CPAN

                       nreqs nready npending nthreads
                       max_poll_time max_poll_reqs
                       sendfile fadvise madvise
                       mmap munmap mremap munlock munlockall

                       accept4 tee splice pipe2 pipesize
                       fexecve mount umount memfd_create eventfd
                       timerfd_create timerfd_settime timerfd_gettime
                       pidfd_open pidfd_send_signal pidfd_getfd);

   push @AIO_REQ, qw(aio_busy); # not exported

   @IO::AIO::GRP::ISA = 'IO::AIO::REQ';

   require XSLoader;
   XSLoader::load ("IO::AIO", $VERSION);
}

=head1 FUNCTIONS

=head2 QUICK OVERVIEW

AIO.pm  view on Meta::CPAN

side effects, such as when you want to add a dummy request to a group so
that finishing the requests in the group depends on executing the given
code.

While this request does nothing, it still goes through the execution
phase and still requires a worker thread. Thus, the callback will not
be executed immediately but only after other requests in the queue have
entered their execution phase. This can be used to measure request
latency.

=item IO::AIO::aio_busy $fractional_seconds, $callback->()  *NOT EXPORTED*

Mainly used for debugging and benchmarking, this aio request puts one of
the request workers to sleep for the given time.

While it is theoretically handy to have simple I/O scheduling requests
like sleep and file handle readable/writable, the overhead this creates is
immense (it blocks a thread for a long time) so do not use this function
except to put your application under artificial I/O pressure.

=back

AIO.xs  view on Meta::CPAN

            {
              SvREADONLY_on (data);
              req->flags |= FLAG_SV2_RO_OFF;
            }

          REQ_SEND;
        }
}

void
aio_busy (double delay, SV *callback = &PL_sv_undef)
	PPCODE:
{
	dREQ;

        req->type = EIO_BUSY;
        req->nv1  = delay < 0. ? 0. : delay;

	REQ_SEND;
}

Changes  view on Meta::CPAN

	- more perl 5.10 workarounds for aio_read and write.
        - aio_write no longer modifies the sv (if possible).
        - aio_read now works correctly with magic values.

3.18 Sun Apr 19 21:17:32 CEST 2009
	- better diagnostics when some aio_* functions get passed an illegal fh.
        - try to avoid crashes due to incompatible 5.10 API changes. grmbl.

3.17 Thu Nov 20 08:45:36 CET 2008
	- (libeio) added aio_sync_file_range (untested).
        - add aio_busy to @IO::AIO::AIO_REQ.

3.16 Wed Oct 22 18:28:01 CEST 2008
	- use SvREFCNT_inc instead of SvREFCNT_inc_NN in a non-speed critical
          part to improve portability to perl 5.8 (reported by szymon).

3.15 Mon Oct 13 00:39:55 CEST 2008
	- automatic removal of feeders was broken.
	- (libeio) use a more robust method to detect whether a feeder
          has added something to the group or not.

Changes  view on Meta::CPAN

	- (libeio) do not use readdir_r, as Ulrich Drepper pointed out that this
          is stupid.
        - (libeio) fix eio__readahead prototype, patch by Jost Krieger.
        - (libeio) fix a bug that could potentially cause IO::AIO
          not to get initialised properly.

3.03 Thu May 29 05:33:30 CEST 2008
	- (libeio) correctly call pthread_attr_destroy ().
        - (libeio) work around broken bsd headers once more.
        - reduce shared library size again by not including wrappers.
        - max_outstanding could cause poll to enter a busy-waiting loop.
        - document the new IO::AIO::poll_cb result value.

3.02 Mon May 12 02:32:02 CEST 2008
	- fix a memory leak on aio_readlink.
        - bring back working fchmod.
        - nop and busy now set result to 0.
        - set errno to ENOMEM when allocation fails.

3.01 Sun May 11 03:07:03 CEST 2008
	- (libeio) make it compile on systems without readahead or readdir_r.
        - (libeio) improve configure check for readahead availability.
        - do not try to link against -lrt.
	- use a separate configure script for IO::AIO (not the libeio one).

3.0  Sun May 11 00:57:14 CEST 2008
	- added bin/treescan to the distribution.

Changes  view on Meta::CPAN

2.4  Sun Aug  5 18:44:22 CEST 2007
        - add aio_truncate, aio_chmod, aio_chown, aio_utime (linux
          successfully demonstrated that you can block on futimes...).
        - allow undef as fileoffset for aio_read/write and use read/write(2)
          internally (useful for sockets or O_APPEND handles).
        - allow undef for length in aio_write.
        - negative dataoffsets work as expected now in aio_read/aio_write.
        - use NV instead of UV for 32 bit perls and file offsets, as NVs
          have a larger range then.
	- shared code between BDB and IO::AIO.
        - aio_busy was completely broken. now fixed.
        - readahead emulation now returns something.
        - correctly set errno to ENOSYS on unimplemented functions
          (should never happen, though).
        - large changes to make it partially compile and run on win32,
          but win32 lacks too much functionality, and perl overrides way
          too many functions with crashing versions.

2.33 Tue Jan 23 23:55:41 CET 2007
	- fix install path (Andreas J. Koenig).

Changes  view on Meta::CPAN

        - aio requests can be cancelled.
        - callbacks can be (re-)set later.
        - aio requests can choose between 9 priorities.
        - add aio_group: aio requests can be grouped
          into composite requests.
        - generator interface for groups.
        - add IO::AIO::poll_some.
        - major documentation improvements.
        - very minor bugfixes.
        - add aio_nop for dummy requests.
        - add aio_busy mainly for benchmarking and debugging.
        - use "fast" mutexes on linux.
        - use dynamic (and larger) buffers instead of
          putting them onto the stack.
        - optimise x86 and amd64 a bit.
        - better error checking when ENOMEM.
        - hopefully fix mem and dirp leaks on fork.
        - warn about broken perl malloc.
        - compiles on cygwin (but pread is broken on cygwin
          which is not detected by autoconf, so you have to
          edit autoconf/config.h yourself to enable emulation).

Changes  view on Meta::CPAN

        - abort when the configure script fails.

1.4  Wed Aug 17 08:07:27 CEST 2005
	- forgot to recreate the pipe after forking, this could cause
          deadlocks.

1.3  Wed Aug 17 07:25:54 CEST 2005
	- properly propagate exceptions from callbacks, instead of silently
          eating them.
        - use a different fork algorithm that avoids recursive callback
          invocations and reduces fork latency in busy processes.
        - fix a bug where the buffer scalar in aio_read got assigned the wrong
          length after reading.
        - fix a bug where the child would process some outstanding requests
          from the parent.
        - make a copy of the callback scalar, to avoid some very uncommon
          (but valid) usages where the callback scalar changes.
        - the callback was never freed in aio_read/aio_write.
        - aio_read/aio_write will now set the readonly flag on the data
          scalar for better error reporting.

README  view on Meta::CPAN

        used for side effects, such as when you want to add a dummy request
        to a group so that finishing the requests in the group depends on
        executing the given code.

        While this request does nothing, it still goes through the execution
        phase and still requires a worker thread. Thus, the callback will
        not be executed immediately but only after other requests in the
        queue have entered their execution phase. This can be used to
        measure request latency.

    IO::AIO::aio_busy $fractional_seconds, $callback->() *NOT EXPORTED*
        Mainly used for debugging and benchmarking, this aio request puts
        one of the request workers to sleep for the given time.

        While it is theoretically handy to have simple I/O scheduling
        requests like sleep and file handle readable/writable, the overhead
        this creates is immense (it blocks a thread for a long time) so do
        not use this function except to put your application under
        artificial I/O pressure.

  IO::AIO::WD - multiple working directories

libeio/eio.c  view on Meta::CPAN

eio_req *eio_wd_close (eio_wd wd, int pri, eio_cb cb, void *data)
{
  REQ (EIO_WD_CLOSE); req->wd = wd; SEND;
}

eio_req *eio_nop (int pri, eio_cb cb, void *data)
{
  REQ (EIO_NOP); SEND;
}

eio_req *eio_busy (double delay, int pri, eio_cb cb, void *data)
{
  REQ (EIO_BUSY); req->nv1 = delay; SEND;
}

eio_req *eio_sync (int pri, eio_cb cb, void *data)
{
  REQ (EIO_SYNC); SEND;
}

eio_req *eio_fsync (int fd, int pri, eio_cb cb, void *data)

libeio/eio.h  view on Meta::CPAN

{
  eio_req volatile *next; /* private ETP */

  eio_wd wd;       /* all applicable requests: working directory of pathname, old name; wd_open: return wd */

  eio_ssize_t result;  /* result of syscall, e.g. result = read (... */
  off_t offs;      /* read, write, truncate, readahead, sync_file_range, fallocate, slurp: file offset, mknod: dev_t */
  size_t size;     /* read, write, readahead, sendfile, msync, mlock, sync_file_range, fallocate, slurp: length */
  void *ptr1;      /* all applicable requests: pathname, old name, readdir: optional eio_dirents */
  void *ptr2;      /* all applicable requests: new name or memory buffer; readdir: name strings */
  eio_tstamp nv1;  /* utime, futime: atime; busy: sleep time */
  eio_tstamp nv2;  /* utime, futime: mtime */

  int int1;        /* all applicable requests: file descriptor; sendfile: output fd; open, msync, mlockall, readdir: flags */
  long int2;       /* chown, fchown: uid; sendfile: input fd; open, chmod, mkdir, mknod: file mode, seek: whence, fcntl, ioctl: request, sync_file_range, fallocate, rename: flags */
  long int3;       /* chown, fchown: gid; rename, link: working directory of new name */
  int errorno;     /* errno value on syscall return */

  unsigned char flags; /* private */

  signed char type;/* EIO_xxx constant ETP */

libeio/eio.h  view on Meta::CPAN

unsigned int eio_nthreads (void); /* number of worker threads in use currently */

/*****************************************************************************/
/* convenience wrappers */
/* these do not expose advanced syscalls and directory fds */

#ifndef EIO_NO_WRAPPERS
eio_req *eio_wd_open   (const char *path, int pri, eio_cb cb, void *data); /* result=wd */
eio_req *eio_wd_close  (eio_wd wd, int pri, eio_cb cb, void *data);
eio_req *eio_nop       (int pri, eio_cb cb, void *data); /* does nothing except go through the whole process */
eio_req *eio_busy      (eio_tstamp delay, int pri, eio_cb cb, void *data); /* ties a thread for this long, simulating busyness */
eio_req *eio_sync      (int pri, eio_cb cb, void *data);
eio_req *eio_fsync     (int fd, int pri, eio_cb cb, void *data);
eio_req *eio_fdatasync (int fd, int pri, eio_cb cb, void *data);
eio_req *eio_syncfs    (int fd, int pri, eio_cb cb, void *data);
eio_req *eio_msync     (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data);
eio_req *eio_mtouch    (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data);
eio_req *eio_mlock     (void *addr, size_t length, int pri, eio_cb cb, void *data);
eio_req *eio_mlockall  (int flags, int pri, eio_cb cb, void *data);
eio_req *eio_sync_file_range (int fd, off_t offset, size_t nbytes, unsigned int flags, int pri, eio_cb cb, void *data);
eio_req *eio_fallocate (int fd, int mode, off_t offset, size_t len, int pri, eio_cb cb, void *data);

t/04_fork.t  view on Meta::CPAN

# this is a lame test, but....

BEGIN { plan tests => 10 }

IO::AIO::min_parallel 2;

IO::AIO::aio_nop sub {
   print "ok 6\n";
};

IO::AIO::aio_busy 1, sub {
   print "ok 8\n";

};

print "ok 1\n";

if (open FH, "-|") {
   print while <FH>;
   aio_stat "/", sub {
      print "ok 7\n";

t/06_group.t  view on Meta::CPAN

IO::AIO::poll while IO::AIO::nreqs;

aio_group sub {
   print "ok 8\n";
};

print "ok 7\n";

IO::AIO::poll while IO::AIO::nreqs;

IO::AIO::aio_busy 0, sub { print "ok 9\n" };

IO::AIO::poll while IO::AIO::nreqs;

print "ok 10\n";

aio_nop sub {
   print "ok 11\n";
};

IO::AIO::poll while IO::AIO::nreqs;

t/07_feeder.t  view on Meta::CPAN

my $cn2 = 0;
my $cn3 = 0;

print "ok 1\n";

limit $grp 5;
$grp->feed (sub {
   return if $cn2 >= 10;
   $cn2++;
   aioreq_pri $cn2;
   (add $grp IO::AIO::aio_busy 0)->cb (sub {
      $cn3++;
   });
});

print $cn2 == 5 ? "" : "not ", "ok 2 # $cn2 == 5\n";
print $cn3 == 0 ? "" : "not ", "ok 3 # $cn3 == 0\n";

IO::AIO::poll while IO::AIO::nreqs;

print $cn2 == 10 ? "" : "not ", "ok 5 # $cn2 == 10\n";

typemap  view on Meta::CPAN

aio_rfd		T_AIO_RFD
aio_wfd		T_AIO_WFD

octet_string		T_STR8
octet_string_ornull	T_STR8_ORNULL

INPUT

T_AIO
	if (!($var = SvAIO_REQ ($arg)))
          croak (\"busy IO::AIO::REQ object expected\")

T_AIO_ORNOT
	if (!($var = SvAIO_REQ ($arg)))
	  XSRETURN_EMPTY

T_SV8
	($var) = $arg;
        if (SvPOKp ($var) && !sv_utf8_downgrade ($var, 1))
          croak (\"\\\"%s\\\" argument must be byte/octet-encoded\", \"$var\")



( run in 0.490 second using v1.01-cache-2.11-cpan-87723dcf8b7 )