Record a completed I/O event.  The nanosecond time slot is actually nano's-blocked-on-io
549098
public static void record_IOclose( AutoBuffer b, int flavor ) {
    H2ONode h2o = b._h2o==null ? H2O.SELF : b._h2o;
    // First long word going out has sender-port and a 'bad' control packet
    long b0 = UDP.udp.i_o.ordinal(); // Special flag to indicate io-record and not a rpc-record
    b0 |= H2O.SELF._key.udp_port()<<8;
    b0 |= flavor<<24;           // I/O flavor; one of the Value.persist backends
    long iotime = b._time_start_ms > 0 ? (b._time_close_ms - b._time_start_ms) : 0;
    b0 |= iotime<<32;           // msec from start-to-finish, including non-i/o overheads
    long b8 = b._size;          // byte's transfered in this I/O
    long ns = b._time_io_ns;    // nano's blocked doing I/O
    record2(h2o,ns,true,b.readMode()?1:0,0,b0,b8);
  }
867491
def record_participation(self, client, dt=None):
        """"""
        if dt is None:
            date = datetime.now()
        else:
            date = dt

        experiment_key = self.experiment.name

        pipe = self.redis.pipeline()

        pipe.sadd(_key("p:{0}:years".format(experiment_key)), date.strftime('%Y'))
        pipe.sadd(_key("p:{0}:months".format(experiment_key)), date.strftime('%Y-%m'))
        pipe.sadd(_key("p:{0}:days".format(experiment_key)), date.strftime('%Y-%m-%d'))

        pipe.execute()

        keys = [
            _key("p:{0}:_all:all".format(experiment_key)),
            _key("p:{0}:_all:{1}".format(experiment_key, date.strftime('%Y'))),
            _key("p:{0}:_all:{1}".format(experiment_key, date.strftime('%Y-%m'))),
            _key("p:{0}:_all:{1}".format(experiment_key, date.strftime('%Y-%m-%d'))),
            _key("p:{0}:{1}:all".format(experiment_key, self.name)),
            _key("p:{0}:{1}:{2}".format(experiment_key, self.name, date.strftime('%Y'))),
            _key("p:{0}:{1}:{2}".format(experiment_key, self.name, date.strftime('%Y-%m'))),
            _key("p:{0}:{1}:{2}".format(experiment_key, self.name, date.strftime('%Y-%m-%d'))),
        ]
        msetbit(keys=keys, args=([self.experiment.sequential_id(client), 1] * len(keys)))
1050352
def grab_earliest(self, timeout: float=None) -> typing.List[DataAndMetadata.DataAndMetadata]:
        """"""
        timeout = timeout if timeout is not None else 10.0
        with self.__buffer_lock:
            if len(self.__buffer) == 0:
                done_event = threading.Event()
                self.__done_events.append(done_event)
                self.__buffer_lock.release()
                done = done_event.wait(timeout)
                self.__buffer_lock.acquire()
                if not done:
                    raise Exception("Could not grab latest.")
            return self.__buffer.pop(0)
1103493
private synchronized void closeInternal() throws IOException {
    dfsClient.checkOpen();
    isClosed();

    try {
        eventStartWrite();

        flushBuffer(true, false);       // flush from all upper layers

        eventCloseAfterFlushBuffer();
        
        // Mark that this packet is the last packet in block.
        // If there are no outstanding packets and the last packet
        // was not the last one in the current block, then create a
        // packet with empty payload.
        synchronized (dataQueue) {
          if (currentPacket == null && bytesCurBlock != 0) {
            WritePacketClientProfile pktProfile = null;
            if (getProfileData() != null) {
              pktProfile = getProfileData().getWritePacketClientProfile();
            }
            currentPacket = DFSOutputStreamPacketFactory.getPacket(
              DFSOutputStream.this, ifPacketIncludeVersion(),
              getPacketVersion(), packetSize, chunksPerPacket, bytesCurBlock, pktProfile);
          }
          if (currentPacket != null) {
            currentPacket.lastPacketInBlock = true;
          }
        }
                
      flushInternal();             // flush all data to Datanodes
      isClosed(); // check to see if flushInternal had any exceptions
      closed = true; // allow closeThreads() to showdown threads

      closeThreads();

      synchronized (dataQueue) {
        if (blockStream != null) {
          blockStream.writeInt(0); // indicate end-of-block to datanode
          blockStream.close();
          blockReplyStream.close();
        }
        if (s != null) {
          for (int i = 0; i < s.length; i++) {
            s[i].close();
          }
          s = null;
        }
      }

      streamer = null;
      blockStream = null;
      blockReplyStream = null;

      eventCloseReceivedAck();
      
      dfsClient.closeFile(src, lastBlkOffset, getLastBlock());
      
      eventEndClose();
    } finally {
      closed = true;
    }
  }
910470
def write_event(self, etype, code, value):
        """"""
        last_value = self._write_cache.get(code)
        if last_value != value:
            self.device.write(etype, code, value)
            self._write_cache[code] = value
491604
def _handle_io(self, args, file, result, passphrase=False, binary=False):
        """"""
        p = self._open_subprocess(args, passphrase)
        if not binary:
            stdin = codecs.getwriter(self._encoding)(p.stdin)
        else:
            stdin = p.stdin
        if passphrase:
            _util._write_passphrase(stdin, passphrase, self._encoding)
        writer = _util._threaded_copy_data(file, stdin)
        self._collect_output(p, result, writer, stdin)
        return result
963486
private void finishConnect(final SelectionKey sk, final MemcachedNode node)
    throws IOException {
    if (verifyAliveOnConnect) {
      final CountDownLatch latch = new CountDownLatch(1);
      final OperationFuture<Boolean> rv = new OperationFuture<Boolean>("noop",
        latch, 2500, listenerExecutorService);
      NoopOperation testOp = opFact.noop(new OperationCallback() {
        public void receivedStatus(OperationStatus status) {
          rv.set(status.isSuccess(), status);
        }

        @Override
        public void complete() {
          latch.countDown();
        }
      });

      testOp.setHandlingNode(node);
      testOp.initialize();
      checkState();
      insertOperation(node, testOp);
      node.copyInputQueue();

      boolean done = false;
      if (sk.isValid()) {
        long timeout = TimeUnit.MILLISECONDS.toNanos(
          connectionFactory.getOperationTimeout());

        long stop = System.nanoTime() + timeout;
        while (stop > System.nanoTime()) {
          handleWrites(node);
          handleReads(node);
          if(done = (latch.getCount() == 0)) {
            break;
          }
        }
      }

      if (!done || testOp.isCancelled() || testOp.hasErrored()
        || testOp.isTimedOut()) {
        throw new ConnectException("Could not send noop upon connect! "
          + "This may indicate a running, but not responding memcached "
          + "instance.");
      }
    }

    connected(node);
    addedQueue.offer(node);
    if (node.getWbuf().hasRemaining()) {
      handleWrites(node);
    }
  }
785995
function (event) {
        var self = this;

        event.monologued = false;
        event.recorded_at = new Date();

        self.events.insert(event, function (err) {
          if (!err) {
            _.delay(function () {
              self.events.remove({
                event_id: event.event_id
              });
            }, 60000);
          }
        });
      }
386361
def _event(self, event):
    """"""
    result = dict(
        pid=event.device_id,
        tid=event.resource_id,
        name=event.name,
        ts=event.timestamp_ps / 1000000.0)
    if event.duration_ps:
      result['ph'] = _TYPE_COMPLETE
      result['dur'] = event.duration_ps / 1000000.0
    else:
      result['ph'] = _TYPE_INSTANT
      result['s'] = _SCOPE_THREAD
    for key in dict(event.args):
      if 'args' not in result:
        result['args'] = {}
      result['args'][key] = event.args[key]
    return result
217886
def _wait_for_io_events(socks, events, timeout=None):
    
    if not HAS_SELECT:
        raise ValueError('Platform does not have a selector')
    if not isinstance(socks, list):
        # Probably just a single socket.
        if hasattr(socks, "fileno"):
            socks = [socks]
        # Otherwise it might be a non-list iterable.
        else:
            socks = list(socks)
    with DefaultSelector() as selector:
        for sock in socks:
            selector.register(sock, events)
        return [key[0].fileobj for key in
                selector.select(timeout) if key[1] & events]
49683
def trigger(self):
        """"""
        if _debug: IOCB._debug("trigger(%d)", self.ioID)

        # if it's queued, remove it from its queue
        if self.ioQueue:
            if _debug: IOCB._debug("    - dequeue")
            self.ioQueue.remove(self)

        # if there's a timer, cancel it
        if self.ioTimeout:
            if _debug: IOCB._debug("    - cancel timeout")
            self.ioTimeout.suspend_task()

        # set the completion event
        self.ioComplete.set()
        if _debug: IOCB._debug("    - complete event set")

        # make the callback(s)
        for fn, args, kwargs in self.ioCallback:
            if _debug: IOCB._debug("    - callback fn: %r %r %r", fn, args, kwargs)
            fn(self, *args, **kwargs)
553738
function recordTiming (name, timing) {
  recorder[name] = parseInt(timing, 10) || Date.now()
  performanceEvent.trigger('update', getTiming())
}
593230
@Override
  public void writeImpl(D record) throws IOException {
    if (!isRetry()) {
      //If currentRequest is still here, it means this is retry request.
      //In this case, don't invoke onNewRecord again as onNewRecord is not guaranteed to be idempotent.
      //(e.g: If you do batch processing duplicate record can go in, etc.)
      curRequest = onNewRecord(record);
    }

    if (curRequest.isPresent()) {
      ListenableFuture<CloseableHttpResponse> responseFuture = sendRequest(curRequest.get());
      try (CloseableHttpResponse response = waitForResponse(responseFuture)) {
        processResponse(response);
      }
      curRequest = Optional.absent(); //Clear request if successful
    }
    numRecordsWritten++;
  }
266578
def get_event_noblock(self):
        '''
        
        '''
        assert self._run_io_loop_sync

        if not self.cpub:
            if not self.connect_pub():
                return None
        raw = self.subscriber.read_sync(timeout=0)
        if raw is None:
            return None
        mtag, data = self.unpack(raw, self.serial)
        return {'data': data, 'tag': mtag}
697014
def record(self, i=0):
        """"""
        f = self.__getFileObj(self.dbf)
        if self.numRecords is None:
            self.__dbfHeader()
        i = self.__restrictIndex(i)
        recSize = self.__recStruct.size
        f.seek(0)
        f.seek(self.__dbfHdrLength + (i * recSize))
        return self.__record(oid=i)
36770
def write_record(self, event_str):
        """"""
        header = struct.pack('Q', len(event_str))
        header += struct.pack('I', masked_crc32c(header))
        footer = struct.pack('I', masked_crc32c(event_str))
        self._writer.write(header + event_str + footer)
189571
def process_once(self, timeout=0.01):
        
        try:
            event = self.recv(timeout)
            if event:
                event_t = event[0]
                event_c = event[1]

                if event_t == 'JOIN':
                    self.on_join(event_c[0], event_c[1])
                elif event_t == 'PART':
                    self.on_part(event_c[0], event_c[1], event_c[2])
                elif event_t == 'PRIVMSG':
                    if event_c[1] in self.channels.keys():
                        self.on_chanmsg(event_c[0], event_c[1], event_c[2])
                    else:
                        self.on_privmsg(event_c[0], event_c[2])
                elif event_t == 'NOTICE':
                    if event_c[1] in self.channels.keys():
                        self.on_channotice(event_c[0], event_c[1], event_c[2])
                    else:
                        self.on_privnotice(event_c[0], event_c[2])
                elif event_t == 'CTCP':
                    if event_c[1] in self.channels.keys():
                        self.on_chanctcp(event_c[0], event_c[1], event_c[2])
                    else:
                        self.on_privctcp(event_c[0], event_c[2])
                elif event_t == 'CTCP_REPLY':
                    self.on_ctcp_reply(event_c[0], event_c[2])
                elif event_t == 'MODE':
                    if event_c[0][0] == self.current_nick:
                        self.on_umode(event_c[1])
                    else:
                        self.on_cmode(event_c[0], event_c[1], event_c[2])
                elif event_t == 'KICK':
                    self.on_kick(event_c[0], event_c[1], event_c[2], \
                    event_c[3])
                elif event_t == 'INVITE':
                    self.on_invite(event_c[0], event_c[2])
                elif event_t == 'NICK':
                    self.on_nick(event_c[0], event_c[1])
                elif event_t == 'TOPIC':
                    self.on_topic(event_c[0], event_c[1], event_c[2])
                elif event_t == 'QUIT':
                    self.on_quit(event_c[0], event_c[1])
                elif event_t == 'LUSERS':
                    self.on_lusers(event_c)
                elif event_t == 'ERROR':
                    self.on_error(event_c[0])
                elif event_t == 'UNKNOWN':
                    self.on_unknown(event_c[0])

        except self.LurklibError as exception:
            self.on_exception(exception)