Skip to content

Add journal-style log storage#3854

Merged
c-bata merged 103 commits intooptuna:masterfrom
rotaki:journal-storage-simple-v2
Sep 2, 2022
Merged

Add journal-style log storage#3854
c-bata merged 103 commits intooptuna:masterfrom
rotaki:journal-storage-simple-v2

Conversation

@rotaki
Copy link
Copy Markdown
Collaborator

@rotaki rotaki commented Aug 5, 2022

Motivation

Introduce JournalStorage to optuna.

Journal storage writes a record of every operation to the database as it is executed and at the same time, keeps a latest snapshot of the database in-memory. If the database crashes for any reason, the storage can re-establish the contents in memory by replaying the operations stored from the beginning.

Journal storage has several benefits over the conventional value logging storages.

  1. The number of IOs can be reduced because of larger granularity of logs.
  2. Journal storage (BaseJournalLogStorage) has a simpler backend API than the conventional storage (BaseStorage), which makes it easier to plug-in other backend implementations.
  3. Journal storage keeps a snapshot in-memory so it can avoid the use of internal cache, which reduces complications of code.

Description of the changes

  • optuna/storages/_journal/storage.py
    • Implementation of the BaseStorage named as JournalStorage.
  • optuna/storages/_journal/base.py
    • Abstract class of JournalStorage backend named as BaseJournalLogStorage.
  • optuna/storages/_journal/file.py
    • File storage backend that implements BaseJournalLogStorage named as JournalFileLogStorage. This file also contains implementations of locks needed for synchronizing processes.
  • tests/storages_tests/test_journal.py
    • Test JournalFileLogStorage.

References

Copy link
Copy Markdown
Member

@c-bata c-bata left a comment

Choose a reason for hiding this comment

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

Thank you for your pull request. Changes almost looks good to me.
I wrote some minor review comments.

Copy link
Copy Markdown
Member

@c-bata c-bata left a comment

Choose a reason for hiding this comment

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

LGTM after passed CI!

@c-bata c-bata added this to the v3.1.0 milestone Aug 30, 2022
@c-bata c-bata added the feature Change that does not break compatibility, but affects the public interfaces. label Aug 30, 2022
@c-bata c-bata removed their assignment Aug 30, 2022
@c-bata
Copy link
Copy Markdown
Member

c-bata commented Aug 31, 2022

Please merge the master branch to fix CI failures after #3950 is merged.

Copy link
Copy Markdown
Member

@keisuke-umezawa keisuke-umezawa left a comment

Choose a reason for hiding this comment

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

Thank you for updating it. LGTM.

Copy link
Copy Markdown
Member

@sile sile left a comment

Choose a reason for hiding this comment

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

LGTM

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

Labels

feature Change that does not break compatibility, but affects the public interfaces. optuna.storages Related to the `optuna.storages` submodule. This is automatically labeled by github-actions. optuna.testing Related to the `optuna.testing` submodule. This is automatically labeled by github-actions. optuna.trial Related to the `optuna.trial` submodule. This is automatically labeled by github-actions.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants