Skip to content

Commit

Permalink
Merge pull request monero-project#8 from fourschaft/master
Browse files Browse the repository at this point in the history
Increased thread stack size on OSX
  • Loading branch information
amjuarez committed Apr 30, 2014
2 parents a57f4fc + c9be942 commit 25d3389
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 12 deletions.
4 changes: 2 additions & 2 deletions contrib/epee/include/net/abstract_tcp_server2.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ namespace net_utils
bool init_server(const std::string port, const std::string& address = "0.0.0.0");

/// Run the server's io_service loop.
bool run_server(size_t threads_count, bool wait = true);
bool run_server(size_t threads_count, bool wait = true, const boost::thread::attributes& attrs = boost::thread::attributes());

/// wait for service workers stop
bool timed_wait_server_stop(uint64_t wait_mseconds);
Expand Down Expand Up @@ -273,4 +273,4 @@ namespace net_utils

#include "abstract_tcp_server2.inl"

#endif
#endif
4 changes: 2 additions & 2 deletions contrib/epee/include/net/abstract_tcp_server2.inl
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ POP_WARNINGS
}
//---------------------------------------------------------------------------------
template<class t_protocol_handler>
bool boosted_tcp_server<t_protocol_handler>::run_server(size_t threads_count, bool wait)
bool boosted_tcp_server<t_protocol_handler>::run_server(size_t threads_count, bool wait, const boost::thread::attributes& attrs)
{
TRY_ENTRY();
m_threads_count = threads_count;
Expand All @@ -538,7 +538,7 @@ POP_WARNINGS
for (std::size_t i = 0; i < threads_count; ++i)
{
boost::shared_ptr<boost::thread> thread(new boost::thread(
boost::bind(&boosted_tcp_server<t_protocol_handler>::worker_thread, this)));
attrs, boost::bind(&boosted_tcp_server<t_protocol_handler>::worker_thread, this)));
m_threads.push_back(thread);
}
CRITICAL_REGION_END();
Expand Down
2 changes: 1 addition & 1 deletion src/cryptonote_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,5 @@
#define P2P_NET_DATA_FILENAME "p2pstate.bin"
#define MINER_CONFIG_FILE_NAME "miner_conf.json"


#define THREAD_STACK_SIZE 5 * 1024 * 1024

11 changes: 8 additions & 3 deletions src/cryptonote_core/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ namespace cryptonote
return !m_stop;
}
//-----------------------------------------------------------------------------------------------------
bool miner::start(const account_public_address& adr, size_t threads_count)
bool miner::start(const account_public_address& adr, size_t threads_count, const boost::thread::attributes& attrs)
{
m_mine_address = adr;
m_threads_total = static_cast<uint32_t>(threads_count);
Expand All @@ -218,7 +218,9 @@ namespace cryptonote
boost::interprocess::ipcdetail::atomic_write32(&m_thread_index, 0);

for(size_t i = 0; i != threads_count; i++)
m_threads.push_back(boost::thread(boost::bind(&miner::worker_thread, this)));
{
m_threads.push_back(boost::thread(attrs, boost::bind(&miner::worker_thread, this)));
}

LOG_PRINT_L0("Mining has started with " << threads_count << " threads, good luck!" )
return true;
Expand Down Expand Up @@ -269,7 +271,10 @@ namespace cryptonote
{
if(m_do_mining)
{
start(m_mine_address, m_threads_total);
boost::thread::attributes attrs;
attrs.set_stack_size(THREAD_STACK_SIZE);

start(m_mine_address, m_threads_total, attrs);
}
}
//-----------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/cryptonote_core/miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace cryptonote
static void init_options(boost::program_options::options_description& desc);
bool set_block_template(const block& bl, const difficulty_type& diffic, uint64_t height);
bool on_block_chain_update();
bool start(const account_public_address& adr, size_t threads_count);
bool start(const account_public_address& adr, size_t threads_count, const boost::thread::attributes& attrs);
uint64_t get_speed();
void send_stop_signal();
bool stop();
Expand Down
5 changes: 4 additions & 1 deletion src/daemon/daemon_commands_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,10 @@ class daemon_cmmands_handler
threads_count = (ok && 0 < threads_count) ? threads_count : 1;
}

m_srv.get_payload_object().get_core().get_miner().start(adr, threads_count);
boost::thread::attributes attrs;
attrs.set_stack_size(THREAD_STACK_SIZE);

m_srv.get_payload_object().get_core().get_miner().start(adr, threads_count, attrs);
return true;
}
//--------------------------------------------------------------------------------
Expand Down
5 changes: 4 additions & 1 deletion src/p2p/net_node.inl
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,12 @@ namespace nodetool
m_net_server.add_idle_handler(boost::bind(&node_server<t_payload_net_handler>::idle_worker, this), 1000);
m_net_server.add_idle_handler(boost::bind(&t_payload_net_handler::on_idle, &m_payload_handler), 1000);

boost::thread::attributes attrs;
attrs.set_stack_size(THREAD_STACK_SIZE);

//go to loop
LOG_PRINT("Run net_service loop( " << thrds_count << " threads)...", LOG_LEVEL_0);
if(!m_net_server.run_server(thrds_count))
if(!m_net_server.run_server(thrds_count, true, attrs))
{
LOG_ERROR("Failed to run net tcp server!");
}
Expand Down
5 changes: 4 additions & 1 deletion src/rpc/core_rpc_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,10 @@ namespace cryptonote
return true;
}

if(!m_core.get_miner().start(adr, static_cast<size_t>(req.threads_count)))
boost::thread::attributes attrs;
attrs.set_stack_size(THREAD_STACK_SIZE);

if(!m_core.get_miner().start(adr, static_cast<size_t>(req.threads_count), attrs))
{
res.status = "Failed, mining not started";
return true;
Expand Down

0 comments on commit 25d3389

Please sign in to comment.