mfe.c - use of write cache and bm_flush_cache() is confusing

Issue #162 resolved
dd1 created an issue

I am confused by the use of bm_flush_cache() in mfe.c.

In some places, bm_flush_cache() is done immediately after bm_send_event() (rpc_send_event()), completely defeating the write cache.

In other places there is a loop to bm_flush_cache() of all open buffers, not just the one we are writing into (i.e. bm_flush_cache() is unnecessarily called on the SYSMSG buffer).

Then there is a periodic call to bm_flush_cache() at around 1 Hz to flush the current equipment if it is not writing fast enough.

I think all the calls to bm_flush_cache() should be removed except for the 1Hz periodic flush.

But clearly I do not understand the intent of this logic...

K.O.

Comments (3)

  1. Stefan Ritt

    I don't know exactly which locations you refer, but the original design idea was the following:

    • Buffer smaller events in order to reduce the TCP overhead. Sending 10'000 events with 10 Bytes takes longer than sending one buffer with 100'000 Bytes.
    • For experiments with small trigger rates, it might take many seconds or even minutes until a buffer is full and flushed. So people would not see any events coming down the line and wonder what is happening. So we should flush every buffer regularly. I guess I do this once per second.
    • When scaler events are sent, the cache should be flushed, so that the scalers arrive immediately, reflecting the current status of the experiment (such as rates for example). If a scaler is read out and sent one minute later, it might cause confusion.
    • At the end of the run, all caches should be flushed to collect any remaining event.
    • The SYSMSG buffer should be flushed immediately so that messages can be seen. Actually this buffer should not be cached at all.
    • There might be some excessive calling of bm_flush_cache() but this is "cheap", since testing an empty cache is just a few instructions and can be done millions of times per second.

    Stefan

  2. Log in to comment