Skip to content
This repository was archived by the owner on Jan 31, 2024. It is now read-only.
This repository was archived by the owner on Jan 31, 2024. It is now read-only.

Unable to Have More Than 1024 File Descriptors at Once #197

@heindelj

Description

@heindelj

Hi,

For some context, I have hooked up a potential to the driver code which comes with i-PI as this is probably the easiest way to use a personal potential as far as I can see. This works fine, but I need to print a property for each bead (from the extras), and am also using more than 1024 beads in some simulations at very low temperatures.

When this is done, the following error is given:

Exception in thread poll_driver:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/Users/hein071/research/i-pi-dev/ipi/engine/forcefields.py", line 166, in _poll_loop
self.poll()
File "/Users/hein071/research/i-pi-dev/ipi/engine/forcefields.py", line 260, in poll
self.socket.poll()
File "/Users/hein071/research/i-pi-dev/ipi/interfaces/sockets.py", line 674, in poll
self.pool_update()
File "/Users/hein071/research/i-pi-dev/ipi/interfaces/sockets.py", line 514, in pool_update
readable, writable, errored = select.select([self.server], [], [], searchtimeout)
ValueError: filedescriptor out of range in select()

To the best of my knowledge, this error is independent of whether a unix or inet socket is used, but I have noted that more than 1024 beads are possible if the extra files are not opened. I do not know if this is only a problem when using the driver interface, or if using e.g. LAMMPS for forces would have the same problem.

After doing some googling, this is a known limitation of select.select(). I don't think it is mentioned in the documentation I just linked, but it is noted in the NOTES sections at that site. Specifically, FD_SETSIZE is 1024 on linux systems, so select() can only monitor up to 1024 file descriptors at a time.

That being said, the problem can apparently be fixed with minimal changes by using select.poll() rather than select.select(), but I do not know if I can fix this properly myself, so I thought I would mention the problem here. I believe the only real changes needed are that whenever a new file descriptor is set, it needs to be registered using poll.register() and then select.poll() needs to be called rather than select.select().

To be clear, this is not a bug in i-PI but a limitation of the python (and hence underlying C) module select(), but there is a solution which can be implemented in i-PI with only minor changes using poll(). Unfortunately, the details have prevented me from being able to fix this myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions