Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Options:
- `--max-age` - Considers only rows younger than specified. See `--min-age`.
- `--bisection-factor` - Segments per iteration. When set to 2, it performs binary search.
- `--bisection-threshold` - Minimal bisection threshold. i.e. maximum size of pages to diff locally.
- `-j` or `--threads` - Number of worker threads to use per database. Default=1.


# How does it work?
Expand Down
28 changes: 21 additions & 7 deletions data_diff/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@
@click.option("-v", "--verbose", is_flag=True, help="Print extra info")
@click.option("-i", "--interactive", is_flag=True, help="Confirm queries, implies --debug")
@click.option(
"-j", "--threads", default=None, help="Number of threads to use. 1 means no threading. Auto if not specified."
"-j",
"--threads",
default="1",
help="Number of worker threads to use per database. Default=1. "
"A higher number will increase performance, but take more capacity from your database. "
"'serial' guarantees a single-threaded execution of the algorithm (useful for debugging).",
)
def main(
db1_uri,
Expand Down Expand Up @@ -76,11 +81,20 @@ def main(
elif verbose:
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT, datefmt=DATE_FORMAT)

threaded = True
if threads is not None:
threads = int(threads)
if threads < 1:
logging.error("Error: threads must be >= 1")
return
if threads.lower() == "serial":
threaded = False
threads = 1
else:
try:
threads = int(threads)
except ValueError:
logger.error("Error: threads must be a number, 'auto', or 'serial'.")
return
if threads < 1:
logging.error("Error: threads must be >= 1")
return

db1 = connect_to_uri(db1_uri, threads)
db2 = connect_to_uri(db2_uri, threads)
Expand All @@ -106,8 +120,8 @@ def main(
bisection_factor=bisection_factor,
bisection_threshold=bisection_threshold,
debug=debug,
threaded=threads != 1,
max_threadpool_size=threads,
threaded=threaded,
max_threadpool_size=threads and threads * 2,
)
diff_iter = differ.diff_tables(table1, table2)

Expand Down