(Round 2) RFR(s): 8150460: (linux|bsd|aix)_close.c: file descriptor table may become large or may not work at all
thomas.stuefe at gmail.com
Thu Mar 10 12:59:40 UTC 2016
Thank you Dmitry!
I will fix the typo before comitting.
Kind Regards, Thomas
On Thu, Mar 10, 2016 at 9:19 AM, Dmitry Samersoff <
dmitry.samersoff at oracle.com> wrote:
> Looks good for me. But please wait for someone from core-libs team.
> PS: Could you also fix a typeo at 79, 51, 53?
> 51 * Heap allocated during initialization - one entry per fd
> On 2016-03-10 10:59, Thomas Stüfe wrote:
> > Hi,
> > may I have a review of this new iteration for this fix?
> > Thank you!
> > Thomas
> > On Thu, Mar 3, 2016 at 5:26 PM, Thomas Stüfe <thomas.stuefe at gmail.com>
> > wrote:
> >> Hi all,
> >> https://bugs.openjdk.java.net/browse/JDK-8150460
> >> thanks to all who took the time to review the first version of this fix!
> >> This is the new version:
> >> I reworked the fix, trying to add in all the input I got: This fix uses
> >> simple one-dimensional array, preallocated at startup, for low-value
> >> descriptors. Like the code did before. Only for large values of file
> >> descriptors it switches to an overflow table, organized as two
> >> sparse array of fixed sized slabs, which are allocated on demand. Only
> >> overflow table is protected by a lock.
> >> For 99% of all cases we will be using the plain simple fdTable structure
> >> as before. Only for unusually large file descriptor values we will be
> >> this overflow table.
> >> Memory footprint is kept low: for small values of RLIMIT_NOFILE, we will
> >> only allocate as much space as we need. Only if file descriptor values
> >> large, memory is allocated in the overflow table.
> >> Note that I avoided the proposed double-checked locking solution: I find
> >> it too risky in this place and also unnecessary. When calling
> >> we will be executing a blocking IO operation afterwards, flanked by two
> >> mutex locks (in startOp and endOp). So, I do not think the third mutex
> >> in getFdEntry will add much, especially since it is only used in case of
> >> larger file descriptor values.
> >> I also added the fix to bsd_close.c and aix_close.c. I do not like this
> >> code triplication. I briefly played around with unifying this code, but
> >> this is more difficult than it seems: implementations subtly differ
> >> the three platforms, and solaris implementation is completely
> different. It
> >> may be a worthwhile cleanup, but that would be a separate issue.
> >> I did some artificial tests to check how the code does with many and
> >> file descriptor values, all seemed to work well. I also ran java/net
> >> tests on Linux and AIX.
> >> Kind Regards, Thomas
> Dmitry Samersoff
> Oracle Java development team, Saint Petersburg, Russia
> * I would love to change the world, but they won't give me the sources.
More information about the core-libs-dev