<commit_before>#include "arch/io/disk/conflict_resolving.hpp"

#include <deque>
#include <map>

#include "perfmon/perfmon.hpp"

template<class payload_t>
conflict_resolving_diskmgr_t<payload_t>::conflict_resolving_diskmgr_t(perfmon_collection_t *stats) :
    conflict_sampler(secs_to_ticks(1), true),
    conflict_sampler_membership(stats, &conflict_sampler, "conflict")
{ }

template<class payload_t>
conflict_resolving_diskmgr_t<payload_t>::~conflict_resolving_diskmgr_t() {

    /* Make sure there are no requests still out. */
    for (typename all_chunk_queues_t::iterator fd_t_chunk_queues = all_chunk_queues.begin();
         fd_t_chunk_queues != all_chunk_queues.end();
         ++fd_t_chunk_queues) {
        chunk_queues_t &chunk_queues = fd_t_chunk_queues->second;
        rassert(chunk_queues.empty());
    }
}

template<class payload_t>
void conflict_resolving_diskmgr_t<payload_t>::submit(action_t *action) {
    chunk_queues_t &chunk_queues = all_chunk_queues[action->get_fd()];
    /* Determine the range of file-blocks that this action spans */
    int start, end;
    get_range(action, &start, &end);

    /* If this is a read, we check whether there is a write from which we
    can "steal" data to satisfy the read immediately. We currently only
    do this if there is a single write operation that provides all the data
    that we need, we don't combine multiple writes that affect different parts
    of the read request. */
    if (action->get_is_read()) {
        /* The logic here is a bit tricky. What we do is the following:
        First we check the queue for the first chunk. If there is a write that
        can satisfy us, it must span all chunks and therefore be on the first
        chunk's queue. We pick the latest write that exists on that queue, so
        we get the most recent version of the data. We then check the other
        chunks and make sure that the same write is also the latest write on
        these queues. If there is another more recent write, we cannot take
        the data from our initial write, because a subrange of it will be
        overwritten by that other write. As an optimization, we could
        still use the data from the initial write and just replace that part of<commit_msg>Simplified [rassert] loop in [conflict_resolving_diskmgr_t] destructor.<commit_after>#include "arch/io/disk/conflict_resolving.hpp"

#include <deque>
#include <map>

#include "perfmon/perfmon.hpp"

template<class payload_t>
conflict_resolving_diskmgr_t<payload_t>::conflict_resolving_diskmgr_t(perfmon_collection_t *stats) :
    conflict_sampler(secs_to_ticks(1), true),
    conflict_sampler_membership(stats, &conflict_sampler, "conflict")
{ }

template<class payload_t>
conflict_resolving_diskmgr_t<payload_t>::~conflict_resolving_diskmgr_t() {

    /* Make sure there are no requests still out. */
    for (typename all_chunk_queues_t::iterator fd_t_chunk_queues = all_chunk_queues.begin();
         fd_t_chunk_queues != all_chunk_queues.end();
         ++fd_t_chunk_queues) {
        rassert(fd_t_chunk_queues->second.empty());
    }
}

template<class payload_t>
void conflict_resolving_diskmgr_t<payload_t>::submit(action_t *action) {
    chunk_queues_t &chunk_queues = all_chunk_queues[action->get_fd()];
    /* Determine the range of file-blocks that this action spans */
    int start, end;
    get_range(action, &start, &end);

    /* If this is a read, we check whether there is a write from which we
    can "steal" data to satisfy the read immediately. We currently only
    do this if there is a single write operation that provides all the data
    that we need, we don't combine multiple writes that affect different parts
    of the read request. */
    if (action->get_is_read()) {
        /* The logic here is a bit tricky. What we do is the following:
        First we check the queue for the first chunk. If there is a write that
        can satisfy us, it must span all chunks and therefore be on the first
        chunk's queue. We pick the latest write that exists on that queue, so
        we get the most recent version of the data. We then check the other
        chunks and make sure that the same write is also the latest write on
        these queues. If there is another more recent write, we cannot take
        the data from our initial write, because a subrange of it will be
        overwritten by that other write. As an optimization, we could
        still use the data from the initial write and just replace that part of
{'fraction_non_alphanumeric': 0.07049434715140768, 'fraction_numerical': 0.0004433606739082243, 'mean_word_length': 3.704900938477581, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5311279', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1336, 'n_words': 509}