Skip to content

Commit

Permalink
small improvements to load tests and fix to block get implementation …
Browse files Browse the repository at this point in the history
…for new DVID
  • Loading branch information
Steve Plaza committed Apr 1, 2015
1 parent 3fa3ffd commit e92a3fc
Show file tree
Hide file tree
Showing 9 changed files with 250 additions and 269 deletions.
15 changes: 6 additions & 9 deletions libdvid/DVIDNodeService.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class DVIDNodeService {
*/
Labels3D get_labels3D(std::string datatype_instance, Dims_t dims,
std::vector<unsigned int> offset, bool throttle=true,
bool compress=false);
bool compress=true);

/*!
* Retrive a 3D 8-byte label volume with the specified
Expand All @@ -218,7 +218,7 @@ class DVIDNodeService {
Labels3D get_labels3D(std::string datatype_instance, Dims_t dims,
std::vector<unsigned int> offset,
std::vector<unsigned int> channels, bool throttle=true,
bool compress=false);
bool compress=true);

/*!
* Put a 3D 1-byte grayscale volume to DVID with the specified
Expand Down Expand Up @@ -262,7 +262,7 @@ class DVIDNodeService {
*/
void put_labels3D(std::string datatype_instance, Labels3D& volume,
std::vector<unsigned int> offset, bool throttle=true,
bool compress=false);
bool compress=true);

/************** API to access DVID blocks directly **************/
// This API is probably most relevant for bulk transfers to and
Expand All @@ -272,8 +272,7 @@ class DVIDNodeService {
* Fetch grayscale blocks from DVID. The call will fetch
* a series of contiguous blocks along the first dimension (X).
* The number of blocks fetched is encoded in the GrayscaleBlocks
* returned structure. This number can be less than the
* requested span if those blocks do not exist on DVID.
* returned structure.
* TODO: support compression and throttling.
* \param datatype instance name of grayscale type instance
* \param block_coords location of first block in span (block coordinates)
Expand All @@ -287,8 +286,7 @@ class DVIDNodeService {
* Fetch label blocks from DVID. The call will fetch
* a series of contiguous blocks along the first dimension (X).
* The number of blocks fetched is encoded in the LabelBlocks
* returned structure. This number can be less than the
* requested span if those blocks do not exist on DVID.
* returned structure.
* TODO: support compression and throttling.
* \param datatype instance name of labelblk type instance
* \param block_coords location of first block in span (block coordinates)
Expand Down Expand Up @@ -515,11 +513,10 @@ class DVIDNodeService {
* \param datatype_instance name of datatype instance
* \param block_coords starting block in DVID block coordinates
* \param span number of blocks to attempt to get
* \param return number of actual blocks retrieved
* \return binary data corresponding to an array of blocks
*/
BinaryDataPtr get_blocks(std::string datatype_instance,
std::vector<unsigned int> block_coords, int span, int& extracted_span);
std::vector<unsigned int> block_coords, int span);

/*!
* Helper to put blocks from DVID for labels and grayscale.
Expand Down
Binary file added load_tests/inputs/segmenation.binary.lz4
Binary file not shown.
30 changes: 15 additions & 15 deletions load_tests/loadtest_labelblk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
#include "ScopeTime.h"

#include <iostream>
#include <fstream>

using std::cerr; using std::cout; using std::endl;
using namespace libdvid;
using std::vector;
using std::ifstream;

using std::string;

Expand All @@ -31,11 +33,13 @@ int NUM_FETCHES = 100;
int SMALLFETCH = 128;

/*!
* Exercises the nD GETs and PUTs for the labelblk datatype.
* Exercises the nD GETs and PUTs for the labelblk datatype. Assume input
* binary is VOLDIMxVOLDIMxVOLDIM 64bit numbers compressed with lz4 (example
* in the inputs directory of a segmentation of an EM dataset with 8nm voxels).
*/
int main(int argc, char** argv)
{
if (argc != 2) {
if (argc != 3) {
cout << "Usage: <program> <server_name>" << endl;
return -1;
}
Expand All @@ -56,27 +60,23 @@ int main(int argc, char** argv)
return -1;
}

// ** Write and read labelblk data **
// create label 64 image volume
unsigned long long * img_labels = new unsigned long long [VOLDIM * VOLDIM * VOLDIM];
for (int i = 0; i < (VOLDIM*VOLDIM*VOLDIM); ++i) {
img_labels[i] = rand() % 1000000;
}

// create binary data string wrapper (64 bits per pixel)
// calculate time to post volume
{
Dims_t dims;
dims.push_back(VOLDIM); dims.push_back(VOLDIM); dims.push_back(VOLDIM);
Labels3D labelbin = Labels3D(img_labels,
VOLDIM * VOLDIM * VOLDIM, dims);
delete []img_labels;

// read a representative segmentation
ifstream fin(argv[2]);
BinaryDataPtr binary = BinaryData::create_binary_data(fin);
binary = BinaryData::decompress_lz4(binary, VOLDIM*VOLDIM*VOLDIM*sizeof(uint64));
Labels3D labelbin = Labels3D(binary, dims);

vector<unsigned int> start;
start.push_back(0); start.push_back(0); start.push_back(0);

ScopeTime post_timer(false);
dvid_node.put_labels3D(label_datatype_name, labelbin, start);
dvid_node.put_labels3D(label_datatype_name, labelbin, start, true, true);
double post_time = post_timer.getElapsed();
cout << "Time to POST large label volume: " << post_time << " seconds" << endl;
cout << int(VOLDIM * VOLDIM * VOLDIM * sizeof(unsigned long long) / post_time)
Expand All @@ -92,7 +92,7 @@ int main(int argc, char** argv)
lsizes.push_back(VOLDIM); lsizes.push_back(VOLDIM); lsizes.push_back(VOLDIM);

ScopeTime get_timer(false);
Labels3D labelcomp = dvid_node.get_labels3D(label_datatype_name, lsizes, start);
Labels3D labelcomp = dvid_node.get_labels3D(label_datatype_name, lsizes, start, true, true);
double read_time = get_timer.getElapsed();
cout << "Time to GET large label volume: " << read_time << " seconds" << endl;
cout << int(VOLDIM * VOLDIM * VOLDIM * sizeof(unsigned long long)/ read_time)
Expand All @@ -116,7 +116,7 @@ int main(int argc, char** argv)
lsizes.push_back(SMALLFETCH);

Labels3D labelcomp =
dvid_node.get_labels3D(label_datatype_name, lsizes, start);
dvid_node.get_labels3D(label_datatype_name, lsizes, start, true, true);

double read_time = get_timer.getElapsed();
cout << "Time to GET small label volume: " << read_time << " seconds" << endl;
Expand Down
114 changes: 0 additions & 114 deletions load_tests/results/labelblk.emdata1.results

This file was deleted.

Loading

0 comments on commit e92a3fc

Please sign in to comment.