ID |
Date |
Author |
Topic |
Subject |
3069
|
14 Aug 2025 |
Konstantin Olchanski | Forum | How can I retrieve online data |
> I would like to know how to retrieve the online data during the experiment so
> that I can create my own custom plot. I execute my own frontend.exe to start the
> experiment. I can get a midas file after the experiment, but I am not sure about
> how to retrieve the online data. I know that rootana can help us to get the
> online plots, but the instructions in rootana is not clear. Can anyone give me
> some suggestion? Thank you.
The current package for analyzing MIDAS data is the "m" analyzer, usually in the manalyzer subdirectory of your midas package,
but it can also be used stand-alone without MIDAS.
There is several examples:
manalyzer_example_cxx.cxx - a simple "c++" example shows how to extra midas bank data
manalyzer_example_root.cxx - how to create ROOT histograms (that you can see online using jsroot)
manalyzer_example_root_graphics.cxx - how to create a ROOT graphical program (obsoleted by jsroot, but still possible)
manalyzer_example_flow*.cxx - more advanced examples on using a flow analyzer
Documentation is in README.md
Unfortunately there is no tutorial or 5 min youtube explainer, each experiment needs are very different, there is no way to
write a one-size-fits-all recipe.
Please take a look at the existing examples first, then send me a PM with any additional questions (or ask here). If you can
explain what kind of data you have and how you want to look at it, I should be able to guide you through writing an appropriate
manalyzer module.
K.O. |
3068
|
14 Aug 2025 |
Tam Kai Chung | Forum | How can I retrieve online data |
Dear experts,
I would like to know how to retrieve the online data during the experiment so
that I can create my own custom plot. I execute my own frontend.exe to start the
experiment. I can get a midas file after the experiment, but I am not sure about
how to retrieve the online data. I know that rootana can help us to get the
online plots, but the instructions in rootana is not clear. Can anyone give me
some suggestion? Thank you.
Best,
Terry |
3067
|
24 Jul 2025 |
Konstantin Olchanski | Bug Fix | support for large history files |
FILE history code (mhf_*.dat files) did not support reading history files bigger than about 2GB, this is now
fixed on branch "feature/history_off64_t" (in final testing, to be merged ASAP).
History files were never meant to get bigger than about 100 MBytes, but it turns out large files can still
happen:
1) files are rotated only when history is closed and reopened
2) we removed history close and open on run start
3) so files are rotated only when mlogger is restarted
In the old code, large files would still happen if some equipment writes a lot of data (I have a file from
Stefan with history record size about 64 kbytes, written at 1/second, MIDAS handles this just fine) or if
there is no runs started and stopped for a long time.
There are reasons for keeping file size smaller:
a) I would like to use mmap() to read history files, and mmap() of a 100 Gbyte file on a 64 Gbyte RAM
machine would not work very well.
b) I would like to implement compressed history files and decompression of a 100 Gbyte file takes much
longer than decompression of a 100 Mbyte file. it is better if data is in smaller chunks.
(it is easy to write a utility program to break-up large history files into smaller chunks).
Why use mmap()? I note that the current code does 1 read() syscall per history record (it is much better to
read data in bigger chunks) and does multiple seek()/read() syscalls to find the right place in the history
file (plays silly buggers with the OS read-ahead and data caching). mmap() eliminates all syscalls and has
the potential to speed things up quite a bit.
K.O. |
3066
|
24 Jul 2025 |
Konstantin Olchanski | Suggestion | K.O.'s guide to new C/C++ data types |
> for (int i=0; i<array_of_10_elements.size(); i++)
becomes
for (size_t i=0; i<array.size(); i++)
but for a reverse loop, replacing "int" with "size_t" becomes a bug:
for (size_t i=array.size()-1; i>=0; i--)
explodes, last iteration should be with i set to 0, then i--
wraps it around a very big positive value and loop end condition
is still true (i>=0), the loop never ends. (why is there no GCC warning
that with "size_t i", "i>=0" is always true?
a kludge solution is:
for (size_t i=array.size()-1; ; i--) {
do_stuff(i, array[i]);
if (i==0) break;
}
if you do not need the index variable, you can use a reverse iterator (which is missing from a few
container classes).
K.O. |
3065
|
23 Jul 2025 |
Konstantin Olchanski | Suggestion | K.O.'s guide to new C/C++ data types |
Over the last 10 years, the traditional C/C++ data types have been
displaced by a hodgepodge of new data types that promise portability
and generate useful (and not so useful) warnings, for example:
for (int i=0; i<array_of_10_elements.size(); i++)
is now a warning with a promise of crash (in theory, even if "int" is 64 bit).
"int" and "long" are dead, welcome "size_t", "off64_t" & co.
What to do, what to do? This is what I figured out:
1) for data returned from hardware: use uint16_t, uint32_t, uint64_t, uint128_t (u16, u32, u64 in
the Linux kernel), they have well defined width to match hardware (FPGA, AXI, VME, etc) data
widths.
2) for variables used with strlen(), array.size(), etc: use size_t, a data type wide enough to
store the biggest data size possible on this hardware (32-bit on 32-bit machines, 64-bit on 64-bit
machines). use with printf("%zu").
3) for return values of read() and write() syscalls: use ssize_t and observe an inconsistency,
read() and write() syscalls take size_t (32/64 bits), return ssize_t (31/63 bits) and the error
check code cannot be written without having to defeat the C/C++ type system (a cast to size_t):
size_t s = 100;
void* ptr = malloc(s);
ssize_t rd = read(fd, ptr, s);
if (rd < 0) { syscall error }
else if ((size_t)rd != s) { short read, important for TCP sockets }
else { good read }
use ssize_t with printf("%zd")
4) file access uses off64_t with lseek64() and ftruncate64(), this is a signed type (to avoid the
cast in the error handling code) with max file size 2^63 (at $/GB, storage for a file of max size
costs $$$$$, you cannot have enough money to afford one). use with printf("%jd", (intmax_t)v).
intmax_t by definition is big enough for all off64_t values, "%jd" is the corresponding printf()
format.
5) there is no inconsistency between 32-bit size_t and 64-bit off64_t, on 32-bit systems you can
only read files in small chunks, but you can lseek64() to any place in the file.
BTW, 64-bit time_t has arrived with Ubuntu LTS 24.04, I will write about this some other time. |
3064
|
21 Jul 2025 |
Stefan Ritt | Bug Report | Default write cache size for new equipments breaks compatibility with older equipments |
> Perhaps have:
>
> set_write_cache_size("SYSTEM", 0);
> set_write_cache_size("BUF1", bigsize);
>
> with an internal std::map<std::string,size_t>; for write cache size for each named buffer
Ok, this is implemented now in mfed.cxx and called from examples/experiment/frontend.cxx
Stefan |
3063
|
13 Jul 2025 |
Zaher Salman | Info | PySequencer |
As many of you already know Ben introduced the new PySequencer that allows running python scripts from MIDAS. In the last couple of month we have been working on integrating it into the MIDAS pages. We think that it is now ready for general testing.
To use the PySequencer:
1- Enable it from /Experiment/Menu
2- Refresh the pages to see a new PySequencer menu item
3- Click on it to start writing and executing your python script.
The look and feel are identical to the msequencer pages (both use the same JavaScript code).
Please report problems and bug here.
Known issues:
The first time you start the PySequencer program it may fail. To fix this copy:
$MIDASSYS/python/examples/pysequencer_script_basic.py
to
online/userfiles/sequencer/
and set /PySequencer/State/Filename to pysequencer_script_basic.py |
3062
|
04 Jul 2025 |
Mark Grimes | Bug Report | Memory leaks in mhttpd |
Something changed in our system and we started seeing memory leaks in mhttpd again. I guess someone
updated some front end or custom page code that interacted with mhttpd differently.
I found a few memory leaks in some (presumably) rarely seen corner cases and we now see steady
memory usage. The branch is fix/memory_leaks
(https://bitbucket.org/tmidas/midas/branch/fix/memory_leaks) and I opened pull request #55
(https://bitbucket.org/tmidas/midas/pull-requests/55). I couldn't find a BitBucket account for you
Konstantin to add as a reviewer, so it currently has none.
Thanks,
Mark. |
3061
|
23 Jun 2025 |
Stefan Ritt | Bug Report | Memory leak in mhttpd binary RPC code |
Since this memory leak is quite obvious, I pushed the fix to develop.
Stefan |
3060
|
19 Jun 2025 |
Stefan Ritt | Bug Report | History variables with leading spaces |
I added now code to the logger so it properly complains if there would be a leading space in a variable name.
Stefan
> By accident we had history variables with leading spaces. The history schema check then decides that this is a new variable (the leading space is not read from the history file) and starts a new file. We found this because the run start became slow due to the many, many history files created. It would be nice to just get an error if one has a malformed variable name like this.
>
> How to reproduce: Try to put a variable with a leading space in the name into the history, repeatedly start runs.
> Sugested fix: Produce an error if a history variable has a leading space. |
3059
|
19 Jun 2025 |
Frederik Wauters | Bug Report | add history variables |
I have encounter this a few times
* Make a new history panel
* Use the web GUI to add history variables
* When I am at the "add history variables" panel, there is not scroll option. So
depending on the size and zoom of my screen, some variables further down the list
can not be selected
tried Chrome and Firefox |
3058
|
15 Jun 2025 |
Mark Grimes | Bug Report | Memory leak in mhttpd binary RPC code |
Many thanks for the fix. We've applied and see better memory performance. We still have to kill and restart
mhttpd after a few days however. I think the official fix is missing this part:
diff --git a/src/mjsonrpc.cxx b/src/mjsonrpc.cxx
index 2201d228..38f0b99b 100644
--- a/src/mjsonrpc.cxx
+++ b/src/mjsonrpc.cxx
@@ -3454,6 +3454,7 @@ static MJsonNode* brpc(const MJsonNode* params)
status = cm_connect_client(name.c_str(), &hconn);
if (status != RPC_SUCCESS) {
+ free(buf);
return mjsonrpc_make_result("status", MJsonNode::MakeInt(status));
}
When the other process returns a failure the memory block is also currently leaked. I originally stated "...although I
don't think it contributed to the leak we were seeing" but it seems this was false.
Thanks,
Mark.
> I confirm that MJSON_ARRAYBUFFER does not work correctly for zero-size buffers,
> buffer is leaked in the destructor and copied as NULL in MJsonNode::Copy().
>
> I also confirm memory leak in mjsonrpc "brpc" error path (already fixed).
>
> Affected by the MJSON_ARRAYBUFFER memory leak are "brpc" (where user code returns
> a zero-size data buffer) and "js_read_binary_file" (if reading from an empty
> file, return of "new char[0]" is never freed).
>
> "receive_event" and "read_history" RPCs never use zero-size buffers and are not
> affected by this bug.
>
> mjson commit c798c1f0a835f6cea3e505a87bbb4a12b701196c
> midas commit 576f2216ba2575b8857070ce7397210555f864e5
> rootana commit a0d9bb4d8459f1528f0882bced9f2ab778580295
>
> Please post bug reports a plain-text so I can quote from them.
>
> K.O. |
3057
|
11 Jun 2025 |
Stefan Ritt | Info | Frontend write cache size |
We had issues with the frontend write cache size and the way it was implemented in the frontend
framework mfe. Specifically, we had two equipments like in the experiment/examples/frontend.cxx, one
trigger event and one periodic event. While the trigger event sets the cache size correctly in the
equipment table, the periodic event (defined afterwards) overwrites the cache size to zero, causing slow
data taking.
The underlying problem is that one event buffer (usually "SYSTEM") can only have one cache size for all
events in one frontend. To avoid mishaps like that, I remove the write cache size from the equipment table
and instead defined a function which explicitly sets the cache size for a buffer. In your frontend_init() you
can now call
set_cache_size("SYSTEM", 10000000);
to set the cache size of the SYSTEM buffer. Note that 10 MiB is the minimum cache size. Especially for
smaller events, this dramatically can speed up your maximal DAQ rate.
Full commit is here:
https://bitbucket.org/tmidas/midas/commits/24fbf2c02037ae5f7db74d0cadab23cd4bfe3b13
Note that this only affects frontends using the mfe framework, NOT for those using the tmfe framework.
Stefan |
3056
|
10 Jun 2025 |
Stefan Ritt | Info | History configuration changed |
Today the way the history system is configured has changed. Whenever one adds new equipment
variables, the logger has to add that variable to the history system. Previously, this happened during
startup of the logger and at run start. We have now a case in the Mu3e experiment where we have many
variables and the history configuration takes about 15 seconds, which delays data taking considerably.
After discussion with KO we decided to remove the history re-configuration at run start. This speeds up
the run start considerably, also for other experiments with many history variables. It means however that
once you add/remove/rename any equipment variable going into the history system, you have to restart the
logger for this to become active.
https://bitbucket.org/tmidas/midas/commits/c0a14c2d0166feb6b38c645947f2c5e0bef013d5
Stefan |
3055
|
10 Jun 2025 |
Konstantin Olchanski | Bug Report | Memory leak in mhttpd binary RPC code |
I confirm that MJSON_ARRAYBUFFER does not work correctly for zero-size buffers,
buffer is leaked in the destructor and copied as NULL in MJsonNode::Copy().
I also confirm memory leak in mjsonrpc "brpc" error path (already fixed).
Affected by the MJSON_ARRAYBUFFER memory leak are "brpc" (where user code returns
a zero-size data buffer) and "js_read_binary_file" (if reading from an empty
file, return of "new char[0]" is never freed).
"receive_event" and "read_history" RPCs never use zero-size buffers and are not
affected by this bug.
mjson commit c798c1f0a835f6cea3e505a87bbb4a12b701196c
midas commit 576f2216ba2575b8857070ce7397210555f864e5
rootana commit a0d9bb4d8459f1528f0882bced9f2ab778580295
Please post bug reports a plain-text so I can quote from them.
K.O. |
3054
|
10 Jun 2025 |
Nik Berger | Bug Report | History variables with leading spaces |
By accident we had history variables with leading spaces. The history schema check then decides that this is a new variable (the leading space is not read from the history file) and starts a new file. We found this because the run start became slow due to the many, many history files created. It would be nice to just get an error if one has a malformed variable name like this.
How to reproduce: Try to put a variable with a leading space in the name into the history, repeatedly start runs.
Sugested fix: Produce an error if a history variable has a leading space. |
3053
|
10 Jun 2025 |
Stefan Ritt | Info | use of modified image showing MIDAS data format? |
> Hello, I'm currently writing a paper about making a dataset publicly available
> from the University of Minnesota and it's a MIDAS dataset.
>
> I'd like to use an image that shows the MIDAS data format (that's been slightly
> modified to fit in the paper) and am wondering (1) if I could get permission to do
> so and (2) what the preferred attribution would be.
Feel free to use whatever you like, the documentation is on the same open source license as midas itself.
Stefan |
3052
|
10 Jun 2025 |
Amy Roberts | Info | use of modified image showing MIDAS data format? |
Hello, I'm currently writing a paper about making a dataset publicly available
from the University of Minnesota and it's a MIDAS dataset.
I'd like to use an image that shows the MIDAS data format (that's been slightly
modified to fit in the paper) and am wondering (1) if I could get permission to do
so and (2) what the preferred attribution would be. |
3051
|
07 Jun 2025 |
Mark Grimes | Bug Report | Memory leak in mhttpd binary RPC code |
Hi,
We applied an intermediate fix for this locally and it seems to have fixed our issue. The attached plot shows the percentage memory use on our machine with 128 Gb memory, as a rough proxy for mhttpd memory use. After applying our fix mhttpd seems to be happy using ~7% of the memory after being up for 2.5 days.
Our fix to mjson was:
diff --git a/mjson.cxx b/mjson.cxx
index 17ee268..2443510 100644
--- a/mjson.cxx
+++ b/mjson.cxx
@@ -654,8 +654,7 @@ MJsonNode::~MJsonNode() // dtor
delete subnodes[i];
subnodes.clear();
- if (arraybuffer_size > 0) {
- assert(arraybuffer_ptr != NULL);
+ if (arraybuffer_ptr != NULL) {
free(arraybuffer_ptr);
arraybuffer_size = 0;
arraybuffer_ptr = NULL;
We also applied the following in midas for good measure, although I don't think it contributed to the leak we were seeing:
diff --git a/src/mjsonrpc.cxx b/src/mjsonrpc.cxx
index 2201d228..38f0b99b 100644
--- a/src/mjsonrpc.cxx
+++ b/src/mjsonrpc.cxx
@@ -3454,6 +3454,7 @@ static MJsonNode* brpc(const MJsonNode* params)
status = cm_connect_client(name.c_str(), &hconn);
if (status != RPC_SUCCESS) {
+ free(buf);
return mjsonrpc_make_result("status", MJsonNode::MakeInt(status));
}
I hope this is useful to someone. As previously mentioned we make heavy use of binary RPC, so maybe other experiments don't run into the same problem.
Thanks,
Mark. |
3050
|
04 Jun 2025 |
Konstantin Olchanski | Bug Report | Memory leak in mhttpd binary RPC code |
Noted. I will look at this asap. K.O.
[quote="Mark Grimes"]Hi,
During an evening of running we noticed that memory usage of mhttpd grew to
close to 100Gb. We think we've traced this to the following issue when making
RPC calls.
[LIST]
[*] The brpc method allocates memory for the response at
[URL=https://bitbucket.org/tmidas/midas/src/67db8627b9ae381e5e28800dfc4c350c5bd0
5e3f/src/mjsonrpc.cxx#lines-3449]src/mjsonrpc.cxx#lines-3449[/URL].
[*] It then makes the call at
[URL=https://bitbucket.org/tmidas/midas/src/67db8627b9ae381e5e28800dfc4c350c5bd0
5e3f/src/mjsonrpc.cxx#lines-3460]src/mjsonrpc.cxx#lines-3460[/URL], which may
set `buf_length` to zero if the response was empty.
[*] It then uses `MJsonNode::MakeArrayBuffer` to pass ownership of the memory to
an `MJsonNode`, providing `buf_length` as the size.
[*] When the `MJsonNode` is destructed at
[URL=https://bitbucket.org/tmidas/mjson/src/9d01b3f72722bbf7bcec32ae218fcc0825cc
9e7f/mjson.cxx#lines-657]mjson.cxx#lines-657[/URL], it only calls `free` on the
buffer if the size is greater than zero.
[/LIST]
Hence, mhttpd will leak at least 1024 bytes for every binary RPC call that
returns an empty response.
I tried to submit a pull request to fix this but I don't have permission to push
to https://bitbucket.org/tmidas/mjson.git. Could somebody take a look?
Thanks,
Mark.[/quote] |