transformers-0001/ray-project-0001/dask-project-0001/dask-project-0002: 4 CWE-407 defects across 3 ML/data targets
transformers-0001: tokenization_python convert_ids_to_tokens O(T×S) property-rebuild-per-token MEDIUM 3.1x ray-project-0001: dag_node _get_toplevel_child_nodes O(A²) list dedup MEDIUM 1.5x dask-project-0001: parquet filter_partitions disjunction O(P×O) list dedup MEDIUM-HIGH 65x dask-project-0002: methods describe_aggregate O(C²) column name dedup LOW-MEDIUM 12.7x
This commit is contained in:
parent
4560936024
commit
13a4de8613
11 changed files with 486 additions and 0 deletions
30
defects/dask-project/patch/dask-project-0001.patch
Normal file
30
defects/dask-project/patch/dask-project-0001.patch
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# dask-project-0001: parquet/core.py filter_partitions disjunction O(P×O) dedup
|
||||
# CWE-407 — Algorithmic Complexity
|
||||
#
|
||||
# In _filter_partitions(), when combining disjunctions (OR filters), each
|
||||
# partition from a disjunction branch is checked with `if part not in out_parts`
|
||||
# where out_parts is a growing list. This is O(P × O) where P = partitions from
|
||||
# each disjunction and O = accumulated output size.
|
||||
#
|
||||
# For large parquet datasets with many row groups (P=10000+) and multiple
|
||||
# OR filter clauses, this becomes a significant bottleneck.
|
||||
#
|
||||
# Fix: maintain a parallel set of part identities for O(1) membership.
|
||||
# Severity: MEDIUM-HIGH (data I/O path, P can be 10000+ for large datasets)
|
||||
# Speedup: ~50x at P=5000
|
||||
#
|
||||
# File: dask/dataframe/io/parquet/core.py
|
||||
# Function: _filter_partitions
|
||||
--- a/dask/dataframe/io/parquet/core.py
|
||||
+++ b/dask/dataframe/io/parquet/core.py
|
||||
@@ -558,9 +558,11 @@
|
||||
|
||||
out_parts, out_statistics = apply_conjunction(parts, statistics, conjunction)
|
||||
+ out_parts_set = set(id(p) for p in out_parts)
|
||||
for conjunction in disjunction:
|
||||
for part, stats in zip(*apply_conjunction(parts, statistics, conjunction)):
|
||||
- if part not in out_parts:
|
||||
+ if id(part) not in out_parts_set:
|
||||
out_parts.append(part)
|
||||
+ out_parts_set.add(id(part))
|
||||
out_statistics.append(stats)
|
||||
Loading…
Add table
Add a link
Reference in a new issue