Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add memory monitoring to livereduce #15

Merged
merged 3 commits into from
Nov 26, 2024
Merged

Conversation

rosswhitfield
Copy link
Member

Ref: 6960: [LIVEREDUCTION] Add memory monitoring

It works by creating function running in it's own thread that is checking the memory usage. If it gets above the set percentage it will stop live data, clear the workspaces and restart live data. This seemed like a better solution then running mantid in a subprocess, MonitorLiveData is already running in it's own thread anyway.

To test I created another example in the test folder using FakeISISEventDAE where it's producing lots of events and the proceeding will just accumulated all the events quickly using up the available memory.

Start the fake server

python test/fake_event_server.py

start livereduce

python scripts/livereduce.py test/fake_event.conf

and you should see live data getting restarted after it uses 25% of your memory.

@peterfpeterson peterfpeterson changed the title This add memory monitoring to livereduce Add memory monitoring to livereduce Nov 25, 2024
@backmari
Copy link

Successfully ran the test. The livereduce process is stopped when it reaches 25% of my system memory and restarted after 1 s.
Screenshot from 2024-11-25 09-10-10
The log file shows a message about exceeding the memory limit:

2024-11-25 09:08:47,229 - livereduce - ERROR - Memory usage 8442.67 MB exceeds limit
2024-11-25 09:08:47,229 - livereduce.LiveDataManager - INFO - Restarting Live Data and clearing workspaces
2024-11-25 09:08:47,229 - livereduce.LiveDataManager - INFO - stopping live data processing
2024-11-25 09:08:47,299 - Mantid - WARNING - Plus: Execution cancelled by user.
2024-11-25 09:08:47,339 - Mantid - WARNING - MonitorLiveData: Execution cancelled by user.
2024-11-25 09:08:48,537 - livereduce.LiveDataManager - INFO - StartLiveData({
  "AccumulationMethod": "Add",
  "FromNow": false,
  "FromStartOfRun": true,
  "Instrument": "ISIS_Event",
  "OutputWorkspace": "result",
  "PreserveEvents": true,
  "ProcessingScriptFilename": "/home/u5z/projects/livereduce/test/reduce_ISIS_Event_live_proc.py",
  "UpdateEvery": 3
})
2024-11-25 09:08:48,706 - Mantid - INFO - StartLiveData started

Copy link
Member

@peterfpeterson peterfpeterson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I appreciate the extra information in the README for configuring this option.

scripts/livereduce.py Outdated Show resolved Hide resolved
Copy link

@backmari backmari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small change

Copy link

@backmari backmari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@rosswhitfield rosswhitfield merged commit e846a70 into main Nov 26, 2024
2 checks passed
@rosswhitfield rosswhitfield deleted the memory_monitoring branch November 26, 2024 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants