Skip to content

Commit

Permalink
Merge pull request #79 from realratchet/master
Browse files Browse the repository at this point in the history
* enable logical cores on non windows machines
  • Loading branch information
realratchet authored Aug 28, 2023
2 parents 391ee09 + ba9af74 commit 90a181b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions tablite/import_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
import os
import math
import platform
import psutil
from pathlib import Path
import pyexcel
Expand Down Expand Up @@ -569,8 +570,15 @@ class PatchTqdm: # we need to re-use the tqdm pbar, this will patch
def update(self, n=1):
pbar.update(n * dump_size)

cpus = max(psutil.cpu_count(logical=False), 1) # there's always at least one core.
# do not set logical to true as windows cannot handle that many file handles.
"""
all modern processors have more than one thread per core intel has hyper-threading, amd has SMT
we don't want to stop using potentially half of our cores on other OS'es because windows can't that many file handles
"""
is_windows = platform.system() == "Windows"
use_logical = False if is_windows else True

cpus = max(psutil.cpu_count(logical=use_logical), 1) # there's always at least one core.

cpus_needed = min(len(tasks), cpus) # 4 columns won't require 96 cpus ...!
if cpus_needed < 2 or Config.MULTIPROCESSING_MODE == Config.FALSE:
for task in tasks:
Expand Down
2 changes: 1 addition & 1 deletion tablite/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
major, minor, patch = 2023, 7, "dev1"
major, minor, patch = 2023, 7, "dev2"
__version_info__ = (major, minor, patch)
__version__ = ".".join(str(i) for i in __version_info__)

0 comments on commit 90a181b

Please sign in to comment.