Skip to content

Commit

Permalink
Reduce the overhead of Engine log statements.
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=187506205
  • Loading branch information
sjudd committed Mar 6, 2018
1 parent 5e45539 commit 7ff3bde
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class Engine implements EngineJobListener,
EngineResource.ResourceListener {
private static final String TAG = "Engine";
private static final int JOB_POOL_SIZE = 150;
private static final boolean VERBOSE_IS_LOGGABLE = Log.isLoggable(TAG, Log.VERBOSE);
private final Jobs jobs;
private final EngineKeyFactory keyFactory;
private final MemoryCache cache;
Expand Down Expand Up @@ -173,7 +174,7 @@ public <R> LoadStatus load(
EngineResource<?> active = loadFromActiveResources(key, isMemoryCacheable);
if (active != null) {
cb.onResourceReady(active, DataSource.MEMORY_CACHE);
if (Log.isLoggable(TAG, Log.VERBOSE)) {
if (VERBOSE_IS_LOGGABLE) {
logWithTimeAndKey("Loaded resource from active resources", startTime, key);
}
return null;
Expand All @@ -182,7 +183,7 @@ public <R> LoadStatus load(
EngineResource<?> cached = loadFromCache(key, isMemoryCacheable);
if (cached != null) {
cb.onResourceReady(cached, DataSource.MEMORY_CACHE);
if (Log.isLoggable(TAG, Log.VERBOSE)) {
if (VERBOSE_IS_LOGGABLE) {
logWithTimeAndKey("Loaded resource from cache", startTime, key);
}
return null;
Expand All @@ -191,7 +192,7 @@ public <R> LoadStatus load(
EngineJob<?> current = jobs.get(key, onlyRetrieveFromCache);
if (current != null) {
current.addCallback(cb);
if (Log.isLoggable(TAG, Log.VERBOSE)) {
if (VERBOSE_IS_LOGGABLE) {
logWithTimeAndKey("Added to existing load", startTime, key);
}
return new LoadStatus(cb, current);
Expand Down Expand Up @@ -229,7 +230,7 @@ public <R> LoadStatus load(
engineJob.addCallback(cb);
engineJob.start(decodeJob);

if (Log.isLoggable(TAG, Log.VERBOSE)) {
if (VERBOSE_IS_LOGGABLE) {
logWithTimeAndKey("Started new load", startTime, key);
}
return new LoadStatus(cb, engineJob);
Expand Down

2 comments on commit 7ff3bde

@PaulWoitaschek
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But what if you now change the property by the command line? If I understand correctly you have to kill the process then to see the changes.

@sjudd
Copy link
Collaborator Author

@sjudd sjudd commented on 7ff3bde Apr 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, if you want to change the value while the app is running, you'll need to restart the app. It's a system property so it's stored across subsequent app restarts.

Please sign in to comment.