Exemplo n.º 1
0
void thorium_transport_destroy(struct thorium_transport *self)
{
    /*
     * Print the report if requested.
     */
    if (core_bitmap_get_bit_uint32_t(&self->flags, FLAG_PROFILE)) {
        thorium_transport_profiler_print_report(&self->transport_profiler);
    }

    thorium_transport_profiler_destroy(&self->transport_profiler);

    CORE_DEBUGGER_ASSERT(thorium_transport_get_active_request_count(self) == 0);

    if (self->transport_interface != NULL) {
        self->transport_interface->destroy(self);

        core_memory_free(self->concrete_transport, MEMORY_TRANSPORT);
        self->concrete_transport = NULL;
    }

    self->node = NULL;
    self->rank = -1;
    self->size = -1;

    core_timer_destroy(&self->timer);
}
Exemplo n.º 2
0
void thorium_cfs_scheduler_print(struct thorium_scheduler *self)
{
    struct thorium_cfs_scheduler *concrete_self;
    struct core_red_black_tree_iterator iterator;
    uint64_t virtual_runtime;
    struct thorium_actor *actor;
    int i;
    struct core_timer timer;

    core_timer_init(&timer);
    concrete_self = self->concrete_self;

    core_red_black_tree_iterator_init(&iterator, &concrete_self->tree);

    printf("[cfs_scheduler] %" PRIu64 " ns, timeline contains %d actors\n",
                    core_timer_get_nanoseconds(&timer),
                    core_red_black_tree_size(&concrete_self->tree));

    i = 0;
    while (core_red_black_tree_iterator_get_next_key_and_value(&iterator, &virtual_runtime,
                            &actor)) {
        printf("[%d] virtual_runtime= %" PRIu64 " actor= %s/%d\n",
                        i, virtual_runtime,
                        thorium_actor_script_name(actor), thorium_actor_name(actor));
        ++i;
    }

    core_red_black_tree_iterator_destroy(&iterator);
    core_timer_destroy(&timer);
}
Exemplo n.º 3
0
void biosal_input_controller_destroy(struct thorium_actor *actor)
{
    struct biosal_input_controller *concrete_actor;
    int i;
    char *pointer;
    struct core_map_iterator iterator;
    struct core_vector *vector;

    concrete_actor = (struct biosal_input_controller *)thorium_actor_concrete_actor(actor);

    core_timer_destroy(&concrete_actor->input_timer);
    core_timer_destroy(&concrete_actor->counting_timer);
    core_timer_destroy(&concrete_actor->distribution_timer);

    biosal_dna_codec_destroy(&concrete_actor->codec);

    for (i = 0; i < core_vector_size(&concrete_actor->files); i++) {
        pointer = *(char **)core_vector_at(&concrete_actor->files, i);
        core_memory_free(pointer, MEMORY_CONTROLLER);
    }

    core_vector_destroy(&concrete_actor->mega_block_vector);
    core_vector_destroy(&concrete_actor->counting_streams);
    core_vector_destroy(&concrete_actor->reading_streams);
    core_vector_destroy(&concrete_actor->partition_commands);
    core_vector_destroy(&concrete_actor->consumer_active_requests);
    core_vector_destroy(&concrete_actor->stream_consumers);
    core_vector_destroy(&concrete_actor->files);
    core_vector_destroy(&concrete_actor->spawners);
    core_vector_destroy(&concrete_actor->counts);
    core_vector_destroy(&concrete_actor->consumers);
    core_vector_destroy(&concrete_actor->stores_per_spawner);
    core_queue_destroy(&concrete_actor->unprepared_spawners);

    core_map_iterator_init(&iterator, &concrete_actor->mega_blocks);
    while (core_map_iterator_has_next(&iterator)) {
        core_map_iterator_next(&iterator, NULL, (void **)&vector);

        core_vector_destroy(vector);
    }
    core_map_iterator_destroy(&iterator);
    core_map_destroy(&concrete_actor->mega_blocks);
    core_map_destroy(&concrete_actor->assigned_blocks);
}
Exemplo n.º 4
0
void test_allocator(struct core_memory_pool *memory)
{
    int i;
    int size;
    void *pointer;
    struct core_vector vector;
    struct core_timer timer;
    uint64_t elapsed;

    i = 1000000;
    size = 45;

    core_vector_init(&vector, sizeof(void *));
    core_timer_init(&timer);

    core_timer_start(&timer);

    while (i--) {
        if (memory != NULL) {
            pointer = core_memory_pool_allocate(memory, size);
        } else {
            pointer = core_memory_allocate(size, -1);
        }

        core_vector_push_back(&vector, &pointer);
    }

    core_timer_stop(&timer);
    elapsed = core_timer_get_elapsed_nanoseconds(&timer);

    if (memory == NULL) {
        printf("Not using memory pool... ");
    } else {
        printf("Using memory pool... ");
    }
    printf("Elapsed : %" PRIu64 " milliseconds\n", elapsed / 1000 / 1000);

    size = core_vector_size(&vector);
    for (i = 0; i < size; ++i) {
        pointer = core_vector_at_as_void_pointer(&vector, i);

        if (memory != NULL) {
            core_memory_pool_free(memory, pointer);
        } else {
            core_memory_free(pointer, -1);
        }
    }
    core_vector_destroy(&vector);
    core_timer_destroy(&timer);
}
Exemplo n.º 5
0
void spate_destroy(struct thorium_actor *self)
{
    struct spate *concrete_self;

    concrete_self = (struct spate *)thorium_actor_concrete_actor(self);

    core_timer_destroy(&concrete_self->timer);

    concrete_self->input_controller = THORIUM_ACTOR_NOBODY;
    concrete_self->manager_for_sequence_stores = THORIUM_ACTOR_NOBODY;
    concrete_self->assembly_graph = THORIUM_ACTOR_NOBODY;
    concrete_self->assembly_graph_builder = THORIUM_ACTOR_NOBODY;

    core_vector_destroy(&concrete_self->initial_actors);
    core_vector_destroy(&concrete_self->sequence_stores);
    core_vector_destroy(&concrete_self->graph_stores);
}
Exemplo n.º 6
0
void biosal_unitig_manager_destroy(struct thorium_actor *self)
{
    struct biosal_unitig_manager *concrete_self;

    concrete_self = (struct biosal_unitig_manager *)thorium_actor_concrete_actor(self);

    core_vector_destroy(&concrete_self->spawners);
    core_vector_destroy(&concrete_self->graph_stores);

    core_vector_destroy(&concrete_self->walkers);
    core_vector_destroy(&concrete_self->visitors);

    concrete_self->completed = 0;
    concrete_self->manager = THORIUM_ACTOR_NOBODY;

    core_timer_destroy(&concrete_self->timer);
}
Exemplo n.º 7
0
void thorium_message_multiplexer_destroy(struct thorium_message_multiplexer *self)
{
    int i;
    int size;
    struct thorium_multiplexed_buffer *multiplexed_buffer;
    float ratio;

    if (thorium_node_must_print_data(self->node)) {

        ratio = 0.0;

        if (self->original_message_count != 0) {
            ratio = self->real_message_count / (0.0 + self->original_message_count);

            /*
             * Jack M. Nilles
             * "Traffic reduction by telecommuting: A status review and selected bibliography"
             * Transportation Research Part A: General
             * Volume 22, Issue 4, July 1988, Pages 301–317.
             *
             * @see http://www.sciencedirect.com/science/article/pii/0191260788900088
             * @see http://ww2.cityofpasadena.net/councilagendas/2007%20agendas/feb_26_07/pasadena%20traffic%20reduction%20strategies%2011-20-06%20draft.pdf
             */
            thorium_printf("[thorium] node %d worker %d message_multiplexer:"
                            " original_message_count %d real_message_count %d (traffic reduction: %.2f%%)\n",
                            thorium_node_name(self->node), thorium_worker_name(self->worker),
                    self->original_message_count, self->real_message_count, (1.0 - ratio) * 100);

            thorium_message_multiplexer_print_traffic_reduction(self);
        }
    }

#ifdef CORE_DEBUGGER_ASSERT_ENABLED
#endif
    size = core_vector_size(&self->buffers);

#ifdef THORIUM_MULTIPLEXER_TRACK_BUFFERS_WITH_CONTENT
    /*
     * There can be no messages that are not flushed already.
     */
    CORE_DEBUGGER_ASSERT(core_set_empty(&self->buffers_with_content));

    core_set_destroy(&self->buffers_with_content);
#endif

    for (i = 0; i < size; ++i) {
        multiplexed_buffer = core_vector_at(&self->buffers, i);

        CORE_DEBUGGER_ASSERT(thorium_multiplexed_buffer_current_size(multiplexed_buffer) == 0);

        thorium_multiplexed_buffer_destroy(multiplexed_buffer);
    }

    core_vector_destroy(&self->buffers);

    self->node = NULL;

    self->buffer_size_in_bytes = -1;
    self->timeout_in_nanoseconds = -1;

    core_timer_destroy(&self->timer);

#ifdef THORIUM_MULTIPLEXER_USE_TREE
    core_red_black_tree_destroy(&self->timeline);
#elif defined(THORIUM_MULTIPLEXER_USE_HEAP)
    core_binary_heap_destroy(&self->timeline);
#elif defined(THORIUM_MULTIPLEXER_USE_QUEUE)
    core_queue_destroy(&self->timeline);

#endif

    thorium_decision_maker_destroy(&self->decision_maker);

    thorium_router_destroy(&self->router);
}
Exemplo n.º 8
0
void thorium_worker_destroy(struct thorium_worker *worker)
{
    void *buffer;

    thorium_load_profiler_destroy(&worker->profiler);

    if (core_bitmap_get_bit_uint32_t(&worker->flags, FLAG_ENABLE_ACTOR_LOAD_PROFILER)) {
        core_buffered_file_writer_destroy(&worker->load_profile_writer);
    }

    core_map_destroy(&worker->actor_received_messages);

    /*
    thorium_worker_print_balance(worker);
    */
    while (thorium_worker_fetch_clean_outbound_buffer(worker, &buffer)) {

        core_memory_pool_free(&worker->outbound_message_memory_pool, buffer);

#ifdef THORIUM_WORKER_DEBUG_INJECTION
        ++worker->counter_freed_outbound_buffers_from_other_workers;
#endif
    }

#ifdef THORIUM_WORKER_DEBUG_INJECTION
    printf("AFTER COLLECTION\n");
    thorium_worker_print_balance(worker);

    printf("THORIUM-> clean_message_queue_for_triage has %d items\n",
                    core_fast_queue_size(&worker->clean_message_queue_for_triage));
    printf("THORIUM-> clean_message_ring_for_triage has %d items\n",
                    core_fast_ring_size_from_producer(&worker->clean_message_ring_for_triage));
    printf("THORIUM-> injected_clean_outbound_buffers has %d items\n",
                    core_fast_ring_size_from_producer(&worker->injected_clean_outbound_buffers));
#endif

    core_timer_destroy(&worker->timer);

#ifdef THORIUM_WORKER_ENABLE_LOCK
    core_lock_destroy(&worker->lock);
#endif

    core_fast_ring_destroy(&worker->actors_to_schedule);

#ifdef THORIUM_NODE_INJECT_CLEAN_WORKER_BUFFERS
    core_fast_ring_destroy(&worker->injected_clean_outbound_buffers);

    core_fast_ring_destroy(&worker->clean_message_ring_for_triage);
    core_fast_queue_destroy(&worker->clean_message_queue_for_triage);
#endif

    thorium_scheduler_destroy(&worker->scheduler);
    core_fast_ring_destroy(&worker->outbound_message_queue);
    core_fast_queue_destroy(&worker->outbound_message_queue_buffer);

    core_map_destroy(&worker->actors);
    core_map_iterator_destroy(&worker->actor_iterator);
    core_set_destroy(&worker->evicted_actors);

    worker->node = NULL;

    worker->name = -1;
    core_bitmap_set_bit_uint32_t(&worker->flags, FLAG_DEAD);

    core_memory_pool_destroy(&worker->ephemeral_memory);
    core_memory_pool_destroy(&worker->outbound_message_memory_pool);

    thorium_priority_assigner_destroy(&worker->assigner);
}