Random long I / O delays during periodic data recording

I am writing an Android application. As far as I know, most SD cards in devices have a write speed of ~ 4 Mbps. In the worst case, my application should create and write ~ 0.5Mb to a new file about 5 times per second. As a rule, IO does this very quickly, but after creating and writing several files in a short period of time, I experience a sudden long wait time of ~ 2 seconds.

Here are some statistics from my application (note that only one I / O operation is performed at a time):

E  = Time IO operation began
S  = Number of Mbs written
WT = Time taken to write to file

E      S        WT     
14.546 ~0.41 MB 0.02s
15.061 ~0.40 MB 0.019s
15.600 ~0.42 MB 0.073s
16.054 ~0.41 MB 0.02s
16.538 ~0.36 MB 0.019s
17.007 ~0.33 MB 0.018s
17.475 ~0.32 MB 0.017s
18.030 ~0.38 MB 0.07s
19.991 ~0.38 MB 1.542s <--
20.124 ~0.34 MB 0.018s
20.233 ~0.25 MB 0.015s
20.390 ~0.38 MB 0.021s
20.624 ~0.36 MB 0.08s
20.858 ~0.37 MB 0.018s
21.304 ~0.32 MB 0.018s
21.796 ~0.33 MB 0.017s
22.257 ~0.35 MB 0.02s
22.780 ~0.37 MB 0.07s
24.366 ~0.27 MB 1.178s <--
24.522 ~0.40 MB 0.021s
24.648 ~0.34 MB 0.019s
24.866 ~0.38 MB 0.018s
25.319 ~0.29 MB 0.07s
25.850 ~0.45 MB 0.021s
26.288 ~0.39 MB 0.018s
26.796 ~0.43 MB 0.035s
27.249 ~0.33 MB 0.069s
27.671 ~0.41 MB 0.018s
30.054 ~0.44 MB 1.874s <--

, - < 0,05 , , ~ 4 , - ~ 1,5 . ? .

( ):

  RandomAccessFile fos = new RandomAccessFile(filename, "rw");
  FileChannel outChannel = fos.getChannel();
  byteBuffer.rewind();
  outChannel.write(byteBuffer);
  fos.close();

- , , - , , , , . ? , - , .

: mementos undo/redo , , . , , mementos . , , , -, 1,5 , . , , undo/redo, .

+3
1

?

flash.

- , , - , , , , .

, . Android YAFFS2, , . , , , , - , .

Android (, Nexus S) ext4, / .

, , - , , ..

, Brad Fitzpatrick 2010 Google | O " Android Zippy", .

?

. -/ , , AsyncTask. StrictMode Android 2.3 , "janky" .

+3

Source: https://habr.com/ru/post/1789382/


All Articles