Date | Commit message (Collapse) |
|
Currently, all memory used by Raindrops is mapped as MAP_ANONYMOUS. This
means that although Raindrops counters can be shared between processes
that have forked from each other, it is not possible to share the
counter values with another, unrelated process.
This patch adds support for backing the Raindrops mapping with a file
descriptor obtained from an IO object. The #initialize API has been
enhanced with two new keyword options:
Raindrops.new(size, io: nil, zero: false)
If an instance of IO is provided, then the underlying file descriptor
for that IO will be used to back the memory mapping Raindrops creates.
An unrelated process can then open the same file, and read the counters;
either by mmap'ing the file itself (or using Raindrops to do so), or by
making ordinary seek()/read() calls if performance is not a concern.
Note that the provided IO object _must_ implement #truncate; this is
used to set the size of the file to be right-sized for the memory
mapping that is created.
If the zero argument is passed as true, then the mapping will be zero'd
by Raindrops as part of its initialization. If it's false, then the
Raindrops counters existing in the file will be preserved. This allows
counter values to be persisted (although note that Raindrops makes no
attempt to msync the values, so they are not durable to e.g. system
crashes).
Counter values can easily be shared between processes
in-memory only without touching the disk by passing in a File on a
tmpfs as the io object.
|
|
Newer rubies have more warnings
|
|
FreeBSD not only uses different values than Linux for TCP
states, but different names, too. To ease writing portable code
between the OSes, do more CPP metaprogramming via extconf.rb
and define a common hash supported on both OSes.
Putting all this in a hash allows for easy dumping and mapping
in an OS-neutral way, since the actual TCP states are
OS-independent.
|
|
Of course these fields are not portable between Linux and FreeBSD,
but they should remain ABI-compatible for future versions of each OS.
Tested on FreeBSD 10.3-RELEASE i386
TCP state names will be another problem...
|
|
While we're at it, improve the description of other skips.
|
|
Ruby 2.4 will unify Fixnum and Bignum.
|
|
With invalid addresses specified which give no currently-bound
address, we must avoid leaving placeholders ('true' objects)
in our results.
Clean up some shadowing "cur" while we're at it.
|
|
Signed-off-by: Eric Wong <normalperson@yhbt.net>
|
|
assert_raises doesn't capture exceptions the same way rescue works.
|
|
This allows reusing existing Linux::TCP_Info objects to avoid
generating garbage.
|
|
It makes no sense to compare peak times of different queues
(active vs queued) against each other.
|
|
When unix_listener_stats is called without arguments, it should
still match the behavior of tcp_listener_stats and return
ListenerStats object with zero values.
This allows callers to iterate through the results to find the
pathnames of all the Unix domain sockets in in listen mode.
|
|
Teach unix_listener_stats to remember the symlink path
it followed and have it point to the same object as the
resolved (real) socket path.
This allows the case where looking up stats by symlinks
works if the symlink is given to unix_listener_stats:
File.symlink("/real/path/of.sock", "/path/to/link.sock")
stats = unix_listener_stats(["/path/to/link.sock"])
stats["/path/to/link.sock"] => # same as stats["/real/path/of.sock"]
|
|
Raindrops currently fails when provided a symlink to a socket.
As this is a common practice for many deployment tools (Vlad,
etc.) this patch adds support for finding the realpath prior to
looking the socket up in /proc/net/unix
[ew: commit message subject]
[ew: fixed test to pass under 1.9.3 and 1.8.7:
* Tempfile#unlink is unsafe to call if we want to reuse the
path, use File.unlink(tmp.path) instead
* The return value of File.symlink is zero (or it raises),
so it's unusable.
* File.symlink will not call #to_path under 1.8.7, so it's
necessary to pass pathnames to it, not Tempfile objects.
]
Signed-off-by: Eric Wong <normalperson@yhbt.net>
|
|
This enables it to behave more like a Rack
BodyProxy would, delegating methods to its body
object when it does not implement them itself.
(Also includes a minor grammar fix to a comment.)
[ew: minor comment/whitespace fix]
Signed-off-by: Eric Wong <normalperson@yhbt.net>
|
|
Most other linux-specific test files have this, but
test_linux_tcp_info.rb does not.
With this patch, gmake test passes on OpenBSD.
|
|
Just in case somebody tries to scan all addresses, we
won't run out of memory as easily.
|
|
It could be useful to know when the first and last peak time of
a maximum was.
|
|
Unicorn.run no longer exists
|
|
It can be useful to some to see that info all at once
without hitting the HTML index page.
|
|
|
|
Found in the check-warnings target in pkg.mk
|
|
The last_data_recv field is dependent on the CONFIG_HZ of
the kernel, so the stock 250 HZ kernel can change the
timing on us.
|
|
Very few programs can take advantage of inheriting FDs
across exec() boundaries, and inet_diag sockets have no
reason to be used in this way.
|
|
We know exactly when to invalidate based on the delay :)
|
|
It takes too long
|
|
Apparently 1.8 Test::Unit doesn't like empty test classes
|
|
It does streaming!
|
|
This matches behavior of the TCP version.
|
|
No need to waste resources on creating/destroying
a socket.
|
|
It's not needed since we don't care to rebind sockets
|
|
No reason to have an extra method. This also speeds up
the multi-listener case for tcp_listener_stats since it
avoids expensive sendmsg() syscalls.
|
|
Be stricter about invalid inputs.
|
|
This is a work-in-progress and will probably be modified
before the next release.
|
|
"Advanced" GCs are typically less aggressive and typically allow
much more memory to be used.
|
|
Raindrops is designed to work with forking servers after all.
|
|
This allows limited resizing of the Raindrops memory
area since we always over-allocate due to the required
page aligment for mmap.
It would be nice if mremap() worked with MAP_SHARED,
but it does not and triggers a bus error when attempting
to access the new area.
ref: https://bugzilla.kernel.org/show_bug.cgi?id=8691
|
|
Oops, don't let GC close our listener before Unicorn
can inherit it.
|
|
POSIX message queues needs native threads to function.
|
|
Seems to basically work
|
|
|
|
|
|
|
|
UGH...
|
|
We need to do this for apps that depend on things like the
sendfile() optimizations in Rainbows!
|
|
This is the highest number a counter may be incremented to
before it overflows.
|
|
This returns a Raindrops::TCP_Info object
that wraps a tcp_info struct.
|
|
Since Unicorn and Rainbows! support IPv6 now, it makes sense to
support the rfc2732-style addresses it returns.
|
|
inet_diag already supports AF_INET6.
|
|
|