Skip to content

Commit e41b7b4

Browse files
committed
Regenerate remove_default_chunk_size.patch for current version, add a note at the top to not use without changing your usage patterns as well, otherwise significant loss of performance. Probably is not ready for use at all yet, still needs some work on performance issues.
1 parent 21cf00b commit e41b7b4

1 file changed

Lines changed: 36 additions & 36 deletions

File tree

remove_default_chunk_size.patch

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
This will remove the default chunk size for each priority level.
2+
3+
Do not yet use, this is a work-in-progress, and if you do not specify explicit chunk sizes, you will suffer a significant drop in performance.
4+
15
diff --git a/nonblock/BackgroundWrite.py b/nonblock/BackgroundWrite.py
2-
index efb15ea..26932e3 100644
6+
index 8b9765c..b76cc28 100644
37
--- a/nonblock/BackgroundWrite.py
48
+++ b/nonblock/BackgroundWrite.py
5-
@@ -18,8 +18,9 @@ __all__ = ('BackgroundWriteProcess', 'BackgroundIOPriority', 'bgwrite', 'bgwrite
6-
7-
DEBUG = False
9+
@@ -26,8 +26,9 @@ __all__ = ('BackgroundWriteProcess', 'BackgroundIOPriority', 'bgwrite', 'bgwrite
10+
# Uncomment the "DEBUG" sections you want to see below. Search for DEBUG.
11+
#DEBUG = False
812

913
+_SIZE_MEG = 1024 * 1024
1014

@@ -13,7 +17,7 @@ index efb15ea..26932e3 100644
1317
'''
1418
bgwrite - Start a background writing process
1519

16-
@@ -38,7 +39,7 @@ def bgwrite(fileObj, data, closeWhenFinished=False, chainAfter=None, ioPrio=4):
20+
@@ -46,7 +47,7 @@ def bgwrite(fileObj, data, closeWhenFinished=False, chainAfter=None, ioPrio=4):
1721
@return - BackgroundWriteProcess - An object representing the state of this operation. @see BackgroundWriteProcess
1822
'''
1923

@@ -22,7 +26,7 @@ index efb15ea..26932e3 100644
2226
thread.start()
2327

2428
return thread
25-
@@ -57,9 +58,9 @@ def bgwrite_chunk(fileObj, data, chunkSize, closeWhenFinished=False, chainAfter=
29+
@@ -65,9 +66,9 @@ def bgwrite_chunk(fileObj, data, chunkSize, closeWhenFinished=False, chainAfter=
2630

2731
@param chunkSize <integer> - The max siZe of each chunk.
2832
'''
@@ -34,7 +38,7 @@ index efb15ea..26932e3 100644
3438

3539

3640
class BackgroundIOPriority(object):
37-
@@ -69,9 +70,9 @@ class BackgroundIOPriority(object):
41+
@@ -77,9 +78,9 @@ class BackgroundIOPriority(object):
3842
See __init__ for fields
3943
'''
4044

@@ -46,7 +50,7 @@ index efb15ea..26932e3 100644
4650
'''
4751
__init__ - Create a BackgroundIOPriority.
4852

49-
@@ -81,12 +82,6 @@ class BackgroundIOPriority(object):
53+
@@ -89,12 +90,6 @@ class BackgroundIOPriority(object):
5054
@param chainPollTime - float > 0, When chaining, this is the sleep time between checking if prior is finished.
5155
Too low and the polling takes up CPU time, too high and you'll lose a little time in between chained writes, while gaining interactivity elsewhere.
5256

@@ -59,7 +63,7 @@ index efb15ea..26932e3 100644
5963
A high number means higher throughput at the cost of lest interactivity for other tasks, a low number means the opposite.
6064

6165
So, for example, a bandwidthPct of "50" will attempt to use "50%" of the available bandwidth. Note, this does not represent theroetical
62-
@@ -99,7 +94,7 @@ class BackgroundIOPriority(object):
66+
@@ -107,7 +102,7 @@ class BackgroundIOPriority(object):
6367
See #bandwidthPct for the other half of the story. The higher this number, the more "fair" your application will be against a constant
6468
rate of I/O by other applications, but the less able it may be to play fair when the external I/O is spiking.
6569

@@ -68,46 +72,42 @@ index efb15ea..26932e3 100644
6872
but you may want to tune it if you use really large or really small chunk sizes.
6973

7074

71-
@@ -108,7 +103,6 @@ class BackgroundIOPriority(object):
75+
@@ -116,7 +111,6 @@ class BackgroundIOPriority(object):
7276

7377

7478
self.chainPollTime = chainPollTime
7579
- self.defaultChunkSize = defaultChunkSize
7680
self.bandwidthPct = float(bandwidthPct)
7781
if bandwidthPct <= 0 or bandwidthPct > 100:
7882
raise ValueError('Given bandwidthPct %f must be > 0 and <= 100')
79-
@@ -126,20 +120,19 @@ class BackgroundIOPriority(object):
80-
raise KeyError('Unknown key: %s\n' %(key,))
81-
82-
83-
-_SIZE_MEG = 1024 * 1024
83+
@@ -138,16 +132,16 @@ _SIZE_MEG = 1024 * 1024
8484

8585
# BG_IO_PRIOS - Predefined I/O priorities, 1-10. The lower the number, the more throughput at the cost of interactivity
8686
BG_IO_PRIOS = {
8787
- 1 : BackgroundIOPriority(.0009, _SIZE_MEG * 5, 100), # Maximum throughput, no regard for interactivity.
8888
- 2 : BackgroundIOPriority(.0009, _SIZE_MEG * 4, 90),
89-
- 3 : BackgroundIOPriority(.0015, _SIZE_MEG * 3, 80),
90-
- 4 : BackgroundIOPriority(.0015, _SIZE_MEG * 2, 75),
91-
- 5 : BackgroundIOPriority(.0019, _SIZE_MEG * 1.25, 65),
92-
- 6 : BackgroundIOPriority(.0019, _SIZE_MEG * .6, 55),
93-
- 7 : BackgroundIOPriority(.0024, _SIZE_MEG * .4, 45),
94-
- 8 : BackgroundIOPriority(.0024, _SIZE_MEG * .25, 35),
95-
- 9 : BackgroundIOPriority(.0031, _SIZE_MEG * .175, 31),
96-
- 10 : BackgroundIOPriority(.0100, _SIZE_MEG * .1, 25), # Least throughput, most interactivity, very little throughput
97-
+ 1 : BackgroundIOPriority(.0009, 100), # Maximum throughput, no regard for interactivity.
98-
+ 2 : BackgroundIOPriority(.0009, 90),
99-
+ 3 : BackgroundIOPriority(.0015, 80),
100-
+ 4 : BackgroundIOPriority(.0015, 75),
101-
+ 5 : BackgroundIOPriority(.0019, 65),
102-
+ 6 : BackgroundIOPriority(.0019, 55),
103-
+ 7 : BackgroundIOPriority(.0024, 45),
104-
+ 8 : BackgroundIOPriority(.0024, 35),
105-
+ 9 : BackgroundIOPriority(.0031, 31),
106-
+ 10 : BackgroundIOPriority(.0100, 25), # Least throughput, most interactivity, very little throughput
89+
- 3 : BackgroundIOPriority(.0015, _SIZE_MEG * 3, 78),
90+
- 4 : BackgroundIOPriority(.0015, _SIZE_MEG * 2, 72),
91+
- 5 : BackgroundIOPriority(.0019, _SIZE_MEG * 1.6, 65),
92+
- 6 : BackgroundIOPriority(.0019, _SIZE_MEG * .75, 55),
93+
- 7 : BackgroundIOPriority(.0024, _SIZE_MEG * .69, 45),
94+
- 8 : BackgroundIOPriority(.0024, _SIZE_MEG * .5, 35),
95+
- 9 : BackgroundIOPriority(.0031, _SIZE_MEG * .3, 30),
96+
- 10 : BackgroundIOPriority(.0100, _SIZE_MEG * .25, 20), # Least throughput, most interactivity, very little throughput
97+
+ 1 : BackgroundIOPriority(.0009, 100), # Maximum throughput, no regard for interactivity.
98+
+ 2 : BackgroundIOPriority(.0009, 90),
99+
+ 3 : BackgroundIOPriority(.0015, 78),
100+
+ 4 : BackgroundIOPriority(.0015, 72),
101+
+ 5 : BackgroundIOPriority(.0019, 65),
102+
+ 6 : BackgroundIOPriority(.0019, 55),
103+
+ 7 : BackgroundIOPriority(.0024, 45),
104+
+ 8 : BackgroundIOPriority(.0024, 35),
105+
+ 9 : BackgroundIOPriority(.0031, 30),
106+
+ 10 : BackgroundIOPriority(.0100, 20), # Least throughput, most interactivity, very little throughput
107107
}
108108

109109

110-
@@ -157,7 +150,7 @@ class BackgroundWriteProcess(threading.Thread):
110+
@@ -165,7 +159,7 @@ class BackgroundWriteProcess(threading.Thread):
111111
'''
112112
# Design question: What about errors?
113113

@@ -116,7 +116,7 @@ index efb15ea..26932e3 100644
116116
'''
117117
__init__ - Create the BackgroundWriteProcess thread. You should probably use bgwrite or bgwrite_chunk instead of calling this directly.
118118

119-
@@ -171,6 +164,12 @@ class BackgroundWriteProcess(threading.Thread):
119+
@@ -179,6 +173,12 @@ class BackgroundWriteProcess(threading.Thread):
120120

121121
@param ioPrio <int/BackgroundIOPriority> - If an integer (1-10), a predefined BackgroundIOPriority will be used. 1 is highest throughput, 10 is most interactivity. You can also pass in your own BackgroundIOPriority object if you want to define a custom profile.
122122

@@ -129,7 +129,7 @@ index efb15ea..26932e3 100644
129129

130130
@raises ValueError - If ioPrio is neither a BackgroundIOPriority nor integer 1-10 inclusive
131131
- If chainAfter is not a BackgroundWriteProcess or None
132-
@@ -187,7 +186,8 @@ class BackgroundWriteProcess(threading.Thread):
132+
@@ -195,7 +195,8 @@ class BackgroundWriteProcess(threading.Thread):
133133
raise ValueError('Invalid ioPrio: %s. Available priority levels are: %s' %(str(ioPrio), str(list(BG_IO_PRIOS.keys()))) )
134134

135135
if type(dataBlocks) not in (list, tuple):

0 commit comments

Comments
 (0)