Revision 3f622152102075c3973697da8c562c423b45cd81 authored by Andrew Kryczka on 19 November 2016, 00:54:09 UTC, committed by Facebook Github Bot on 19 November 2016, 01:09:11 UTC
Summary: Since a RangeDelAggregator is created for each read request, these heap-allocating member variables were consuming significant CPU (~3% total) which slowed down request throughput. The map and pinning manager are only necessary when range deletions exist, so we can defer their initialization until the first range deletion is encountered. Currently lazy initialization is done for reads only since reads pass us a single snapshot, which is easier to store on the stack for later insertion into the map than the vector passed to us by flush or compaction. Note the Arena member variable is still expensive, I will figure out what to do with it in a subsequent diff. It cannot be lazily initialized because we currently use this arena even to allocate empty iterators, which is necessary even when no range deletions exist. Closes https://github.com/facebook/rocksdb/pull/1539 Differential Revision: D4203488 Pulled By: ajkr fbshipit-source-id: 3b36279
1 parent 41e77b8
env_registry.cc
// Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
#ifndef ROCKSDB_LITE
#include "rocksdb/utilities/env_registry.h"
#include <map>
#include <string>
namespace rocksdb {
struct EnvRegistryEntry {
std::string prefix;
EnvFactoryFunc env_factory;
};
struct EnvRegistry {
static EnvRegistry* Get() {
static EnvRegistry instance;
return &instance;
}
std::vector<EnvRegistryEntry> entries;
private:
EnvRegistry() = default;
};
Env* NewEnvFromUri(const std::string& uri, std::unique_ptr<Env>* env_guard) {
env_guard->reset();
for (const auto& entry : EnvRegistry::Get()->entries) {
if (uri.compare(0, entry.prefix.size(), entry.prefix) == 0) {
return entry.env_factory(uri, env_guard);
}
}
return nullptr;
}
EnvRegistrar::EnvRegistrar(std::string uri_prefix, EnvFactoryFunc env_factory) {
EnvRegistry::Get()->entries.emplace_back(
EnvRegistryEntry{std::move(uri_prefix), std::move(env_factory)});
}
} // namespace rocksdb
#endif // ROCKSDB_LITE
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...