-
-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix slow write/append to files on ramfs
This patch improves performance and memory utilization when writing/appending to files on ramfs. Before this patch every write to a file when size needed to increase required allocating bigger buffer and copying all data from the old one to the new one. This especially applied to any type of log file residing on ramfs. In this case appending every single line required malloc(), free() and memcpy() leading to a lot of thrashing and potentially situation when big enough free fragment of memory was not available anymore to allocate. This patch changes internal data structure of how file data is stored by using std::map where keys are file offsets and values are file segments at that offset. This eliminates the need to copy data as well as only allocates enough memory needed for next 10% of file or desired increase. Fixes #884 Signed-off-by: Waldemar Kozaczuk <[email protected]>
- Loading branch information
Showing
2 changed files
with
150 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters