@@ -905,21 +905,20 @@ class PlasmaStoreRunner {
905
905
PlasmaStoreRunner () {}
906
906
907
907
void Start (char * socket_name, int64_t system_memory, std::string directory,
908
- bool hugepages_enabled, bool use_one_memory_mapped_file ) {
908
+ bool hugepages_enabled) {
909
909
// Create the event loop.
910
910
loop_.reset (new EventLoop);
911
911
store_.reset (
912
912
new PlasmaStore (loop_.get (), system_memory, directory, hugepages_enabled));
913
913
plasma_config = store_->GetPlasmaStoreInfo ();
914
914
915
- // If the store is configured to use a single memory-mapped file, then we
916
- // achieve that by mallocing and freeing a single large amount of space.
917
- // that maximum allowed size up front.
918
- if (use_one_memory_mapped_file) {
919
- void * pointer = plasma::dlmemalign (kBlockSize , system_memory);
920
- ARROW_CHECK (pointer != nullptr );
921
- plasma::dlfree (pointer);
922
- }
915
+ // We are using a single memory-mapped file by mallocing and freeing a single
916
+ // large amount of space up front. According to the documentation,
917
+ // dlmalloc might need up to 128*sizeof(size_t) bytes for internal
918
+ // bookkeeping.
919
+ void * pointer = plasma::dlmemalign (kBlockSize , system_memory - 128 * sizeof (size_t ));
920
+ ARROW_CHECK (pointer != nullptr );
921
+ plasma::dlfree (pointer);
923
922
924
923
int socket = BindIpcSock (socket_name, true );
925
924
// TODO(pcm): Check return value.
@@ -955,15 +954,14 @@ void HandleSignal(int signal) {
955
954
}
956
955
957
956
void StartServer (char * socket_name, int64_t system_memory, std::string plasma_directory,
958
- bool hugepages_enabled, bool use_one_memory_mapped_file ) {
957
+ bool hugepages_enabled) {
959
958
// Ignore SIGPIPE signals. If we don't do this, then when we attempt to write
960
959
// to a client that has already died, the store could die.
961
960
signal (SIGPIPE, SIG_IGN);
962
961
963
962
g_runner.reset (new PlasmaStoreRunner ());
964
963
signal (SIGTERM, HandleSignal);
965
- g_runner->Start (socket_name, system_memory, plasma_directory, hugepages_enabled,
966
- use_one_memory_mapped_file);
964
+ g_runner->Start (socket_name, system_memory, plasma_directory, hugepages_enabled);
967
965
}
968
966
969
967
} // namespace plasma
@@ -975,8 +973,6 @@ int main(int argc, char* argv[]) {
975
973
// Directory where plasma memory mapped files are stored.
976
974
std::string plasma_directory;
977
975
bool hugepages_enabled = false ;
978
- // True if a single large memory-mapped file should be created at startup.
979
- bool use_one_memory_mapped_file = false ;
980
976
int64_t system_memory = -1 ;
981
977
int c;
982
978
while ((c = getopt (argc, argv, " s:m:d:hf" )) != -1 ) {
@@ -994,13 +990,16 @@ int main(int argc, char* argv[]) {
994
990
char extra;
995
991
int scanned = sscanf (optarg, " %" SCNd64 " %c" , &system_memory, &extra);
996
992
ARROW_CHECK (scanned == 1 );
993
+ // Set system memory, potentially rounding it to a page size
994
+ // Also make it so dlmalloc fails if we try to request more memory than
995
+ // is available.
996
+ system_memory = plasma::dlmalloc_set_footprint_limit ((size_t )system_memory);
997
997
ARROW_LOG (INFO) << " Allowing the Plasma store to use up to "
998
998
<< static_cast <double >(system_memory) / 1000000000
999
999
<< " GB of memory." ;
1000
1000
break ;
1001
1001
}
1002
1002
case ' f' :
1003
- use_one_memory_mapped_file = true ;
1004
1003
break ;
1005
1004
default :
1006
1005
exit (-1 );
@@ -1051,12 +1050,8 @@ int main(int argc, char* argv[]) {
1051
1050
SetMallocGranularity (1024 * 1024 * 1024 ); // 1 GB
1052
1051
}
1053
1052
#endif
1054
- // Make it so dlmalloc fails if we try to request more memory than is
1055
- // available.
1056
- plasma::dlmalloc_set_footprint_limit ((size_t )system_memory);
1057
1053
ARROW_LOG (DEBUG) << " starting server listening on " << socket_name;
1058
- plasma::StartServer (socket_name, system_memory, plasma_directory, hugepages_enabled,
1059
- use_one_memory_mapped_file);
1054
+ plasma::StartServer (socket_name, system_memory, plasma_directory, hugepages_enabled);
1060
1055
plasma::g_runner->Shutdown ();
1061
1056
plasma::g_runner = nullptr ;
1062
1057
0 commit comments