Skip to content

Commit 4251995

Browse files
committed
#267 Remove memory leak in license detection match merging
* Do not carry line_by_pos mapping in matches. Instead only inject start and end line in matches at the end using the query line_by_pos mapping kept only globally and not on a per-match basis. This was the source of a major memory leak when license matches were being updated and combined during a merge() run. * Use a list-based mapping for line_by_pos instead of a dic for smaller memory footprint. * Use slots for QueryRun attributes for smaller memory footprint * Replace "solid" attribute for Rules with a minimum_score that a match to a rule must equal or exceed. solid is now minimum_score: 100. Use this in other rules with various minimu score as needed. * Remove remaining references to "gaps". * Fix incorrect Rule thresholds computation for minimum lengths. * Do not use license matches cache for now (the sqlite-backed diskcache-based implementation is the source of major slowdown). * Various minor cleanup and updates on rules, licenses and their corresponding tests. * New batch of frequent tokens for license detection. * Add new tests contributed by @yahalom5776 * Add new license match filter for matches to a whole rule made of a single token that is surrounded by unknown or single letter tokens such as in "a b c d e GPL 1 2 3 4" to discard some false positive (in this case for a GPL). This required to add tracking of query tokens made on a single character. Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent 8d54e50 commit 4251995

137 files changed

Lines changed: 1141 additions & 425 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/licensedcode/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2015 nexB Inc. and others. All rights reserved.
2+
# Copyright (c) 2016 nexB Inc. and others. All rights reserved.
33
# http://nexb.com and https://github.com/nexB/scancode-toolkit/
44
# The ScanCode software is licensed under the Apache License version 2.0.
55
# Data generated with ScanCode require an acknowledgment.
@@ -52,9 +52,6 @@
5252
MIN_MATCH_LENGTH = 4
5353
MIN_MATCH_HIGH_LENGTH = 3
5454

55-
# maximum number of non-matching tokens that can be skipped
56-
MAX_GAP_SKIP = 15
57-
5855
# maximum distance between two matches to merge
5956
MAX_DIST = 120
6057

src/licensedcode/data/licenses/day-spec.LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
[Day Specification License]
2+
3+
Day Management AG ("Licensor") is willing to license this specification
4+
to you ONLY UPON THE CONDITION THAT YOU ACCEPT ALL OF THE TERMS CONTAINED
5+
IN THIS LICENSE AGREEMENT ("Agreement"). Please read the terms and
6+
conditions of this Agreement carefully.
7+
18
Content Repository for JavaTM Technology API Specification ("Specification")
29
Version: 1.0
310
Status: FCS

src/licensedcode/data/licenses/tatu-ylonen.LICENSE

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
Tatu Ylonen License
22

3-
* Author: Tatu Ylonen <ylo@cs.hut.fi>
4-
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
5-
* All rights reserved
6-
* Versions of malloc and friends that check their results, and never return
7-
* failure (they call fatal if they encounter an error).
8-
*
93
* As far as I am concerned, the code I have written for this software
104
* can be used freely for any purpose. Any derived versions of this
115
* software must be clearly marked as such, and if the derived work is

src/licensedcode/data/licenses/zlib.SPDX

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
licenses:
22
- 3pp-proprietary-08
3-
solid: yes
3+
minimum_score: 100
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
licenses:
22
- adobe-scl
3-
solid: yes
3+
minimum_score: 100
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
licenses:
22
- afl-2.1
33
- bsd-new
4-
solid: yes
4+
minimum_score: 100
55
license_choice: yes
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
licenses:
22
- apache-1.1
3-
solid: yes
3+
minimum_score: 100
44
notes: >
55
Notice found in http://apache.org/licenses/LICENSE-1.1
66
but it is really specific to an Apache Software Foundation component.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
licenses:
22
- apache-1.1
3-
solid: yes
3+
minimum_score: 100
44
notes: Old, original Apache 1.1 URL
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
licenses:
22
- apache-1.1
3-
solid: yes
3+
minimum_score: 100

0 commit comments

Comments
 (0)