- Many MSG tests were converted to the new S4U's interface in C, that
was extended for that.
-Fixed bugs (FG#.. -> framagit bugs; FG!.. -> FG merge requests; GH: GitHub):
+Fixed bugs (FG#.. -> FramaGit bugs; FG!.. -> FG merge requests)
+ (FG: issues on Framagit; GH: issues on GitHub; GF: issues on GForge)
+ - GF#18137: Allow different stack sizes?
- FG#41: Add sg_actor_create C interface
- FG#43: xbt::random needs some care
- FG#48: The Impossible Did Happen (yet again)
If you want to push the scalability limits of your code, you might
want to reduce the ``contexts/stack-size`` item. Its default value is
8192 (in KiB), while our Chord simulation works with stacks as small
-as 16 KiB, for example. This *setting is ignored* when using the
-thread factory. Instead, you should compile SimGrid and your
-application with ``-fsplit-stack``. Note that this compilation flag is
-not compatible with the model checker right now.
+as 16 KiB, for example. You can ensure that some actors have a specific
+size by simply changing the value of this configuration item before
+creating these actors. The :cpp:func:`simgrid::s4u::Engine::set_config`
+functions are handy for that.
+
+This *setting is ignored* when using the thread factory (because there
+is no way to modify the stack size with C++ system threads). Instead,
+you should compile SimGrid and your application with
+``-fsplit-stack``. Note that this compilation flag is not compatible
+with the model checker right now.
The operating system should only allocate memory for the pages of the
stack which are actually used and you might not need to use this in
BoostContext::BoostContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory)
: SwappedContext(std::move(code), actor, factory)
{
+ XBT_VERB("Creating a context of stack %uMb", smx_context_stack_size / 1024 / 1024);
/* if the user provided a function for the process then use it, otherwise it is the context for maestro */
if (has_code()) {
#if BOOST_VERSION < 106100
RawContext::RawContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory)
: SwappedContext(std::move(code), actor, factory)
{
- if (has_code()) {
- this->stack_top_ = raw_makecontext(get_stack(), smx_context_stack_size, smx_ctx_wrapper, this);
- } else {
- if (MC_is_active())
- MC_ignore_heap(&stack_top_, sizeof(stack_top_));
- }
+ XBT_VERB("Creating a context of stack %uMb", smx_context_stack_size / 1024 / 1024);
+ if (has_code()) {
+ this->stack_top_ = raw_makecontext(get_stack(), smx_context_stack_size, smx_ctx_wrapper, this);
+ } else {
+ if (MC_is_active())
+ MC_ignore_heap(&stack_top_, sizeof(stack_top_));
+ }
}
void RawContext::swap_into_for_real(SwappedContext* to_)
SwappedContext::SwappedContext(std::function<void()>&& code, smx_actor_t actor, SwappedContextFactory* factory)
: Context(std::move(code), actor), factory_(*factory)
{
- // Save maestro (=context created first) in preparation for run_all
+ // Save maestro (=first created context) in preparation for run_all
if (not SIMIX_context_is_parallel() && factory_.maestro_context_ == nullptr)
factory_.maestro_context_ = this;
ThreadContextFactory::ThreadContextFactory() : ContextFactory()
{
+ if (smx_context_stack_size != 8 * 1024 * 1024)
+ XBT_INFO("Stack size modifications are ignored by thread factory.");
if (SIMIX_context_is_parallel())
ParallelThreadContext::initialize();
}
UContext::UContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory)
: SwappedContext(std::move(code), actor, factory)
{
+ XBT_VERB("Creating a context of stack %uMb", smx_context_stack_size / 1024 / 1024);
/* if the user provided a function for the actor then use it. If not, nothing to do for maestro. */
if (has_code()) {
getcontext(&this->uc_);
--- /dev/null
+foreach(x context-stacksize)
+ add_executable (${x} EXCLUDE_FROM_ALL ${x}/${x}.cpp)
+ target_link_libraries(${x} simgrid)
+ set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
+ add_dependencies(tests ${x})
+
+ set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.cpp)
+endforeach()
+
+## Add the tests.
+## Some need to be run with all factories, some don't need tesh to run
+
+# Only with the raw contexts
+ADD_TESH_FACTORIES(tesh-kern-context-stacksize "raw;boost;ucontext" --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/kernel/context-stacksize --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/kernel/context-stacksize --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_BINARY_DIR}/teshsuite/kernel/context-stacksize ${CMAKE_HOME_DIRECTORY}/teshsuite/kernel/context-stacksize/context-stacksize.tesh)
+
--- /dev/null
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+/* This code tests that we can change the stack-size between the actors creation. */
+
+#include "simgrid/s4u.hpp"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+
+static void actor()
+{
+ XBT_INFO("Hello");
+}
+
+int main(int argc, char* argv[])
+{
+ simgrid::s4u::Engine e(&argc, argv);
+ e.load_platform(argv[1]);
+
+ simgrid::s4u::Actor::create("actor", simgrid::s4u::Host::by_name("Tremblay"), actor);
+ e.set_config("contexts/stack-size:16384");
+ simgrid::s4u::Actor::create("actor", simgrid::s4u::Host::by_name("Tremblay"), actor);
+ e.set_config("contexts/stack-size", 32 * 1024);
+ simgrid::s4u::Actor::create("actor", simgrid::s4u::Host::by_name("Tremblay"), actor);
+ e.set_config("contexts/stack-size", 64 * 1024);
+ simgrid::s4u::Actor::create("actor", simgrid::s4u::Host::by_name("Tremblay"), actor);
+
+ e.run();
+ XBT_INFO("Simulation time %g", e.get_clock());
+
+ return 0;
+}
--- /dev/null
+
+! ignore .*Using Boost contexts. Welcome to the 21th century.
+! ignore .*Activating SYSV context factory
+! ignore .*Using raw contexts. Because the glibc is just not good enough for us.
+
+$ ./context-stacksize --log=simix_context.thresh:verbose --log=no_loc ${platfdir}/small_platform.xml
+> [::(0) 0.000000] [simix_context/VERBOSE] Creating a context of stack 8Mb
+> [0.000000] [simix_context/VERBOSE] Creating a context of stack 8Mb
+> [0.000000] [simix_context/VERBOSE] Creating a context of stack 16Mb
+> [0.000000] [simix_context/VERBOSE] Creating a context of stack 32Mb
+> [0.000000] [simix_context/VERBOSE] Creating a context of stack 64Mb
+> [Tremblay:actor:(1) 0.000000] [s4u_test/INFO] Hello
+> [Tremblay:actor:(2) 0.000000] [s4u_test/INFO] Hello
+> [Tremblay:actor:(3) 0.000000] [s4u_test/INFO] Hello
+> [Tremblay:actor:(4) 0.000000] [s4u_test/INFO] Hello
+> [0.000000] [s4u_test/INFO] Simulation time 0
+
+! ignore .*Stack size modifications are ignored by thread factory.
$ ${bindir:=.}/generic-simcalls --cfg=contexts/stack-size:96 ${srcdir:=.}/examples/platforms/small_platform.xml
> [Tremblay:master:(1) 0.000000] [test/INFO] Start
> [0.000000] [test/INFO] kernel
examples/deprecated/simdag/CMakeLists.txt
teshsuite/java/CMakeLists.txt
+ teshsuite/kernel/CMakeLists.txt
teshsuite/lua/CMakeLists.txt
teshsuite/mc/CMakeLists.txt
teshsuite/msg/CMakeLists.txt