From 24d0d62c3105ab9e777432f9d76613f9d5590d2c Mon Sep 17 00:00:00 2001 From: joeshaw Date: Mon, 3 Apr 2006 17:12:17 +0000 Subject: [PATCH] Update the thread-local storage patch, to fix #335178 --- beagled/Lucene.Net/Index/SegmentReader.cs | 4 ++- beagled/Lucene.Net/Index/TermInfosReader.cs | 2 ++ .../19_no_thread_local_storage.patch | 37 +++++++++++++++------- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/beagled/Lucene.Net/Index/SegmentReader.cs b/beagled/Lucene.Net/Index/SegmentReader.cs index 5d827aab..11f5ed0d 100644 --- a/beagled/Lucene.Net/Index/SegmentReader.cs +++ b/beagled/Lucene.Net/Index/SegmentReader.cs @@ -26,7 +26,7 @@ namespace Lucene.Net.Index /// FIXME: Describe class SegmentReader here. /// /// - /// $Id: SegmentReader.cs,v 1.4 2006/03/15 19:12:18 joeshaw Exp $ + /// $Id: SegmentReader.cs,v 1.5 2006/04/03 17:12:17 joeshaw Exp $ /// class SegmentReader : IndexReader { @@ -37,6 +37,8 @@ namespace Lucene.Net.Index internal TermInfosReader tis; internal TermVectorsReader termVectorsReaderOrig = null; + + [ThreadStatic] private TermVectorsReader tvReader; internal BitVector deletedDocs = null; diff --git a/beagled/Lucene.Net/Index/TermInfosReader.cs b/beagled/Lucene.Net/Index/TermInfosReader.cs index 32546469..3a27f809 100644 --- a/beagled/Lucene.Net/Index/TermInfosReader.cs +++ b/beagled/Lucene.Net/Index/TermInfosReader.cs @@ -29,7 +29,9 @@ namespace Lucene.Net.Index private System.String segment; private FieldInfos fieldInfos; + [ThreadStatic] private SegmentTermEnum termEnum; + private SegmentTermEnum origEnum; private long size; diff --git a/beagled/Lucene.Net/upstream-changes/19_no_thread_local_storage.patch b/beagled/Lucene.Net/upstream-changes/19_no_thread_local_storage.patch index 4f135371..ce03eada 100644 --- a/beagled/Lucene.Net/upstream-changes/19_no_thread_local_storage.patch +++ b/beagled/Lucene.Net/upstream-changes/19_no_thread_local_storage.patch @@ -3,28 +3,39 @@ From: Joe Shaw Lucene uses thread-local storage for caching some data in a threadsafe way. Mono up through 1.1.13.4 leaks all data set using Thread.SetData(), and this accounts for huge memory spikes in Beagle in the file system backend on -inotify events and any time a query is run. It is safe for us because we -never share these instances across threads. +inotify events and any time a query is run. Instead we'll just declare the +items ThreadStatic. Index: Index/SegmentReader.cs =================================================================== RCS file: /cvs/gnome/beagle/beagled/Lucene.Net/Index/SegmentReader.cs,v retrieving revision 1.3 -diff -u -p -u -r1.3 SegmentReader.cs +diff -u -p -r1.3 SegmentReader.cs --- Index/SegmentReader.cs 6 Oct 2005 19:29:55 -0000 1.3 -+++ Index/SegmentReader.cs 15 Mar 2006 18:58:16 -0000 -@@ -36,8 +36,8 @@ namespace Lucene.Net.Index ++++ Index/SegmentReader.cs 3 Apr 2006 17:09:07 -0000 +@@ -26,7 +26,7 @@ namespace Lucene.Net.Index + /// FIXME: Describe class SegmentReader here. + /// + /// +- /// $Id: 19_no_thread_local_storage.patch,v 1.2 2006/04/03 17:12:18 joeshaw Exp $ ++ /// $Id: 19_no_thread_local_storage.patch,v 1.2 2006/04/03 17:12:18 joeshaw Exp $ + /// + class SegmentReader : IndexReader + { +@@ -36,8 +36,10 @@ namespace Lucene.Net.Index private FieldsReader fieldsReader; internal TermInfosReader tis; - internal TermVectorsReader termVectorsReaderOrig = null; - internal System.LocalDataStoreSlot termVectorsLocal = System.Threading.Thread.AllocateDataSlot(); + internal TermVectorsReader termVectorsReaderOrig = null; ++ ++ [ThreadStatic] + private TermVectorsReader tvReader; internal BitVector deletedDocs = null; private bool deletedDocsDirty = false; -@@ -172,19 +172,6 @@ namespace Lucene.Net.Index +@@ -172,19 +174,6 @@ namespace Lucene.Net.Index } } @@ -44,7 +55,7 @@ diff -u -p -u -r1.3 SegmentReader.cs protected internal override void DoCommit() { if (deletedDocsDirty) -@@ -609,11 +596,9 @@ namespace Lucene.Net.Index +@@ -609,11 +598,9 @@ namespace Lucene.Net.Index /// private TermVectorsReader GetTermVectorsReader() { @@ -60,21 +71,23 @@ Index: Index/TermInfosReader.cs =================================================================== RCS file: /cvs/gnome/beagle/beagled/Lucene.Net/Index/TermInfosReader.cs,v retrieving revision 1.4 -diff -u -p -u -r1.4 TermInfosReader.cs +diff -u -p -r1.4 TermInfosReader.cs --- Index/TermInfosReader.cs 6 Oct 2005 19:29:55 -0000 1.4 -+++ Index/TermInfosReader.cs 15 Mar 2006 18:58:16 -0000 -@@ -28,8 +28,8 @@ namespace Lucene.Net.Index ++++ Index/TermInfosReader.cs 3 Apr 2006 17:09:07 -0000 +@@ -28,8 +28,10 @@ namespace Lucene.Net.Index private Directory directory; private System.String segment; private FieldInfos fieldInfos; - - private System.LocalDataStoreSlot enumerators = System.Threading.Thread.AllocateDataSlot(); + ++ [ThreadStatic] + private SegmentTermEnum termEnum; ++ private SegmentTermEnum origEnum; private long size; -@@ -50,20 +50,7 @@ namespace Lucene.Net.Index +@@ -50,20 +52,7 @@ namespace Lucene.Net.Index indexEnum = new SegmentTermEnum(directory.OpenInput(segment + ".tii"), fieldInfos, true); } @@ -96,7 +109,7 @@ diff -u -p -u -r1.4 TermInfosReader.cs public int GetSkipInterval() { return origEnum.skipInterval; -@@ -85,11 +72,9 @@ namespace Lucene.Net.Index +@@ -85,11 +74,9 @@ namespace Lucene.Net.Index private SegmentTermEnum GetEnum() { -- 2.11.4.GIT