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

logging: fs backend: only fs_sync when done with a batch of logs #84979

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kamnxt
Copy link
Contributor

@kamnxt kamnxt commented Jan 31, 2025

The previous behavior was to call fs_sync on the file after every log item written. In many cases, log messages come in bursts, and log_core already operates in batches, configurable using
CONFIG_LOG_PROCESS_THREAD_SLEEP_MS and
CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD. Once the batch is done, the backends get notified with LOG_BACKEND_EVT_PROCESS_THREAD_DONE if any logs were processed. This is a nice time to fs_sync the written changes.

This change both speeds up the time spent writing logs and reduces the amount of block erases done on the flash, as the previous implementation erased blocks after each individual log message.

The previous behavior was to call `fs_sync` on the file after every log
item written. In many cases, log messages come in bursts, and `log_core`
already operates in batches, configurable using
`CONFIG_LOG_PROCESS_THREAD_SLEEP_MS` and
`CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD`. Once the batch is done, the
backends get notified with `LOG_BACKEND_EVT_PROCESS_THREAD_DONE` if any
logs were processed. This is a nice time to `fs_sync` the written changes.

This change both speeds up the time spent writing logs and reduces the
amount of block erases done on the flash, as the previous implementation
erased blocks after each individual log message.

Signed-off-by: Kamil Krzyzanowski <[email protected]>
@kamnxt kamnxt force-pushed the log_backend_fs_sync branch from c406520 to fa58fe2 Compare January 31, 2025 13:14
@kamnxt
Copy link
Contributor Author

kamnxt commented Jan 31, 2025

(I realize this is going to require some changes to the tests. Not sure what the best way forward is there?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants