Skip to content

Commit

Permalink
Add option to disable the optimization.
Browse files Browse the repository at this point in the history
  • Loading branch information
fchirica committed Apr 26, 2024
1 parent 7fcfc92 commit 8d48f90
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion chia/data_layer/data_layer.py
Expand Up @@ -299,7 +299,8 @@ async def batch_insert(
raise ValueError(f"Singleton with launcher ID {tree_id} is not owned by DL Wallet")

t1 = time.monotonic()
batch_hash = await self.data_store.insert_batch(tree_id, changelist, status)
enable_batch_autoinsert = self.config.get("enable_batch_autoinsert", True)
batch_hash = await self.data_store.insert_batch(tree_id, changelist, status, enable_batch_autoinsert)
t2 = time.monotonic()
self.log.info(f"Data store batch update process time: {t2 - t1}.")
# todo return empty node hash from get_tree_root
Expand Down
3 changes: 2 additions & 1 deletion chia/data_layer/data_store.py
Expand Up @@ -1332,6 +1332,7 @@ async def insert_batch(
tree_id: bytes32,
changelist: List[Dict[str, Any]],
status: Status = Status.PENDING,
enable_batch_autoinsert: bool = True,
) -> Optional[bytes32]:
async with self.transaction():
old_root = await self.get_tree_root(tree_id)
Expand Down Expand Up @@ -1369,7 +1370,7 @@ async def insert_batch(
# The key is not referenced in any other operation but this autoinsert, hence the order
# of performing these should not matter. We perform all these autoinserts as a batch
# at the end, to speed up the tree processing operations.
if key_hash_frequency[hash] == 1:
if key_hash_frequency[hash] == 1 and enable_batch_autoinsert:
terminal_node_hash = await self._insert_terminal_node(key, value)
pending_autoinsert_hashes.append(terminal_node_hash)
continue
Expand Down
3 changes: 3 additions & 0 deletions chia/util/initial-config.yaml
Expand Up @@ -687,6 +687,9 @@ data_layer:
# separate log file (under logging/data_sql.log).
log_sqlite_cmds: False

# Speeds up autoinserts. Disable to perform inserts one by one instead of in a batch.
enable_batch_autoinsert: True

logging: *logging

ssl:
Expand Down

0 comments on commit 8d48f90

Please sign in to comment.