Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/RevlogStream.java @ 264:6bb5e7ed051a
Optimize memory usage (reduce number of objects instantiated) when pooling file names and nodeids during manifest parsing
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 19 Aug 2011 03:36:25 +0200 |
parents | 31f67be94e71 |
children | 35125450c804 |
comparison
equal
deleted
inserted
replaced
263:31f67be94e71 | 264:6bb5e7ed051a |
---|---|
337 private DataAccess daIndex = null, daData = null; | 337 private DataAccess daIndex = null, daData = null; |
338 private Lifecycle.BasicCallback cb = null; | 338 private Lifecycle.BasicCallback cb = null; |
339 private int lastRevisionRead = BAD_REVISION; | 339 private int lastRevisionRead = BAD_REVISION; |
340 private DataAccess lastUserData; | 340 private DataAccess lastUserData; |
341 // next are to track two major bottlenecks - patch application and actual time spent in inspector | 341 // next are to track two major bottlenecks - patch application and actual time spent in inspector |
342 // private long applyTime, inspectorTime; | 342 // private long applyTime, inspectorTime; // TIMING |
343 | 343 |
344 | 344 |
345 public ReaderN1(boolean needData, Inspector insp) { | 345 public ReaderN1(boolean needData, Inspector insp) { |
346 assert insp != null; | 346 assert insp != null; |
347 this.needData = needData; | 347 this.needData = needData; |
355 } | 355 } |
356 if (inspector instanceof Lifecycle) { | 356 if (inspector instanceof Lifecycle) { |
357 cb = new Lifecycle.BasicCallback(); | 357 cb = new Lifecycle.BasicCallback(); |
358 ((Lifecycle) inspector).start(totalWork, cb, cb); | 358 ((Lifecycle) inspector).start(totalWork, cb, cb); |
359 } | 359 } |
360 // applyTime = inspectorTime = 0; | 360 // applyTime = inspectorTime = 0; // TIMING |
361 } | 361 } |
362 | 362 |
363 public void finish() { | 363 public void finish() { |
364 if (lastUserData != null) { | 364 if (lastUserData != null) { |
365 lastUserData.done(); | 365 lastUserData.done(); |
370 } | 370 } |
371 daIndex.done(); | 371 daIndex.done(); |
372 if (daData != null) { | 372 if (daData != null) { |
373 daData.done(); | 373 daData.done(); |
374 } | 374 } |
375 // System.out.printf("applyTime:%d ms, inspectorTime: %d ms\n", applyTime, inspectorTime); | 375 // System.out.printf("applyTime:%d ms, inspectorTime: %d ms\n", applyTime, inspectorTime); // TIMING |
376 } | 376 } |
377 | 377 |
378 public boolean range(int start, int end) throws IOException { | 378 public boolean range(int start, int end) throws IOException { |
379 byte[] nodeidBuf = new byte[20]; | 379 byte[] nodeidBuf = new byte[20]; |
380 int i; | 380 int i; |
466 // | 466 // |
467 // it shall be reset at the end of prev iteration, when it got assigned from userDataAccess | 467 // it shall be reset at the end of prev iteration, when it got assigned from userDataAccess |
468 // however, actual userDataAccess and lastUserData may share Inflater object, which needs to be reset | 468 // however, actual userDataAccess and lastUserData may share Inflater object, which needs to be reset |
469 // Alternatively, userDataAccess.done() above may be responsible to reset Inflater (if it's InflaterDataAccess) | 469 // Alternatively, userDataAccess.done() above may be responsible to reset Inflater (if it's InflaterDataAccess) |
470 lastUserData.reset(); | 470 lastUserData.reset(); |
471 // final long startMeasuring = System.currentTimeMillis(); | 471 // final long startMeasuring = System.currentTimeMillis(); // TIMING |
472 byte[] userData = apply(lastUserData, actualLen, patches); | 472 byte[] userData = apply(lastUserData, actualLen, patches); |
473 // applyTime += (System.currentTimeMillis() - startMeasuring); | 473 // applyTime += (System.currentTimeMillis() - startMeasuring); // TIMING |
474 patches.clear(); // do not keep any reference, allow PatchRecord to be gc'd | 474 patches.clear(); // do not keep any reference, allow PatchRecord to be gc'd |
475 userDataAccess = new ByteArrayDataAccess(userData); | 475 userDataAccess = new ByteArrayDataAccess(userData); |
476 } | 476 } |
477 } else { | 477 } else { |
478 if (inline) { | 478 if (inline) { |
479 daIndex.skip(compressedLen); | 479 daIndex.skip(compressedLen); |
480 } | 480 } |
481 } | 481 } |
482 if (!extraReadsToBaseRev || i >= start) { | 482 if (!extraReadsToBaseRev || i >= start) { |
483 // final long startMeasuring = System.currentTimeMillis(); | 483 // final long startMeasuring = System.currentTimeMillis(); // TIMING |
484 inspector.next(i, actualLen, baseRevision, linkRevision, parent1Revision, parent2Revision, nodeidBuf, userDataAccess); | 484 inspector.next(i, actualLen, baseRevision, linkRevision, parent1Revision, parent2Revision, nodeidBuf, userDataAccess); |
485 // inspectorTime += (System.currentTimeMillis() - startMeasuring); | 485 // inspectorTime += (System.currentTimeMillis() - startMeasuring); // TIMING |
486 } | 486 } |
487 if (cb != null) { | 487 if (cb != null) { |
488 if (cb.isStopped()) { | 488 if (cb.isStopped()) { |
489 return false; | 489 return false; |
490 } | 490 } |