Skip to content

Commit

Permalink
feat: Use rewritten LCTileScheduler
Browse files Browse the repository at this point in the history
Rewritten using java.util.concurrent.ThreadPoolExecutor instead of old ThreadGroup
  • Loading branch information
ktgw0316 committed Dec 16, 2023
1 parent d0ec0fe commit 120e92b
Show file tree
Hide file tree
Showing 2 changed files with 206 additions and 548 deletions.
17 changes: 8 additions & 9 deletions lightcrafts/src/main/java/com/lightcrafts/jai/JAIContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.lightcrafts.jai.utils.LCRecyclingTileFactory;
import com.lightcrafts.image.color.ColorScience;
import com.lightcrafts.image.color.ColorProfileInfo;
import com.lightcrafts.jai.utils.LCTileScheduler;
import com.lightcrafts.platform.Platform;
import com.sun.media.jai.util.SunTileCache;

Expand Down Expand Up @@ -173,18 +174,16 @@ static void zlum(ICC_ColorSpace cs) {

JAI jaiInstance = JAI.getDefaultInstance();

// Use our own Tile Scheduler -- TODO: Needs more testing
// jaiInstance.setTileScheduler(new LCTileScheduler());

final int processors = Runtime.getRuntime().availableProcessors();
System.out.println("Running on " + processors + " processors");

// Use multiple procs only if we have enough heap
final int parallelism = (maxMemory >= 400 * MB) ? processors : 1;
jaiInstance.getTileScheduler().setParallelism(parallelism);
jaiInstance.getTileScheduler().setPrefetchParallelism(parallelism);
jaiInstance.getTileScheduler().setPrefetchPriority(7);
jaiInstance.getTileScheduler().setPriority(7);
// Use multiple processors only if we have enough heap
final int parallelism = (maxMemory >= 400 * MB) ? processors - 1 : 1;
final int priority = 7;

// Use our own Tile Scheduler -- TODO: Needs more testing
final var tileScheduler = new LCTileScheduler(parallelism, priority);
jaiInstance.setTileScheduler(tileScheduler);

final long tileCacheMemory = (maxMemory <= 2048L * MB)
? maxMemory / 2
Expand Down
Loading

0 comments on commit 120e92b

Please sign in to comment.