proxygen
proxygen::HTTP2PriorityQueue Class Reference

#include <HTTP2PriorityQueue.h>

Inheritance diagram for proxygen::HTTP2PriorityQueue:
proxygen::HTTP2PriorityQueueBase proxygen::HTTPCodec::PriorityQueue

Classes

class  Node
 

Public Types

using NextEgressResult = std::vector< std::pair< HTTPTransaction *, double >>
 
- Public Types inherited from proxygen::HTTP2PriorityQueueBase
using Handle = BaseNode *
 

Public Member Functions

 HTTP2PriorityQueue ()
 
 HTTP2PriorityQueue (const WheelTimerInstance &timeout)
 
void attachThreadLocals (const WheelTimerInstance &timeout)
 class HTTP2PriorityQueue More...
 
void detachThreadLocals ()
 
void setMaxVirtualNodes (uint32_t maxVirtualNodes)
 
void signalPendingEgress (Handle h) override
 
void clearPendingEgress (Handle h) override
 
void addPriorityNode (HTTPCodec::StreamID id, HTTPCodec::StreamID parent) override
 
void addOrUpdatePriorityNode (HTTPCodec::StreamID id, http2::PriorityUpdate pri)
 
void dropPriorityNodes ()
 
Handle addTransaction (HTTPCodec::StreamID id, http2::PriorityUpdate pri, HTTPTransaction *txn, bool permanent=false, uint64_t *depth=nullptr) override
 
Handle updatePriority (Handle handle, http2::PriorityUpdate pri, uint64_t *depth=nullptr) override
 
void removeTransaction (Handle handle) override
 
bool empty () const
 
uint64_t numPendingEgress () const
 
uint64_t numVirtualNodes () const
 
void iterate (const std::function< bool(HTTPCodec::StreamID, HTTPTransaction *, double)> &fn, const std::function< bool()> &stopFn, bool all)
 
void iterateBFS (const std::function< bool(HTTP2PriorityQueue &, HTTPCodec::StreamID, HTTPTransaction *, double)> &fn, const std::function< bool()> &stopFn, bool all)
 
void nextEgress (NextEgressResult &result, bool spdyMode=false)
 
void rebuildTree ()
 Error handling code. More...
 
uint32_t getRebuildCount () const
 
bool isRebuilt () const
 
- Public Member Functions inherited from proxygen::HTTPCodec::PriorityQueue
virtual ~PriorityQueue ()
 

Static Public Member Functions

static void setNodeLifetime (std::chrono::milliseconds lifetime)
 

Private Types

using NodeMap = boost::intrusive::unordered_set< Node, boost::intrusive::constant_time_size< false >>
 
typedef boost::intrusive::link_mode< boost::intrusive::auto_unlink > link_mode
 

Private Member Functions

Nodefind (HTTPCodec::StreamID id, uint64_t *depth=nullptr)
 
NodefindInternal (HTTPCodec::StreamID id)
 
bool allowDanglingNodes () const
 
void scheduleNodeExpiration (Node *node)
 
void updateEnqueuedWeight ()
 

Static Private Member Functions

static bool nextEgressResult (HTTP2PriorityQueue &queue, HTTPCodec::StreamID id, HTTPTransaction *txn, double r)
 

Private Attributes

NodeMap::bucket_type nodeBuckets_ [kNumBuckets]
 
NodeMap nodes_
 
Node root_ {*this, nullptr, 0, 1, nullptr}
 
uint32_t rebuildCount_ {0}
 
uint64_t activeCount_ {0}
 
uint32_t maxVirtualNodes_ {50}
 
uint32_t numVirtualNodes_ {0}
 
bool pendingWeightChange_ {false}
 
WheelTimerInstance timeout_
 
NextEgressResultnextEgressResults_ {nullptr}
 

Static Private Attributes

static const size_t kNumBuckets = 100
 
static uint32_t kMaxRebuilds_ = 3
 
static std::chrono::milliseconds kNodeLifetime_
 

Detailed Description

Definition at line 59 of file HTTP2PriorityQueue.h.

Member Typedef Documentation

typedef boost::intrusive::link_mode<boost::intrusive::auto_unlink> proxygen::HTTP2PriorityQueue::link_mode
private

Definition at line 194 of file HTTP2PriorityQueue.h.

using proxygen::HTTP2PriorityQueue::NextEgressResult = std::vector<std::pair<HTTPTransaction*, double>>

Definition at line 148 of file HTTP2PriorityQueue.h.

using proxygen::HTTP2PriorityQueue::NodeMap = boost::intrusive::unordered_set< Node, boost::intrusive::constant_time_size<false>>
private

Definition at line 64 of file HTTP2PriorityQueue.h.

Constructor & Destructor Documentation

proxygen::HTTP2PriorityQueue::HTTP2PriorityQueue ( )
inline

Definition at line 70 of file HTTP2PriorityQueue.h.

proxygen::HTTP2PriorityQueue::HTTP2PriorityQueue ( const WheelTimerInstance timeout)
inlineexplicit

Definition at line 75 of file HTTP2PriorityQueue.h.

76  : nodes_(NodeMap::bucket_traits(nodeBuckets_, kNumBuckets)),
77  timeout_(timeout) {
79  }
NodeMap::bucket_type nodeBuckets_[kNumBuckets]
static const size_t kNumBuckets

Member Function Documentation

void proxygen::HTTP2PriorityQueue::addOrUpdatePriorityNode ( HTTPCodec::StreamID  id,
http2::PriorityUpdate  pri 
)

Definition at line 444 of file HTTP2PriorityQueue.cpp.

References addTransaction(), find(), and updatePriority().

Referenced by proxygen::HTTPSession::onPriority(), and proxygen::HTTPSession::sendPriority().

445  {
446  auto handle = find(id);
447  if (handle) {
448  // already added
449  CHECK(handle->getTransaction() == nullptr);
450  updatePriority(handle, pri);
451  } else {
452  // brand new
453  addTransaction(id, pri, nullptr, false /* not permanent */);
454  }
455 }
Handle addTransaction(HTTPCodec::StreamID id, http2::PriorityUpdate pri, HTTPTransaction *txn, bool permanent=false, uint64_t *depth=nullptr) override
Node * find(HTTPCodec::StreamID id, uint64_t *depth=nullptr)
Handle updatePriority(Handle handle, http2::PriorityUpdate pri, uint64_t *depth=nullptr) override
void proxygen::HTTP2PriorityQueue::addPriorityNode ( HTTPCodec::StreamID  id,
HTTPCodec::StreamID  parent 
)
inlineoverridevirtual

Implements proxygen::HTTPCodec::PriorityQueue.

Definition at line 95 of file HTTP2PriorityQueue.h.

References proxygen::HTTP2PriorityQueueBase::addTransaction(), and uint32_t.

96  {
97  addTransaction(id, {(uint32_t)parent, false, 0}, nullptr, true);
98  }
Handle addTransaction(HTTPCodec::StreamID id, http2::PriorityUpdate pri, HTTPTransaction *txn, bool permanent=false, uint64_t *depth=nullptr) override
folly::Function< void()> parent
Definition: AtFork.cpp:34
HTTP2PriorityQueue::Handle proxygen::HTTP2PriorityQueue::addTransaction ( HTTPCodec::StreamID  id,
http2::PriorityUpdate  pri,
HTTPTransaction txn,
bool  permanent = false,
uint64_t depth = nullptr 
)
overridevirtual

Implements proxygen::HTTP2PriorityQueueBase.

Definition at line 458 of file HTTP2PriorityQueue.cpp.

References proxygen::HTTP2PriorityQueue::Node::convertVirtualNode(), proxygen::http2::DefaultPriority, proxygen::http2::PriorityUpdate::exclusive, find(), proxygen::HTTP2PriorityQueue::Node::getID(), maxVirtualNodes_, folly::gen::move, numVirtualNodes_, parent, pendingWeightChange_, root_, scheduleNodeExpiration(), proxygen::http2::PriorityUpdate::streamDependency, uint16_t, updatePriority(), and proxygen::http2::PriorityUpdate::weight.

Referenced by addOrUpdatePriorityNode(), and updatePriority().

462  {
463  CHECK_NE(id, 0);
464  CHECK_NE(id, pri.streamDependency) << "Tried to create a loop in the tree";
465  CHECK(!txn || !permanent);
466  Node *existingNode = find(id, depth);
467  if (existingNode) {
468  CHECK(!permanent);
469  existingNode->convertVirtualNode(CHECK_NOTNULL(txn));
470  updatePriority(existingNode, pri);
471  return existingNode;
472  }
473  if (!txn) {
475  return nullptr;
476  }
478  }
479 
480  Node* parent = &root_;
481  if (depth) {
482  *depth = 1;
483  }
484  if (pri.streamDependency != 0) {
485  Node* dep = find(pri.streamDependency, depth);
486  if (dep == nullptr) {
487  // specified a missing parent (timed out an idle node)?
488  VLOG(4) << "assigning default priority to txn=" << id;
489  // No point to try to instantiate one more virtual node
490  // if we already reached the virtual node limit
492  // The parent node hasn't arrived yet. For now setting
493  // its priority fields to default.
494  parent = dynamic_cast<Node*>(
495  addTransaction(pri.streamDependency,
497  nullptr,
498  permanent,
499  depth));
500  CHECK_NOTNULL(parent);
501  if (depth) {
502  *depth += 1;
503  }
504  } else {
505  VLOG(4) << "Virtual node limit reached, ignoring stream dependency "
506  << pri.streamDependency << " for new node ID " << id;
507  }
508  } else {
509  parent = dep;
510  if (depth) {
511  *depth += 1;
512  }
513  }
514  }
515  VLOG(4) << "Adding id=" << id << " with parent=" << parent->getID() <<
516  " and weight=" << ((uint16_t)pri.weight + 1);
517  auto node = std::make_unique<Node>(*this, parent, id, pri.weight, txn);
518  if (permanent) {
519  node->setPermanent();
520  } else if (!txn) {
521  scheduleNodeExpiration(node.get());
522  }
523  auto result = parent->emplaceNode(std::move(node), pri.exclusive);
524  pendingWeightChange_ = true;
525  return result;
526 }
void scheduleNodeExpiration(Node *node)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
Handle addTransaction(HTTPCodec::StreamID id, http2::PriorityUpdate pri, HTTPTransaction *txn, bool permanent=false, uint64_t *depth=nullptr) override
Node * find(HTTPCodec::StreamID id, uint64_t *depth=nullptr)
const PriorityUpdate DefaultPriority
Definition: HTTP2Framer.cpp:21
Handle updatePriority(Handle handle, http2::PriorityUpdate pri, uint64_t *depth=nullptr) override
folly::Function< void()> parent
Definition: AtFork.cpp:34
bool proxygen::HTTP2PriorityQueue::allowDanglingNodes ( ) const
inlineprivate

Definition at line 175 of file HTTP2PriorityQueue.h.

Referenced by removeTransaction().

175  {
176  return timeout_ && kNodeLifetime_.count() > 0;
177  }
static std::chrono::milliseconds kNodeLifetime_
void proxygen::HTTP2PriorityQueue::attachThreadLocals ( const WheelTimerInstance timeout)
void proxygen::HTTP2PriorityQueue::clearPendingEgress ( Handle  h)
overridevirtual

Implements proxygen::HTTP2PriorityQueueBase.

Definition at line 606 of file HTTP2PriorityQueue.cpp.

References activeCount_, and pendingWeightChange_.

606  {
607  CHECK_GT(activeCount_, 0);
608  // clear does a CHECK on handle->isEnqueued()
609  CHECK_NOTNULL(dynamic_cast<HTTP2PriorityQueue::Node*>(handle))
610  ->clearPendingEgress();
611  activeCount_--;
612  pendingWeightChange_ = true;
613 }
void proxygen::HTTP2PriorityQueue::detachThreadLocals ( )

Definition at line 437 of file HTTP2PriorityQueue.cpp.

References proxygen::HTTP2PriorityQueue::Node::dropPriorityNodes(), and timeout_.

Referenced by proxygen::HTTPUpstreamSession::detachThreadLocals().

437  {
438  // a bit harsh, we could cancel and reschedule the timeout
440  timeout_ = WheelTimerInstance();
441 }
HTTP2PriorityQueue::Node * proxygen::HTTP2PriorityQueue::find ( HTTPCodec::StreamID  id,
uint64_t depth = nullptr 
)
private

Definition at line 695 of file HTTP2PriorityQueue.cpp.

References nodes_.

Referenced by addOrUpdatePriorityNode(), addTransaction(), and updatePriority().

695  {
696  if (id == 0) {
697  return nullptr;
698  }
699  auto it = nodes_.find(id, Node::IdHash(), Node::IdNodeEqual());
700  if (it == nodes_.end()) {
701  return nullptr;
702  }
703  if (depth) {
704  *depth = it->calculateDepth();
705  }
706  return &(*it);
707 }
Node* proxygen::HTTP2PriorityQueue::findInternal ( HTTPCodec::StreamID  id)
inlineprivate

Definition at line 168 of file HTTP2PriorityQueue.h.

Referenced by iterateBFS().

168  {
169  if (id == 0) {
170  return &root_;
171  }
172  return find(id);
173  }
Node * find(HTTPCodec::StreamID id, uint64_t *depth=nullptr)
uint32_t proxygen::HTTP2PriorityQueue::getRebuildCount ( ) const
inline

Definition at line 160 of file HTTP2PriorityQueue.h.

bool proxygen::HTTP2PriorityQueue::isRebuilt ( ) const
inline

Definition at line 161 of file HTTP2PriorityQueue.h.

References uint64_t.

161 { return rebuildCount_ > 0; }
void proxygen::HTTP2PriorityQueue::iterate ( const std::function< bool(HTTPCodec::StreamID, HTTPTransaction *, double)> &  fn,
const std::function< bool()> &  stopFn,
bool  all 
)
inline

Definition at line 135 of file HTTP2PriorityQueue.h.

References folly::gen::all().

137  {
139  root_.iterate(fn, stopFn, all);
140  }
bool iterate(const std::function< bool(HTTPCodec::StreamID, HTTPTransaction *, double)> &fn, const std::function< bool()> &stopFn, bool all)
Composed all(Predicate pred=Predicate())
Definition: Base.h:786
void proxygen::HTTP2PriorityQueue::iterateBFS ( const std::function< bool(HTTP2PriorityQueue &, HTTPCodec::StreamID, HTTPTransaction *, double)> &  fn,
const std::function< bool()> &  stopFn,
bool  all 
)

Definition at line 616 of file HTTP2PriorityQueue.cpp.

References folly::gen::all(), findInternal(), root_, stop(), folly::f14::swap(), proxygen::HTTP2PriorityQueue::Node::updateEnqueuedWeight(), and proxygen::HTTP2PriorityQueue::Node::visitBFS().

Referenced by proxygen::HTTPSession::resumeTransactions().

619  {
620  Node::PendingList pendingNodes{{0, &root_, 1.0}};
621  Node::PendingList newPendingNodes;
622  bool stop = false;
623 
625  while (!stop && !stopFn() && !pendingNodes.empty()) {
626  CHECK(newPendingNodes.empty());
627  while (!stop && !pendingNodes.empty()) {
628  Node* node = findInternal(pendingNodes.front().id);
629  if (node) {
630  stop = node->visitBFS(pendingNodes.front().ratio, fn, all,
631  newPendingNodes, false /* all children */);
632  }
633  pendingNodes.pop_front();
634  }
635  std::swap(pendingNodes, newPendingNodes);
636  }
637 }
std::deque< PendingNode > PendingList
Node * findInternal(HTTPCodec::StreamID id)
bool visitBFS(double relativeParentWeight, const std::function< bool(HTTP2PriorityQueue &queue, HTTPCodec::StreamID, HTTPTransaction *, double)> &fn, bool all, PendingList &pendingNodes, bool enqueuedChildren)
static void stop()
void swap(SwapTrackingAlloc< T > &, SwapTrackingAlloc< T > &)
Definition: F14TestUtil.h:414
Composed all(Predicate pred=Predicate())
Definition: Base.h:786
void proxygen::HTTP2PriorityQueue::nextEgress ( HTTP2PriorityQueue::NextEgressResult result,
bool  spdyMode = false 
)

Definition at line 648 of file HTTP2PriorityQueue.cpp.

References activeCount_, nextEgressResult(), nextEgressResults_, root_, stop(), folly::f14::swap(), proxygen::HTTP2PriorityQueue::Node::updateEnqueuedWeight(), and proxygen::HTTP2PriorityQueue::Node::visitBFS().

Referenced by proxygen::HTTPSession::getNextToSend().

649  {
650  struct WeightCmp {
651  bool operator()(const std::pair<HTTPTransaction*, double>& t1,
652  const std::pair<HTTPTransaction*, double>& t2) {
653  return t1.second > t2.second;
654  }
655  };
656 
657  result.reserve(activeCount_);
658  nextEgressResults_ = &result;
659 
661  Node::PendingList pendingNodes;
662  Node::PendingList pendingNodesTmp;
663  pendingNodes.emplace_back(0, &root_, 1.0);
664  bool stop = false;
665  do {
666  while (!stop && !pendingNodes.empty()) {
667  Node* node = pendingNodes.front().node;
668  if (node) {
669  stop = node->visitBFS(pendingNodes.front().ratio, nextEgressResult,
670  false, pendingNodesTmp,
671  true /* enqueued children */);
672  }
673  pendingNodes.pop_front();
674  }
675  // In SPDY mode, we stop as soon one level of the tree produces results,
676  // then normalize the ratios.
677  if (spdyMode && !result.empty() && !pendingNodesTmp.empty()) {
678  double totalRatio = 0;
679  for (auto &txnPair: result) {
680  totalRatio += txnPair.second;
681  }
682  CHECK_GT(totalRatio, 0);
683  for (auto &txnPair: result) {
684  txnPair.second = txnPair.second / totalRatio;
685  }
686  break;
687  }
688  std::swap(pendingNodes, pendingNodesTmp);
689  } while (!stop && !pendingNodes.empty());
690  std::sort(result.begin(), result.end(), WeightCmp());
691  nextEgressResults_ = nullptr;
692 }
std::deque< PendingNode > PendingList
static void stop()
static bool nextEgressResult(HTTP2PriorityQueue &queue, HTTPCodec::StreamID id, HTTPTransaction *txn, double r)
NextEgressResult * nextEgressResults_
void swap(SwapTrackingAlloc< T > &, SwapTrackingAlloc< T > &)
Definition: F14TestUtil.h:414
bool proxygen::HTTP2PriorityQueue::nextEgressResult ( HTTP2PriorityQueue queue,
HTTPCodec::StreamID  id,
HTTPTransaction txn,
double  r 
)
staticprivate

Definition at line 640 of file HTTP2PriorityQueue.cpp.

References nextEgressResults_.

Referenced by nextEgress().

642  {
643  queue.nextEgressResults_->emplace_back(txn, r);
644  return false;
645 }
uint64_t proxygen::HTTP2PriorityQueue::numPendingEgress ( ) const
inline

Definition at line 127 of file HTTP2PriorityQueue.h.

Referenced by proxygen::HTTPSession::runLoopCallback().

127  {
128  return activeCount_;
129  }
uint64_t proxygen::HTTP2PriorityQueue::numVirtualNodes ( ) const
inline

Definition at line 131 of file HTTP2PriorityQueue.h.

131  {
132  return numVirtualNodes_;
133  }
void proxygen::HTTP2PriorityQueue::rebuildTree ( )
void proxygen::HTTP2PriorityQueue::removeTransaction ( HTTP2PriorityQueue::Handle  handle)
overridevirtual

Implements proxygen::HTTP2PriorityQueueBase.

Definition at line 578 of file HTTP2PriorityQueue.cpp.

References allowDanglingNodes(), proxygen::HTTP2PriorityQueue::Node::clearPendingEgress(), proxygen::HTTP2PriorityQueue::Node::clearTransaction(), proxygen::HTTP2PriorityQueue::Node::getID(), proxygen::HTTP2PriorityQueue::Node::isEnqueued(), maxVirtualNodes_, numVirtualNodes_, pendingWeightChange_, proxygen::HTTP2PriorityQueue::Node::removeFromTree(), and scheduleNodeExpiration().

578  {
579  Node* node = CHECK_NOTNULL(dynamic_cast<HTTP2PriorityQueue::Node*>(handle));
580  pendingWeightChange_ = true;
581  // TODO: or require the node to do it?
582  if (node->isEnqueued()) {
583  clearPendingEgress(handle);
584  }
586  node->clearTransaction();
589  } else {
590  VLOG(5) << "Deleting dangling node over max id=" << node->getID();
591  node->removeFromTree();
592  }
593 }
void scheduleNodeExpiration(Node *node)
void clearPendingEgress(Handle h) override
void proxygen::HTTP2PriorityQueue::scheduleNodeExpiration ( Node node)
inlineprivate

Definition at line 179 of file HTTP2PriorityQueue.h.

References proxygen::HTTP2PriorityQueue::Node::getID().

Referenced by addTransaction(), proxygen::HTTP2PriorityQueue::Node::detachChild(), and removeTransaction().

179  {
180  if (timeout_) {
181  VLOG(5) << "scheduling expiration for node=" << node->getID();
182  DCHECK_GT(kNodeLifetime_.count(), 0);
184  }
185  }
void scheduleTimeout(folly::HHWheelTimer::Callback *callback, std::chrono::milliseconds timeout)
static std::chrono::milliseconds kNodeLifetime_
void proxygen::HTTP2PriorityQueue::setMaxVirtualNodes ( uint32_t  maxVirtualNodes)
inline
static void proxygen::HTTP2PriorityQueue::setNodeLifetime ( std::chrono::milliseconds  lifetime)
inlinestatic

Definition at line 152 of file HTTP2PriorityQueue.h.

152  {
153  kNodeLifetime_ = lifetime;
154  }
static std::chrono::milliseconds kNodeLifetime_
void proxygen::HTTP2PriorityQueue::signalPendingEgress ( Handle  h)
overridevirtual

Implements proxygen::HTTP2PriorityQueueBase.

Definition at line 596 of file HTTP2PriorityQueue.cpp.

References activeCount_, proxygen::HTTP2PriorityQueueBase::BaseNode::isEnqueued(), and pendingWeightChange_.

596  {
597  if (!handle->isEnqueued()) {
598  CHECK_NOTNULL(dynamic_cast<HTTP2PriorityQueue::Node*>(handle))
599  ->signalPendingEgress();
600  activeCount_++;
601  pendingWeightChange_ = true;
602  }
603 }
void proxygen::HTTP2PriorityQueue::updateEnqueuedWeight ( )
private
HTTP2PriorityQueue::Handle proxygen::HTTP2PriorityQueue::updatePriority ( HTTP2PriorityQueue::Handle  handle,
http2::PriorityUpdate  pri,
uint64_t depth = nullptr 
)
overridevirtual

Implements proxygen::HTTP2PriorityQueueBase.

Definition at line 529 of file HTTP2PriorityQueue.cpp.

References addTransaction(), proxygen::HTTP2PriorityQueueBase::BaseNode::calculateDepth(), proxygen::HTTP2PriorityQueue::Node::calculateDepth(), proxygen::http2::DefaultPriority, proxygen::http2::PriorityUpdate::exclusive, find(), proxygen::HTTP2PriorityQueue::Node::getID(), proxygen::HTTP2PriorityQueue::Node::getParent(), proxygen::HTTP2PriorityQueue::Node::isDescendantOf(), maxVirtualNodes_, numVirtualNodes_, proxygen::HTTP2PriorityQueue::Node::parentID(), pendingWeightChange_, proxygen::HTTP2PriorityQueue::Node::reparent(), root_, proxygen::http2::PriorityUpdate::streamDependency, uint16_t, proxygen::HTTP2PriorityQueue::Node::updateWeight(), and proxygen::http2::PriorityUpdate::weight.

Referenced by addOrUpdatePriorityNode(), and addTransaction().

531  {
532  Node* node = CHECK_NOTNULL(dynamic_cast<HTTP2PriorityQueue::Node*>(handle));
533  pendingWeightChange_ = true;
534  VLOG(4) << "Updating id=" << node->getID() << " with parent=" <<
535  pri.streamDependency << " and weight=" << ((uint16_t)pri.weight + 1);
536  node->updateWeight(pri.weight);
537  CHECK_NE(pri.streamDependency, node->getID()) <<
538  "Tried to create a loop in the tree";
539  if (pri.streamDependency == node->parentID() && !pri.exclusive) {
540  // no move
541  if (depth) {
542  *depth = handle->calculateDepth();
543  }
544  return handle;
545  }
546 
547  Node* newParent = find(pri.streamDependency, depth);
548  if (!newParent) {
549  if (pri.streamDependency == 0 || numVirtualNodes_ >= maxVirtualNodes_) {
550  newParent = &root_;
551  } else {
552  // allocate a virtual node for non-existing parent in my depenency tree
553  // then do normal priority processing
554  newParent = dynamic_cast<Node*>(
555  addTransaction(pri.streamDependency,
557  nullptr,
558  false,
559  depth));
560 
561  CHECK_NOTNULL(newParent);
562  VLOG(4) << "updatePriority missing parent, creating virtual parent="
563  << newParent->getID() << " for txn=" << node->getID();
564  }
565  }
566 
567  if (newParent->isDescendantOf(node)) {
568  newParent = newParent->reparent(node->getParent(), false);
569  }
570  node = node->reparent(newParent, pri.exclusive);
571  if (depth) {
572  *depth = node->calculateDepth();
573  }
574  return node;
575 }
Handle addTransaction(HTTPCodec::StreamID id, http2::PriorityUpdate pri, HTTPTransaction *txn, bool permanent=false, uint64_t *depth=nullptr) override
Node * find(HTTPCodec::StreamID id, uint64_t *depth=nullptr)
const PriorityUpdate DefaultPriority
Definition: HTTP2Framer.cpp:21

Member Data Documentation

uint64_t proxygen::HTTP2PriorityQueue::activeCount_ {0}
private
uint32_t proxygen::HTTP2PriorityQueue::kMaxRebuilds_ = 3
staticprivate

Definition at line 411 of file HTTP2PriorityQueue.h.

Referenced by rebuildTree().

std::chrono::milliseconds proxygen::HTTP2PriorityQueue::kNodeLifetime_
staticprivate
Initial value:
=
std::chrono::seconds(30)

Definition at line 419 of file HTTP2PriorityQueue.h.

const size_t proxygen::HTTP2PriorityQueue::kNumBuckets = 100
staticprivate

Definition at line 66 of file HTTP2PriorityQueue.h.

uint32_t proxygen::HTTP2PriorityQueue::maxVirtualNodes_ {50}
private

Definition at line 413 of file HTTP2PriorityQueue.h.

Referenced by addTransaction(), removeTransaction(), and updatePriority().

NextEgressResult* proxygen::HTTP2PriorityQueue::nextEgressResults_ {nullptr}
private

Definition at line 418 of file HTTP2PriorityQueue.h.

Referenced by nextEgress(), and nextEgressResult().

NodeMap::bucket_type proxygen::HTTP2PriorityQueue::nodeBuckets_[kNumBuckets]
private

Definition at line 407 of file HTTP2PriorityQueue.h.

NodeMap proxygen::HTTP2PriorityQueue::nodes_
private

Definition at line 408 of file HTTP2PriorityQueue.h.

Referenced by find(), and proxygen::HTTP2PriorityQueue::Node::Node().

bool proxygen::HTTP2PriorityQueue::pendingWeightChange_ {false}
private
uint32_t proxygen::HTTP2PriorityQueue::rebuildCount_ {0}
private

Definition at line 410 of file HTTP2PriorityQueue.h.

Referenced by rebuildTree().

Node proxygen::HTTP2PriorityQueue::root_ {*this, nullptr, 0, 1, nullptr}
private
WheelTimerInstance proxygen::HTTP2PriorityQueue::timeout_
private

Definition at line 416 of file HTTP2PriorityQueue.h.

Referenced by attachThreadLocals(), and detachThreadLocals().


The documentation for this class was generated from the following files: