Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
140 commits
Select commit Hold shift + click to select a range
a3789a6
feat: add header file for simulated transport implementation
agnesnatasya Oct 19, 2021
18471c9
feat: add example config file for testing environment
agnesnatasya Oct 19, 2021
d3ae959
feat: add notes for current branch implementation
agnesnatasya Oct 19, 2021
3b6a1f7
feat: add interpretation
agnesnatasya Oct 20, 2021
6fc33c5
refactor: create main to call server, rename original main to test
agnesnatasya Oct 20, 2021
5c2de58
feat: add isDev flags as argument, as a method to choose transport me…
agnesnatasya Oct 20, 2021
09fa87b
feat: add suggestion for FastTransport constructor
agnesnatasya Oct 20, 2021
1beb441
feat: create file to define custom types
agnesnatasya Oct 20, 2021
6792242
feat: add SimRpc and SimAppContext as properties of simulated transport
agnesnatasya Oct 20, 2021
fe15a1f
feat: initial implementation of SimTransport
agnesnatasya Oct 20, 2021
92d8d92
feat: add conditional var for compilation
agnesnatasya Oct 20, 2021
bb75238
feat: add IS_DEV precompiler directive
agnesnatasya Oct 20, 2021
1ecdaed
fix: method name fix
agnesnatasya Oct 20, 2021
1d8af26
feat: define IS_DEV directive in Makefile
agnesnatasya Oct 20, 2021
64d7bbc
feat: change eRPC path if IS_DEV
agnesnatasya Oct 20, 2021
40fa295
fix: remove IS_DEV redef
agnesnatasya Oct 20, 2021
cc9bbde
feat: change file included in network compilation
agnesnatasya Oct 20, 2021
ecc02ee
feat: change obj included in network compilation
agnesnatasya Oct 20, 2021
f6e545c
fix: compilation error
agnesnatasya Oct 20, 2021
9543213
fix: compilation error
agnesnatasya Oct 20, 2021
2e45702
fix: compilation error
agnesnatasya Oct 20, 2021
dbc2cdc
fix: compilation error
agnesnatasya Oct 20, 2021
4fe9909
fix: compilation error
agnesnatasya Oct 20, 2021
e509bb7
feat: remove import guard from simtransport.cpp
agnesnatasya Oct 20, 2021
f90b293
fix: import sequence
agnesnatasya Oct 20, 2021
94c93bf
feat: remove undeclared types
agnesnatasya Oct 20, 2021
dbfe76d
fix: remove client boilerplate code
agnesnatasya Oct 20, 2021
cc06a1e
feat: move sim_req_tag_t to be inside network namespace
agnesnatasya Oct 20, 2021
abcafcf
fix: remove parsing command line args
agnesnatasya Oct 20, 2021
7d97b88
fix: semicolon after class
agnesnatasya Oct 20, 2021
e44d05d
feat: add linker to gflags
agnesnatasya Oct 20, 2021
e2aaf98
Merge branch 'simulated-transport' of https://github.com/agnesnatasya…
agnesnatasya Oct 20, 2021
e389eb8
feat: add ldl flags
agnesnatasya Oct 20, 2021
5249c5c
feat: add ibverbs flags
agnesnatasya Oct 20, 2021
c2ee0f1
fix: flag type
agnesnatasya Oct 21, 2021
0e19704
feat: remove server's dependency to eRPC
agnesnatasya Oct 21, 2021
bd07e2d
fix: import logic
agnesnatasya Oct 21, 2021
534b9e0
feat: remove 1 args from server thread
agnesnatasya Oct 21, 2021
4bb1255
fix: argument passing to server's thread
agnesnatasya Oct 21, 2021
aeb5da5
feat: add transport init in server
agnesnatasya Oct 21, 2021
610473d
refactor: SimulatedTransport to SimTransport
agnesnatasya Oct 21, 2021
cb44428
fix: constructor params in SimTransport header
agnesnatasya Oct 21, 2021
ad1676f
fix: Simtransport constructor
agnesnatasya Oct 21, 2021
4280653
feat: add SimTransport init in servr
agnesnatasya Oct 21, 2021
e211a2c
feat: add debugging statement
agnesnatasya Oct 21, 2021
2f30167
fix: constructor
agnesnatasya Oct 21, 2021
1fe5537
feat: use network namespace
agnesnatasya Oct 21, 2021
e46b0bc
feat: set paranoid flag
agnesnatasya Oct 21, 2021
e98e91c
feat: comment
agnesnatasya Oct 21, 2021
9971100
feat: comment
agnesnatasya Oct 21, 2021
8123b09
fix: namespace
agnesnatasya Oct 21, 2021
a86f1c7
fix: namespace
agnesnatasya Oct 21, 2021
b6ae0a9
fix: namespace
agnesnatasya Oct 21, 2021
f71057c
fix: namespace
agnesnatasya Oct 21, 2021
df25630
fix: namespace
agnesnatasya Oct 21, 2021
ff0a044
fix: namespace
agnesnatasya Oct 21, 2021
e96b5ea
feat: remove namespace network from SimTransport
agnesnatasya Oct 21, 2021
8620e33
feat: add namespace back
agnesnatasya Oct 21, 2021
16aa2fb
fix:namespace
agnesnatasya Oct 21, 2021
f1fa6ea
fix: namespace
agnesnatasya Oct 21, 2021
f5e27e8
fix: namespace
agnesnatasya Oct 21, 2021
7844da8
fix: linker and deps in Make
agnesnatasya Oct 21, 2021
81bdbf2
fix: simtransport compile error
agnesnatasya Oct 21, 2021
640869c
fix: simtransport compile error
agnesnatasya Oct 21, 2021
59331a6
fix: simtransport compile error
agnesnatasya Oct 21, 2021
799be0d
fix: simtransport compile error
agnesnatasya Oct 21, 2021
b6833cc
fix: simtransport compile error
agnesnatasya Oct 21, 2021
e3d7e34
refactor: remove debug
agnesnatasya Oct 21, 2021
82bf994
fix: init SimRpc
agnesnatasya Oct 21, 2021
301d0f2
refactor: remove print
agnesnatasya Oct 21, 2021
470e244
feat: initialise client
agnesnatasya Oct 21, 2021
4937d25
fix: initialise client
agnesnatasya Oct 21, 2021
5b827dc
fix: initialise client
agnesnatasya Oct 21, 2021
27e83fa
fix: initialise client
agnesnatasya Oct 21, 2021
f08f37e
fix: initialise client
agnesnatasya Oct 21, 2021
5d5a67b
fix: initialise client
agnesnatasya Oct 21, 2021
fddb035
fix: initialise client
agnesnatasya Oct 21, 2021
c46c2b9
fix: callback server client
agnesnatasya Oct 21, 2021
ef30bb9
fix: callback server client
agnesnatasya Oct 21, 2021
0af0eaa
fix: callback server client
agnesnatasya Oct 21, 2021
1cc0a96
fix: callback server client
agnesnatasya Oct 21, 2021
e626da8
fix: callback server client
agnesnatasya Oct 21, 2021
832f051
fix: callback server client
agnesnatasya Oct 21, 2021
3856c47
fix: callback server client
agnesnatasya Oct 21, 2021
0cd248b
refactor: remove print
agnesnatasya Oct 21, 2021
73a2de5
feat: move the compiler directive includion in the compile level
agnesnatasya Oct 22, 2021
e2f17a9
feat: add test driver and Makefile
agnesnatasya Oct 22, 2021
c2251b4
fix: comment
agnesnatasya Oct 22, 2021
bacfa6b
fix: typo
agnesnatasya Oct 22, 2021
e99e927
fix: variable
agnesnatasya Oct 22, 2021
23f5588
feat: add conditional directive to linker of clients and main object
agnesnatasya Oct 22, 2021
d52d0d9
feat: add conditional directive to linker of clients and main object
agnesnatasya Oct 22, 2021
d6ca7c5
feat: remove client and server from binary
agnesnatasya Oct 22, 2021
32517e0
feat: add test bin
agnesnatasya Oct 22, 2021
ae3fa6f
feat: debug Makefile
agnesnatasya Oct 22, 2021
94057c4
feat: debug Makefile
agnesnatasya Oct 22, 2021
d39264f
feat: debug Makefile
agnesnatasya Oct 22, 2021
73e3871
feat: debug Makefile
agnesnatasya Oct 22, 2021
4f94b20
feat: debug Makefile
agnesnatasya Oct 22, 2021
9e89168
feat: debug Makefile
agnesnatasya Oct 22, 2021
d8c0012
feat: remove gtest
agnesnatasya Oct 22, 2021
7436486
feat: change dir to benchmark
agnesnatasya Oct 22, 2021
a9bba4e
feat: include test in the Makefile
agnesnatasya Oct 22, 2021
836ee6b
refactor: test to simulation
agnesnatasya Oct 22, 2021
48675c4
feat: add obj storage client
agnesnatasya Oct 22, 2021
1b3532c
fix: import
agnesnatasya Oct 22, 2021
9e2200b
feat: add bins
agnesnatasya Oct 22, 2021
2b50d33
feat: remove fasttranport from simulation maek
agnesnatasya Oct 22, 2021
4459d0a
feat: remove test src
agnesnatasya Oct 22, 2021
f8cbb93
fix: dependencies in Makefile
agnesnatasya Oct 22, 2021
b64b575
feat: make new rule for simulation
agnesnatasya Oct 22, 2021
598ff4a
feat: add SIM_BINS to linking
agnesnatasya Oct 22, 2021
def540a
feat: add linking to SIM_BINS
agnesnatasya Oct 22, 2021
129342e
feat: add SIM_SRCS
agnesnatasya Oct 22, 2021
ef17287
fix: src in SIM_SRCS
agnesnatasya Oct 22, 2021
4fcab38
fix: Makefile syntax
agnesnatasya Oct 22, 2021
53e9e0f
feat: remove IS_DEV directives
agnesnatasya Oct 22, 2021
216d49f
feat: change config file name
agnesnatasya Oct 23, 2021
f2666e6
feat: add main driver thread for simulation
agnesnatasya Oct 23, 2021
c6f96ad
feat: block on client sending request to server
agnesnatasya Oct 30, 2021
8f8356b
feat: add notes
agnesnatasya Oct 30, 2021
e5e5e8c
fix: increase current id during instantiation of server app
agnesnatasya Oct 30, 2021
0f86225
fix: segfault because processing after the reequest turned to null
agnesnatasya Oct 30, 2021
1f83aa8
feat: change back the request type constant declaration
agnesnatasya Oct 30, 2021
e4b99a2
feat: add dummy configuration
agnesnatasya Oct 30, 2021
1443bac
feat: remove unecessary io
agnesnatasya Oct 30, 2021
cc510d3
feat: add gitignore for binaries and objects
agnesnatasya Oct 30, 2021
df4a9d2
feat: add inline comment from meeting
agnesnatasya Nov 3, 2021
c767ece
feat: does not need to wait for client to finish
agnesnatasya Nov 3, 2021
0dbe6e5
feat: change multithread control to server
agnesnatasya Nov 8, 2021
afb78e2
feat: change the transport object to be shared among all client and s…
agnesnatasya Nov 8, 2021
01597dd
feat: add packages to be installed
agnesnatasya Nov 8, 2021
2424e67
refactor: remove debugging statements
agnesnatasya Nov 29, 2021
dd19d89
feat: enable configuration of number of client and server thread thro…
agnesnatasya Dec 13, 2021
33a58dc
feat: add documentation and diagram
agnesnatasya Dec 13, 2021
542aca6
refactor: remove NOTES.md
agnesnatasya Dec 13, 2021
3e8288a
Merge branch 'master' of https://github.com/aaasz/Be-Tree into simtra…
agnesnatasya Dec 13, 2021
564048a
feat: remove unneccessary changes to production implementation
agnesnatasya Dec 14, 2021
082849f
fix: Makefile reconfiguration for 2 build configurations
agnesnatasya Dec 14, 2021
14f069a
feat: change client and server's thread task to remove memory consist…
agnesnatasya Dec 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.obj/
client/client
server/server
simulation/simulation
NOTES.md
47 changes: 30 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ CXX = g++
LD = g++
EXPAND = lib/tmpl/expand

ERPC_PATH= "./third_party/eRPC"

#ERPC_CFLAGS_RAW := -I $(ERPC_PATH)/src -DRAW=true
#ERPC_LDFLAGS_RAW := -L $(ERPC_PATH)/build -lerpc -lnuma -ldl -lgflags -libverbs

DPDK_LIBS := $(shell pkg-config --libs libdpdk)
DPDK_CFLAGS := $(shell pkg-config --cflags libdpdk)
ERPC_CFLAGS_DPDK := -I $(ERPC_PATH)/src -I $(ERPC_PATH)/third_party/asio/include $(DPDK_CFLAGS) -DERPC_DPDK=true -march=native
ERPC_LDFLAGS_DPDK := -L $(ERPC_PATH)/build -lerpc -lnuma -ldl -lgflags -libverbs -lmlx4 -lmlx5 $(DPDK_LIBS)

CFLAGS_WARNINGS:= -Wno-unused-function -Wno-nested-anon-types -Wno-keyword-macro -Wno-uninitialized

# -fno-omit-frame-pointer is needed to get accurate flame graphs. See [1] for
Expand All @@ -27,9 +17,11 @@ CFLAGS := -g -Wall $(CFLAGS_WARNINGS) -iquote.obj/gen -O2 -DNASSERT -fno-omit-fr
CXXFLAGS := -g -std=c++11
LDFLAGS := -levent_pthreads -pthread -lboost_fiber -lboost_context -lboost_system -lboost_thread

## Add ERPC flags ##
CFLAGS += $(ERPC_CFLAGS_DPDK)
LDFLAGS += $(ERPC_LDFLAGS_DPDK)
## Add RPC flags ##
RPC_CFLAGS :=
RPC_LDFLAGS := -ldl -lgflags -libverbs
CFLAGS += $(RPC_CFLAGS)
LDFLAGS += $(RPC_LDFLAGS)

## Debian package: check ##
#CHECK_CFLAGS := $(shell pkg-config --cflags check)
Expand Down Expand Up @@ -113,6 +105,9 @@ SRCS :=
# TEST_SRCS is just like SRCS, but these source files will be compiled
# with testing related flags.
TEST_SRCS :=
# SIM_SRCS is just like SRCS, but these source files will be compiled
# with simulation related flags.
SIM_SRCS :=
# GTEST_SRCS is tests that use Google's testing framework
GTEST_SRCS :=

Expand All @@ -127,6 +122,12 @@ BINS :=
# using the appropriate flags. This is also used as the list of tests
# to run for the `test' target.
TEST_BINS :=
# SIM_BINS is like BINS, but for simulation binaries. They will be linked
# using the appropriate flags. This is also used as the list of tests
# to run for the `sim` target.
# It is similar to test that it uses simulated tranpsort, but you can also
# provide manual inputs to it, as contrast to test
SIM_BINS :=

# add-CFLAGS is a utility macro that takes a space-separated list of
# sources and a set of CFLAGS. It sets the CFLAGS for each provided
Expand All @@ -147,6 +148,7 @@ include debug/Rules.mk
include network/Rules.mk
include client/Rules.mk
include server/Rules.mk
include simulation/Rules.mk
#include replication/common/Rules.mk
#include replication/meerkatir/Rules.mk
#include replication/leadermeerkatir/Rules.mk
Expand Down Expand Up @@ -181,7 +183,7 @@ include server/Rules.mk
DEPFLAGS = -M -MF ${@:.o=.d} -MP -MT $@ -MG

# $(call add-CFLAGS,$(TEST_SRCS),$(CHECK_CFLAGS))
OBJS := $(SRCS:%.cpp=.obj/%.o) $(TEST_SRCS:%.cpp=.obj/%.o) $(GTEST_SRCS:%.cpp=.obj/%.o)
OBJS := $(SRCS:%.cpp=.obj/%.o) $(TEST_SRCS:%.cpp=.obj/%.o) $(GTEST_SRCS:%.cpp=.obj/%.o) $(SIM_SRCS:%.cpp=.obj/%.o)

define compile
@mkdir -p $(dir $@)
Expand Down Expand Up @@ -223,8 +225,9 @@ $(PROTOOBJS:%.o=%-pic.o): .obj/%-pic.o: .obj/gen/%.pb.cc $(PROTOSRCS)
#

$(call add-LDFLAGS,$(TEST_BINS),$(CHECK_LDFLAGS))
$(call add-LDFLAGS,$(SIM_BINS),$(CHECK_LDFLAGS))

$(BINS) $(TEST_BINS): %:
$(BINS) $(TEST_BINS) $(SIM_BINS): %:
$(call trace,LD,$@,$(LD) -o $@ $^ $(LDFLAGS) $(LDFLAGS-$@))

#
Expand Down Expand Up @@ -256,7 +259,7 @@ $(GTEST_MAIN) : .obj/gtest/gtest-all.o .obj/gtest/gtest_main.o

.PHONY: clean
clean:
$(call trace,RM,binaries,rm -f $(BINS) $(TEST_BINS))
$(call trace,RM,binaries,rm -f $(BINS) $(TEST_BINS) $(SIM_BINS))
$(call trace,RM,objects,rm -rf .obj)

#
Expand All @@ -270,16 +273,26 @@ print-%:
#

.PHONY: all
all: $(BINS)
all:
ERPC_PATH= "./third_party/eRPC"
DPDK_LIBS := $(shell pkg-config --libs libdpdk)
DPDK_CFLAGS := $(shell pkg-config --cflags libdpdk)
RPC_CFLAGS := -I $(ERPC_PATH)/src -I $(ERPC_PATH)/third_party/asio/include $(DPDK_CFLAGS) -DERPC_DPDK=true -march=native
RPC_LDFLAGS := -L $(ERPC_PATH)/build -lerpc -lnuma -ldl -lgflags -libverbs -lmlx4 -lmlx5 $(DPDK_LIBS)
$(BINS)

$(TEST_BINS:%=run-%): run-%: %
$(call trace,RUN,$<,$<)

$(TEST_BINS:%=gdb-%): gdb-%: %
$(call trace,GDB,$<,CK_FORK=no gdb $<)

.PHONY: simulation
simulation: $(SIM_BINS)

.PHONY: test
test: $(TEST_BINS:%=run-%)

.PHONY: check
check: test

Expand Down
88 changes: 88 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,90 @@
# Be-Tree
A simple, reference implementation of a B^e-tree

## Environments
There are 3 different environments to run the implementation:
* Production
* Simulation
* Testing

### Production Environment
The production environment is used on production. The RPC implementation of this envrionment uses eRPC. To be able to run on this environment, you need to build the eRPC, that is located under `third_party/eRPC` directory.

**Ubuntu Prerequisites**
1. This implementation is tested and supported on Ubuntu OS.
2. Install the necessary Ubuntu packages to be able to run the implementation
```
sudo apt install make
sudo apt install cmake
sudo apt install libssl-dev
sudo apt install libevent-dev
sudo apt install libboost-all-dev
sudo apt install libgtest-dev
sudo apt-get install libgflags-dev
sudo apt-get install libgoogle-glog-dev
sudo apt install g++
sudo apt-get install -y pkg-config
```

**Setup**
1. Setup and do the necessary installations of the Ubuntu environment as specified above
2. Build eRPC. For instructions to build eRPC, refer to the `third_party/eRPC` directory.
2. Do `make` to compile and build the code
3. Do `./client/client` for the client machine to run the client code
4. Do `./server/server --configFile==<config file name> --serverIndex==<intended index of the server>`
* An example configuration file is the file `config.txt` in the root directory. In this configuration file, there are 1 server spawned on one machine. In this example file,
* Server index 0 indicates that this server instance will occupy the port 38450
5. Enter the file system operations from the client side as needed.

### Simulation Environment
The simulation environment tries to simulate the production environment and hence is similar to the production environment. The interactivity and custom input ability of file system operations should be maintained for this environment.

**Implementation Details**

The main difference between this environment and the production environment is that it does not use the eRPC library, it simulates the transportation of message between the client and the server using a 'simulated transportation'.

In the 'simulated transportation' implementation, there is a single transport object that is shared between the client and the server. Since the client and the server is actually located in the same runtime environment, the transport object is shared using variable sharing.

The image below illustrates the difference between the production and simulation environment.

![](assets/environment-comparison.png)

In this environment,
* the number of server threads
* the number of client threads
* all requests from all clients will always be directed to one of the server threads throughout the whole simulation. Hence, there is actually no need to spawn more than one server threads.
* all requests from all clients will be handled one-by-one by that single server thread. Hence, it is not suitable for benchmarking.

**Ubuntu Prerequisites**

1. This implementation is tested and supported on Ubuntu OS.
2. Install the necessary Ubuntu packages to be able to run the implementation
```
sudo apt install make
sudo apt install cmake
sudo apt install libssl-dev
sudo apt install libevent-dev
sudo apt install libboost-all-dev
sudo apt install libgtest-dev
sudo apt-get install libgflags-dev
sudo apt-get install libgoogle-glog-dev
sudo apt install g++
sudo apt-get install -y pkg-config
```

**Setup**

1. Do `make simulation` to compile and build the simulation code.
2. Do `./simulation/simulation [--numClientThreadsSim=<number of client threads intended> --numServerThreadsSim=<number of server threads intended>` to run both the server and the client code.
* You can optionally specify the number of server threads or number of client threads to be spawned in this simulation environment. If these are not specified, its value will be defaulted to 1.
3. Enter the file system operation as needed.

### Testing Environment
The testing environment is for the purpose of testing the correctness of the implementation. There is no user input expected as the file system operations and its expected output has been defined beforehand.

This environment is not yet implemented at the moment.

## APIs
The APIs that are currently supported by the server are:
* `GetNodeId`
* This returns the ID of the node of the server applications in the server that it resides. A single server can have multiple sever applications
Binary file added assets/environment-comparison.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/storage_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//#include <sys/time.h>
//#include <math.h>

#include <cstring>
#include <random>
using namespace std;

Expand Down
2 changes: 1 addition & 1 deletion client/storage_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#ifndef _STORAGE_CLIENT_H_
#define _STORAGE_CLIENT_H_

#include "network/fasttransport.hpp"
#include "network/configuration.hpp"
#include "network/transport.hpp"

struct nodeid_t {
uint32_t serverIdx;
Expand Down
2 changes: 2 additions & 0 deletions common/gflags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

// Defines all the command line flags shared between both
// severs and clients
DEFINE_uint32(numServerThreadsSim, 1, "The number of server threads in the simulation environment");
DEFINE_uint32(numClientThreadsSim, 1, "The number of client threads in the simulation environment");
DEFINE_string(configFile, "", "Path to the configuration file");
DEFINE_string(backingStoreDir, "", "Path to the backing store directory");
DEFINE_string(benchmark, "", "Benchmark mode (benchmark-<mode>, mode = upserts|queries)");
Expand Down
4 changes: 3 additions & 1 deletion network/Rules.mk
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
d := $(dir $(lastword $(MAKEFILE_LIST)))

SRCS += $(addprefix $(d), transport.cpp fasttransport.cpp configuration.cpp)
SRCS += $(addprefix $(d), transport.cpp simtransport.cpp fasttransport.cpp configuration.cpp)

LIB-configuration := $(o)configuration.o $(LIB-debug)

LIB-transport := $(o)transport.o $(LIB-configuration) $(LIB-debug)

LIB-fasttransport := $(o)fasttransport.o $(LIB-transport) $(LIB-debug)

LIB-simtransport := $(LIB-transport) $(LIB-debug) $(o)simtransport.o
29 changes: 29 additions & 0 deletions network/app_mem_pool.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// A basic mempool for preallocated objects of type T. eRPC has a faster,
// hugepage-backed one.
template <class T> class AppMemPool {
public:
size_t num_to_alloc = 1;
std::vector<T *> backing_ptr_vec;
std::vector<T *> pool;

void extend_pool() {
T *backing_ptr = new T[num_to_alloc];
for (size_t i = 0; i < num_to_alloc; i++) pool.push_back(&backing_ptr[i]);
backing_ptr_vec.push_back(backing_ptr);
num_to_alloc *= 2;
}

T *alloc() {
if (pool.empty()) extend_pool();
T *ret = pool.back();
pool.pop_back();
return ret;
}

void free(T *t) { pool.push_back(t); }

AppMemPool() {}
~AppMemPool() {
for (T *ptr : backing_ptr_vec) delete[] ptr;
}
};
5 changes: 5 additions & 0 deletions network/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ ServerAddress::operator<(const ServerAddress &other) const {
return this_t < other_t;
}

Configuration::Configuration() {
multicastAddress = new ServerAddress("", "");
n = 1;
}

Configuration::Configuration(const Configuration &c)
: n(c.n), servers(c.servers), hasMulticast(c.hasMulticast)
{
Expand Down
4 changes: 4 additions & 0 deletions network/configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ struct ServerAddress
class Configuration
{
public:
/* Empty constructor for dummy configuration in simulation environment */
Configuration();

/* Non-empty constructors for real configuration */
Configuration(const Configuration &c);
Configuration(int n,
// int f,
Expand Down
31 changes: 1 addition & 30 deletions network/fasttransport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,36 +56,6 @@ struct req_tag_t {
TransportReceiver *src;
};

// A basic mempool for preallocated objects of type T. eRPC has a faster,
// hugepage-backed one.
template <class T> class AppMemPool {
public:
size_t num_to_alloc = 1;
std::vector<T *> backing_ptr_vec;
std::vector<T *> pool;

void extend_pool() {
T *backing_ptr = new T[num_to_alloc];
for (size_t i = 0; i < num_to_alloc; i++) pool.push_back(&backing_ptr[i]);
backing_ptr_vec.push_back(backing_ptr);
num_to_alloc *= 2;
}

T *alloc() {
if (pool.empty()) extend_pool();
T *ret = pool.back();
pool.pop_back();
return ret;
}

void free(T *t) { pool.push_back(t); }

AppMemPool() {}
~AppMemPool() {
for (T *ptr : backing_ptr_vec) delete[] ptr;
}
};

// eRPC context passed between request and responses
class AppContext {
public:
Expand Down Expand Up @@ -118,6 +88,7 @@ class AppContext {
class FastTransport : public Transport
{
public:
// TODO: I think we can remove the ip and phy_port argument here since we can get it from config?
FastTransport(const network::Configuration &config,
std::string &ip,
int nthreads,
Expand Down
Loading