Smaller block size results in low internal fragmentation as compared larger block sizes. Is it possible to have more internal fragmentation with a smaller Block size as compared to a larger Block size if we are allowed to use typical block size values (multiple of 2) i.e. 512, 1024 or 2048 bytes?

- 4,998
- 7
- 44
- 53

- 9
- 1
- 3
-
what is "internal fragmentation"? – Emanuele Paolini Jan 23 '13 at 10:22
1 Answers
That's a nice question.
Let me try an answer:
Internal fragmentation is the "waste" of bytes, when allocating memory for data. If the block size is e.g. 512 bytes, your data to be stored only 1 byte, there will be 511 bytes wasted, growing up with larger block sizes.
External fragmentation on the other hand, is the waste of memory place between used blocks. For example: There a memory blocks A, B and C with a 1 kbyte block size. If A and C are used, and there should be data stored with the size of 2 kbyte, the block B can't ever be used for that. So, that's why we have to defrag our HDDs and put data more efficient together.
As you ask: Is it possible to have more internal fragmentation with smaller blocksizes, the answer should be: It depends on what you will normally save.
Let's do some calculating:
Block size: 512 byte
Data to store: 64 kbyte
Blocks needed: 128
Internal fragmentation: 0%
Block size: 512 byte
Data to store: 64,1 kbyte
Blocks needed: 128,2
Internal fragmentation: 80% of 1 block
--
Block size: 2048 byte
Data to store: 64 kbyte
Blocks needed: 32
Internal fragmentation: 0%
Block size: 2048 byte
Data to store: 64,1 kbyte
Blocks needed: 32,05
Internal fragmentation: 95% of 1 block
--
Block size: 4096 byte
Data to store: 64 kbyte
Blocks needed: 32
Internal fragmentation: 0%
Block size: 4096 byte
Data to store: 64,1 kbyte
Blocks needed: 16,025
Internal fragmentation: 97,5% of 1 block
So, it's depending on what you save. You won't never have any system, where files will always have an average size. There will always be big files and many smaller ones, so a tradeoff is needed.
With a big block size, you will have more internal defragmentation, but then the external fragmentation would be better (as there will be much space between reserved blocks). And on the other hand, small block sizes will increase the size of external fragmentation, but the internal would be smaller.
In general, larger block sizes will always increase internal fragmentation. Best is a tradeoff between block size, internal fragmentation, disk access time and page table size.

- 4,998
- 7
- 44
- 53
-
One exception, that comes to my mind: If there will be a large amount of small files, just like a exploratory PC, that will create thousands of byte-size files e.g., you could think about decreasing the block size to avoid too much internal fragmentation. – ConcurrentHashMap Jan 23 '13 at 14:20