9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Dual dialing/forking sessions to increase 9P throughput
@ 2020-12-29 23:50 cigar562hfsp952fans
  2020-12-30  8:12 ` [9fans] " joey
                   ` (3 more replies)
  0 siblings, 4 replies; 18+ messages in thread
From: cigar562hfsp952fans @ 2020-12-29 23:50 UTC (permalink / raw)
  To: 9fans

It's well-known that 9P has trouble transferring large files (high
volume/high bandwith) over high-latency networks, such as the Internet.
While sleeping, one night last week, I got an idea which might improve
throughput:

#define PSEUDOCODE ("this is psuedocode, not actual C")

#define OJUMBO   1<<n
#define JUMBORSZ 1<<16
#define JUMBOWSZ 1<<16

cpuinit() {
  whatever1();
  kernel.jumborsz = get_op(boot9pini, "jumborsz") || JUMBORSZ;
  kernel.jumbowsz = get_op(boot9pini, "jumbowsz") || JUMBOWSZ;
  whatever2();
}

open(fd, path, mode, flags) {
  chan = files[fd];
  chan.srv = NULL;
  chan.bulksrv = NULL;
  chan.rsize = 0;
  chan.wsize = 0;
  if (flags & ORD) {
    chan.rsize = (flags & OJUMBO) ? kernel.jumborsz : IOUNIT;
  }
  if (flags & OWR) {
    chan.wsize = (flags & OJUMBO) ? kernel.jumbowsz : IOUNIT;
  }
  blah();
}

dial(fd, server) {
  chan = files[fd];
  srv = parse_addr(server);
  nextsrv = copy_srv(srv);
  ver9p = "9P2000";

  switch (srv.proto) {
  case TCP:
    iosize = max(chan.rsize, chan.wsize);  
    init_9p_tcp(srv.addr, ver9p, iosize);
    srv.error && return srv.error;
    chan.srv = srv;
    if (chan.flags & OJUMBO) {
      // try to open a second connection with normal IOUNIT
      init_9p_tcp(nextsrv.addr, ver9p, IOUNIT);
      if (!nextsrv.error) {
        chan.bulksrv = srv;
        chan.srv = nextsrv;
        set_tcp_opts(chan.srv, OLATENCY);
        set_tcp_opts(chan.bulksrv, OTHROUGHPUT);
      }
    }
    ;;
  }
  whatever();
}

write(fd, buf, len) {
  chan = files[fd];
  !chan.open && return ECLOSED;
  !(chan.mode & OWR) && return EPERM;
  srv = (len > IOUNIT) ? chan.bulksrv : chan.srv;
  return write_9p(srv.conn, buf, len);
}

main() {
  fd = open(filename, ORD|OWR|OJUMBO);
  read(fd, buf, n);
  write(fd, buf, n);
  celebrate_newfound_speed();
}

The idea, basically, is to use an open flag (OJUMBO) to signal that two
connections to the same server should be attempted.  If a second
connection can be established, it is used for normal 9P transactions,
while the first connection is used for large ("jumbo") writes.  Of
course, this approach will only work if the server forks and accepts
multiple connections.  If the second connection cannot be established,
open() falls back to its customary behavior (with, perhaps, a larger
iosize, depending on the setting of OJUMBO).

There is, however, a very simple reason why this approach won't really
work: the fids for a file opened on one connection won't be recognized
by the server on the other connection.  I guess those are the kinds of
details you miss when you engineer software in your sleep.  :) The qids
would probably still be the same, assuming the same server answers both
connections.  But even that can't be guaranteed.

If it were possible to fork a 9P session off, onto another connection,
something like this could work.  But that introduces the possibility
that messages could arrive at the server or client out-of-order, which
would violate the 9P protocol.

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Te69bb0fce0f0ffaf-M7768691deb99f4bd060052c8
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2021-01-28  0:18 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-29 23:50 [9fans] Dual dialing/forking sessions to increase 9P throughput cigar562hfsp952fans
2020-12-30  8:12 ` [9fans] " joey
2021-01-03 23:51 ` [9fans] " Ethan Gardener
2021-01-04 10:55   ` Ole-Hjalmar Kristensen
2021-01-04 11:03     ` hiro
2021-01-04 19:08       ` joe
2021-01-04 20:44         ` hiro
2021-01-04 21:01         ` ori
2021-01-05  3:41 ` Joe S
2021-01-05  9:40   ` hiro
2021-01-06 22:21   ` [9fans] " cigar562hfsp952fans
2021-01-07  8:06     ` hiro
2021-01-07 16:02   ` [9fans] " ori
2021-01-25 22:31 ` David Arroyo
2021-01-27 16:25   ` Ethan Gardener
2021-01-27 16:52   ` ori
2021-01-27 17:34     ` Charles Forsyth
2021-01-28  0:17     ` David Arroyo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).