develooper Front page | perl.perl5.porters | Postings from December 2019

updating POSIX module for newer functions

Thread Next
Eric Wong
December 16, 2019 19:43
updating POSIX module for newer functions
Message ID:
Hello all, I noticed POSIX.pod states it's for IEEE Std 1003.1,
but I figure it'll be useful to support new functionality...

POSIX::spawn would be good for starting background processes w/o
pipes (or multiple pipes), even if our popen may use posix_spawn(3)

Other functions I'd like to see in the POSIX module:

* pwrite/pread - useful for sharing handles across multiple processes
  or threads (implementing DBs and such).  pread is also useful for
  single-threaded file serving the same file thousands of clients,
  especially with sendfile being unusable with userspace TLS.

* posix_fadvise - gives the ability to manipulate kernel page cache usage,
  great for reducing cache pressure on local filesystem search indexers
  and also to prevent HDD spinups on laptops.

For comparison, all of the above are implemented in recent-ish
versions of Ruby.  Ruby's Process.spawn is a superset of
posix_spawn(3), though, and I'd like work on getting the POSIX
version to feature parity at some point...

A few more newer POSIX.1-2008 ones (not in Ruby):

* _AT_FILE functions: openat, renameat, unlinkat, mkdirat, etc.
  These are useful for:

  - preventing FS mounts from changing while a handle is open
  - reducing name lookup times in the kernel for deeply nested dirs
  - implementing per-thread working directories

* posix_fallocate - can be used to reduce fragmentation when
  writing big files

* statvfs/fstatvfs - yes Filesys::Statvfs exists, but I prefer
  to have to document less dependencies and to have fewer DSOs:


I'd be happy to implement any of these and post patches and pull
requests to a self-hosted git server.  I don't agree to GitHub's
terms-of-service nor will I run JavaScript to get past CAPTCHAs.

Thanks for reading.

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About