Skip to content

Commit

Permalink
Throttle journalctl restarts
Browse files Browse the repository at this point in the history
This addresses an issue with typeahead search generating a significant
load on the system, a single filter test run can make ~100 calls to
journalctl restart if not throttled.
  • Loading branch information
justin-stephenson committed Jul 15, 2021
1 parent 6379950 commit d038d2b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"raw-loader": "^0.5.1",
"react": "16.13.1",
"react-dom": "16.13.1",
"throttle-debounce": "2.3.0",
"xterm": "^3.14.5"
}
}
9 changes: 7 additions & 2 deletions src/recordings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import {
SearchIcon
} from "@patternfly/react-icons";
import { global_danger_color_200 } from "@patternfly/react-tokens";
import { debounce } from 'throttle-debounce';

const $ = require("jquery");
const cockpit = require("cockpit");
Expand Down Expand Up @@ -741,6 +742,11 @@ export default class View extends React.Component {
this.setState({ recordingList: [] });
}

throttleJournalRestart = debounce(300, () => {
this.clearRecordings();
this.journalctlRestart();
});

handleInputChange(name, value) {
const state = {};
state[name] = value;
Expand Down Expand Up @@ -793,8 +799,7 @@ export default class View extends React.Component {
this.state.hostname !== prevState.hostname ||
this.state.search !== prevState.search
) {
this.clearRecordings();
this.journalctlRestart();
this.throttleJournalRestart();
}
}

Expand Down

0 comments on commit d038d2b

Please sign in to comment.