New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 708260 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Apr 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocked on:
issue 700617

Blocking:
issue 704953



Sign in to add a comment

Reduce number of redundant map lookups in QuicStreamFactory

Project Member Reported by xunji...@chromium.org, Apr 4 2017

Issue description

There a a couple of redundant map lookups in QuicStreamFactory.
In the code snippet below, there are 5 job_requests_map_[server_id] lookups when we only need 1.


void QuicStreamFactory::OnJobComplete(Job* job, int rv) {
  // Copy |server_id|, because |job| might be destroyed before this method
  // returns.
  const QuicServerId server_id(job->key().server_id());
  if (rv != OK) {
    JobSet* jobs = &(active_jobs_[server_id]);
    if (jobs->size() > 1) {
      // If there is another pending job, then we can delete this job and let
      // the other job handle the request.
      job->Cancel();
      jobs->erase(job);
      return;
    }
  }

  if (rv == OK) {
    if (!always_require_handshake_confirmation_)
      set_require_confirmation(false);

    if (!job_requests_map_[server_id].empty()) {
      SessionMap::iterator session_it = active_sessions_.find(server_id);
      DCHECK(session_it != active_sessions_.end());
      QuicChromiumClientSession* session = session_it->second;
      for (QuicStreamRequest* request : job_requests_map_[server_id]) {
        DCHECK(request->server_id() == server_id);
        // Do not notify |request| yet.
        request->SetSession(session);
      }
    }
  }

  while (!job_requests_map_[server_id].empty()) {
    RequestSet::iterator it = job_requests_map_[server_id].begin();
    QuicStreamRequest* request = *it;
    job_requests_map_[server_id].erase(it);
    active_requests_.erase(request);
    // Even though we're invoking callbacks here, we don't need to worry
    // about |this| being deleted, because the factory is owned by the
    // profile which can not be deleted via callbacks.
    request->OnRequestComplete(rv);
  }

  for (auto& other_job : active_jobs_[server_id]) {
    if (other_job.first != job)
      other_job.first->Cancel();
  }

  active_jobs_[server_id].clear();
  active_jobs_.erase(server_id);
  job_requests_map_.erase(server_id);
}

 
Project Member

Comment 1 by bugdroid1@chromium.org, Apr 5 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/aa4eb39704c572837d41258bdaf3a46a4c03ed27

commit aa4eb39704c572837d41258bdaf3a46a4c03ed27
Author: xunjieli <xunjieli@chromium.org>
Date: Wed Apr 05 15:27:05 2017

Reduce number of redundant map lookups in QuicStreamFactory::OnJobComplete

This CL reduces the number of redundant map lookups in
QuicStreamFactory::OnJobComplete.

BUG= 708260 

Review-Url: https://codereview.chromium.org/2797633003
Cr-Commit-Position: refs/heads/master@{#462076}

[modify] https://crrev.com/aa4eb39704c572837d41258bdaf3a46a4c03ed27/net/quic/chromium/quic_stream_factory.cc

Status: Fixed (was: Started)

Sign in to add a comment