Skip to content

Reduce number of required file handles#650

Open
Phhere wants to merge 2 commits into
davidemms:masterfrom
Phhere:master
Open

Reduce number of required file handles#650
Phhere wants to merge 2 commits into
davidemms:masterfrom
Phhere:master

Conversation

@Phhere

@Phhere Phhere commented Nov 30, 2021

Copy link
Copy Markdown

I have created a small hack to reduce the number of file handles.

It uses python stringio to to everything in memory and just write the files on close.

To enable it use USE_MEM=1 as environment var

It will use much more memory but sometimes this is easier to archive as to change ulimits

@MrTomRod

MrTomRod commented Apr 21, 2022

Copy link
Copy Markdown

@davidemms @Phhere Why open all files at the same time? Is it much slower to open the necessary files in append mode? Something like this:

def WriteOlogLinesToFile(file: str, text: str, lock: Lock):
    if len(text) == 0:
        return
    if debug:
        util.PrintTime("Waiting: %d" % os.getpid())
    lock.acquire()
    try:
        if debug:
            util.PrintTime("Acquired lock: %d" % os.getpid())
        with open(file, 'a') as f:
            f.write(text)
    finally:
        lock.release()
        if debug: 
            util.PrintTime("Released lock: %d" % os.getpid())

@alexpmagalhaes

Copy link
Copy Markdown

Can you tell us more about memory requirements? How much more should we expect?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants