-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Long iteration performance problem
PostPosted: Mon Aug 16, 2010 12:41 pm 
Newbie

Joined: Mon Aug 16, 2010 12:32 pm
Posts: 12
Hi,

I am trying to iterate over a big table about 2.5Gb and 4Mil records,

I am using multithreading too

The problem is that the application starts out very good at about 40Mb/sec and than slowly deteriorates to below 1Mb/sec in a almost linear fashion

I have tried almost everything and I can't fix this, please advise

The run method of a single thread, I am using from 2 - 10 threads same behavior and from 100 to 10000 objects per fetch (this works out diferently it's worse and better but never solves the problem)

Code:
public void run() {
   //   final SessionFactory sf = getSessionFactory();
   final Session session = getSession(true);
   final Transaction tx = session.getTransaction();
   //   sf.getStatistics().setStatisticsEnabled(false);

   int e = 0;
   int i = 0;
   try {
       tx.begin();

       final Query qry = session.createQuery("from Hit as hit");
       qry.setFlushMode(FlushMode.COMMIT);
       qry.setCacheMode(CacheMode.IGNORE);
       qry.setCacheable(false);
       qry.setMaxResults(maxResults);
       qry.setFirstResult(offset);

       final ScrollableResults sc = qry.scroll(ScrollMode.FORWARD_ONLY);
       while (sc.next()) {
      i++;
      final Hit h = (Hit) sc.get(0);
      final Set<Item> itms = h.getItems();
      final Set<String> uniqueTH = new TreeSet<String>();
      if (itms == null) {
          e++;
          continue;
      }

      for (final Item kwid : itms) {
          final Set<String> th = itemMap.get(kwid.getWebName());
          if (th != null) {
         for (final String thid : th) {
             uniqueTH.add(thid);
         }
          } else {
         e++;
         continue;
          }
      }
      for (final String name : uniqueTH) {
          final String itemId = themaIds.get(name);
          if (itemId == null) {
         logger.warn("No unique " + name);
          }

          if (itemId != null) {
         final String itemIdS = (String) itemId;
         h.setItem(itemIdS);
         if (!onlyTest)
             session.saveOrUpdate(h);
          } else {
         //             logger.warn("Id not found for '" + name + "'");
          }
      }
      session.evict(h);
       }
       tx.commit();
   } catch (final Exception ex) {
       if (tx != null) {
      tx.rollback();
       }
       logger.error(LoggerHelper.stackTraceToString(ex));
   } finally {
       app.decrement();
       if (session != null && session.isConnected()) {
      //      session.disconnect();
      releaseSession(session);
       }
   }
    }


Table

Code:
CREATE TABLE `hits` (
  `id` bigint(20) NOT NULL,
  `source` varchar(255) COLLATE utf8_bin NOT NULL,
  `BOOKNUMBER` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `BUSINESSNAME1` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `BUSINESSNAME2` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `BUSINESSNAME3` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `COUPONURL` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `CREATED` datetime DEFAULT NULL,
  `DISTRICT` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `ELECTRONICUSAGEALLOWED` bit(1) DEFAULT NULL,
  `EMAIL` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `EMAILDISPLAYED` bit(1) DEFAULT NULL,
  `EXTRAFIELD1` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `FAX` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `FIRSTNAME1` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `FIRSTNAME2` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `FIRSTNAME3` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `FULLBUSINESSNAMES` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `FULLLOCATION` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `FULLNAMES` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `GRAFIC` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `HIERARCHYROOTID` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `HIERARCHYSTEP` smallint(6) DEFAULT NULL,
  `HISTORICNAMEAFFIX1` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `HISTORICNAMEAFFIX2` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `HISTORICNAMEAFFIX3` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `HOMEPAGE` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `HOUSENUMBER` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `HOUSENUMBERAFFIX` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `INVERSESEARCHALLOWED` bit(1) DEFAULT NULL,
  `KEYWORD` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `KGS` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `LASTMODIFIED` datetime DEFAULT NULL,
  `LASTNAME1` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `LASTNAME2` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `LASTNAME3` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `LATITUDE` double DEFAULT NULL,
  `LOGO` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `LONGITUDE` double DEFAULT NULL,
  `MISCNAMEAFFIX1` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `MISCNAMEAFFIX2` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `MISCNAMEAFFIX3` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `MOBILE` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `TEL` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `PHONENUMBERDISPLAYED` bit(1) DEFAULT NULL,
  `POSTBOXNUMBER` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `POSTALCODE` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `RANKING` int(11) DEFAULT NULL,
  `SEQUENCENUMBER` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `SHOPURL` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `STATUS` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `STREET` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `SUBSCRIBERTYPE` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `SURENAMEPREFIX1` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `SURENAMEPREFIX2` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `SURENAMEPREFIX3` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `TEXT` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `TITLE1` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `TITLE2` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `TITLE3` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `TOWN` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `VANITYPUBLISHALLOWED` bit(1) DEFAULT NULL,
  `AREACODE` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `searchName` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  PRIMARY KEY (`id`,`source`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin$$



and

Code:
CREATE TABLE `hits_items` (
  `hits_id` bigint(20) NOT NULL,
  `hits_source` varchar(255) COLLATE utf8_bin NOT NULL,
  `items_id` bigint(20) NOT NULL,
  PRIMARY KEY (`hits_id`,`hits_source`,`items_id`),
  KEY `FK8B76BA01F7A53E26` (`hits_id`,`hits_source`),
  KEY `FK8B76BA01FEDAAECE` (`items_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin$$



and

Code:
CREATE TABLE `items` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `itemId` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `name` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `type` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `webName` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=10077 DEFAULT CHARSET=utf8 COLLATE=utf8_bin$$



Top
 Profile  
 
 Post subject: Re: Long iteration performance problem
PostPosted: Tue Aug 17, 2010 4:28 am 
Newbie

Joined: Mon Aug 16, 2010 12:32 pm
Posts: 12
I let it run through yesterday and here what happened

It ran for about 1.5h it did about 85%, than it stopped

Quote:
58:37,208 DEBUG (HitKeywordMatcher.java:103) [de.it2m.dpl.hitkeywordmacher.HitKeywordMatcher, match] - 1093
2010-08-16 22:58:37,208 DEBUG (HitKeywordMatcher.java:103) [de.it2m.dpl.hitkeywordmacher.HitKeywordMatcher, match] - 1092
2010-08-16 22:58:38,012 DEBUG (HitKeywordMatcher.java:103) [de.it2m.dpl.hitkeywordmacher.HitKeywordMatcher, match] - 1091
2010-08-16 22:58:39,027 DEBUG (HitKeywordMatcher.java:103) [de.it2m.dpl.hitkeywordmacher.HitKeywordMatcher, match] - 1090
2010-08-16 22:58:41,723 DEBUG (HitKeywordMatcher.java:103) [de.it2m.dpl.hitkeywordmacher.HitKeywordMatcher, match] - 1089
2010-08-16 22:58:41,724 DEBUG (HitKeywordMatcher.java:103) [de.it2m.dpl.hitkeywordmacher.HitKeywordMatcher, match] - 1088
2010-08-17 05:48:21,657 DEBUG (HitKeywordMatcher.java:103) [de.it2m.dpl.hitkeywordmacher.HitKeywordMatcher, match] - 1087

2010-08-17 05:49:49,838 DEBUG (HitKeywordMatcher.java:103) [de.it2m.dpl.hitkeywordmacher.HitKeywordMatcher, match] - 1086


Than after 8h it started again and finished in about 40mins the rest

It obviously is running out of a resource and than after the resource gets timeout or something it starts again, but what is it running out off?

It's not memory the memory I checked is good and no leaks, than what file locks, some internal mysql synchronization mechanism ? Any ideas ?

This resource timesout after exactly 8 hours


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.