Skip to content

Commit 89935a2

Browse files
author
Vladimir Kotal
committed
Merge pull request #784 from vladak/removed_tunable_flip
change the renamed file handling tunable to be false by default
2 parents a433d73 + a18ffe6 commit 89935a2

File tree

8 files changed

+36
-22
lines changed

8 files changed

+36
-22
lines changed

src/org/opensolaris/opengrok/configuration/RuntimeEnvironment.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public final class RuntimeEnvironment {
6464
private static RuntimeEnvironment instance = new RuntimeEnvironment();
6565
private static ExecutorService historyExecutor = null;
6666
private static ExecutorService historyRenamedExecutor = null;
67-
private static boolean RenamedEnabled = true;
68-
67+
private static boolean RenamedEnabled = false;
68+
6969
/* Get thread pool used for top-level repository history generation. */
7070
public static synchronized ExecutorService getHistoryExecutor() {
7171
if (historyExecutor == null) {
@@ -137,11 +137,11 @@ public static synchronized void destroyRenamedHistoryExecutor() throws Interrupt
137137
/*
138138
* Is handling of renamed files turned on ?
139139
*/
140-
public static boolean RenamedFilesEnabled() {
141-
String disabled =
142-
System.getProperty("org.opensolaris.opengrok.history.RenamedHandlingDisabled");
143-
if (disabled != null) {
144-
RenamedEnabled = false;
140+
public static boolean isRenamedFilesEnabled() {
141+
String enabled =
142+
System.getProperty("org.opensolaris.opengrok.history.RenamedHandlingEnabled");
143+
if (enabled != null) {
144+
RenamedEnabled = true;
145145
}
146146

147147
return (RenamedEnabled);

src/org/opensolaris/opengrok/history/FileHistoryCache.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ public void store(History history, Repository repository)
354354
final File root = RuntimeEnvironment.getInstance().getSourceRootFile();
355355
for (Map.Entry<String, List<HistoryEntry>> map_entry : map.entrySet()) {
356356
try {
357-
if (RuntimeEnvironment.RenamedFilesEnabled() &&
357+
if (RuntimeEnvironment.isRenamedFilesEnabled() &&
358358
isRenamedFile(map_entry, env, repository, history)) {
359359
continue;
360360
}
@@ -366,7 +366,7 @@ public void store(History history, Repository repository)
366366
doFileHistory(map_entry, env, repository, null, root, false);
367367
}
368368

369-
if (!RuntimeEnvironment.RenamedFilesEnabled()) {
369+
if (!RuntimeEnvironment.isRenamedFilesEnabled()) {
370370
return;
371371
}
372372

src/org/opensolaris/opengrok/history/JDBCHistoryCache.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ private History getHistory(
601601
ps.setString(2, filePath);
602602
} else {
603603
// Fetch history for a single file only.
604-
ps = conn.getStatement(env.RenamedFilesEnabled() && (getFilemovesCount() > 0) ?
604+
ps = conn.getStatement(RuntimeEnvironment.isRenamedFilesEnabled() && (getFilemovesCount() > 0) ?
605605
GET_FILE_HISTORY : GET_FILE_HISTORY_FOLDED);
606606
ps.setString(2, getParentPath(filePath));
607607
ps.setString(3, getBaseName(filePath));
@@ -828,7 +828,7 @@ private void storeHistory(final ConnectionResource conn, History history,
828828
String fullPath = toUnixPath(file);
829829
if (!history.isRenamed(
830830
file.substring(repodir.length() + 1)) ||
831-
!RuntimeEnvironment.RenamedFilesEnabled()) {
831+
!RuntimeEnvironment.isRenamedFilesEnabled()) {
832832
int fileId = files.get(fullPath);
833833
addFilechange.setInt(2, fileId);
834834
addFilechange.executeUpdate();
@@ -858,7 +858,7 @@ private void storeHistory(final ConnectionResource conn, History history,
858858
}
859859
}
860860

861-
if (!RuntimeEnvironment.RenamedFilesEnabled()) {
861+
if (!RuntimeEnvironment.isRenamedFilesEnabled()) {
862862
return;
863863
}
864864

src/org/opensolaris/opengrok/history/MercurialHistoryParser.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
22-
* Use is subject to license terms.
21+
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
2322
*/
2423
package org.opensolaris.opengrok.history;
2524

src/org/opensolaris/opengrok/history/MercurialRepository.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
2222
*/
2323
package org.opensolaris.opengrok.history;
2424

@@ -89,9 +89,12 @@ public class MercurialRepository extends Repository {
8989
+ FILE_LIST + END_OF_ENTRY + "\\n";
9090

9191
/** Template for formatting hg log output for directories. */
92-
private static final String DIR_TEMPLATE =
92+
private static final String DIR_TEMPLATE_RENAMED =
9393
TEMPLATE_STUB + FILE_LIST
9494
+ FILE_COPIES + "{file_copies}\\n" + END_OF_ENTRY + "\\n";
95+
private static final String DIR_TEMPLATE =
96+
TEMPLATE_STUB + FILE_LIST
97+
+ END_OF_ENTRY + "\\n";
9598

9699
/** Pattern used to extract author/revision from hg annotate. */
97100
private static final Pattern ANNOTATION_PATTERN =
@@ -151,9 +154,9 @@ Executor getHistoryLogExecutor(File file, String changeset)
151154

152155
cmd.add("--template");
153156
if (file.isDirectory()) {
154-
cmd.add(DIR_TEMPLATE);
157+
cmd.add(RuntimeEnvironment.isRenamedFilesEnabled() ? DIR_TEMPLATE_RENAMED : DIR_TEMPLATE);
155158
} else {
156-
/* JDBC requires to have complete list of files. */
159+
/* JDBC requires complete list of files. */
157160
cmd.add(env.storeHistoryCacheInDB() ? FILE_TEMPLATE_LIST : FILE_TEMPLATE);
158161
}
159162
if (!filename.isEmpty()) {

src/org/opensolaris/opengrok/index/Indexer.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
2222
*
2323
* Portions Copyright 2011 Jens Elkner.
2424
*/
@@ -99,7 +99,7 @@ private static void A_usage() {
9999
*/
100100
@SuppressWarnings("PMD.UseStringBufferForStringAppends")
101101
public static void main(String argv[]) {
102-
Statistics stats=new Statistics();//this won't count JVM creation though
102+
Statistics stats = new Statistics(); //this won't count JVM creation though
103103
boolean runIndex = true;
104104
boolean update = true;
105105
boolean optimizedChanged = false;
@@ -538,10 +538,16 @@ public static void main(String argv[]) {
538538
allowedSymlinks.addAll(cfg.getAllowedSymlinks());
539539
cfg.setAllowedSymlinks(allowedSymlinks);
540540

541-
//Set updated configuration in RuntimeEnvironment
541+
// Set updated configuration in RuntimeEnvironment.
542542
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
543543
env.setConfiguration(cfg);
544544

545+
// Issue a warning when JDBC is used with renamed file handling.
546+
// This causes heavy slowdown when used with JavaDB (issue #774).
547+
if (RuntimeEnvironment.isRenamedFilesEnabled() && cfg.isHistoryCacheInDB()) {
548+
System.out.println("History stored in DB and renamed file handling is on - possible performance degradation");
549+
}
550+
545551
getInstance().prepareIndexer(env, searchRepositories, addProjects,
546552
defaultProject, configFilename, refreshHistory,
547553
listFiles, createDict, subFiles, repositories,

test/org/opensolaris/opengrok/history/FileHistoryCacheTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ public class FileHistoryCacheTest extends TestCase {
5050

5151
cache = new FileHistoryCache();
5252
cache.initialize();
53+
54+
// The tests expect support for renamed files.
55+
System.setProperty("org.opensolaris.opengrok.history.RenamedHandlingEnabled", "1");
5356
}
5457

5558
/**

test/org/opensolaris/opengrok/history/JDBCHistoryCacheTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
2222
*/
2323

2424
package org.opensolaris.opengrok.history;
@@ -85,6 +85,9 @@ public static Test suite() {
8585

8686
// Mercurial parser needs to know if the history is stored in DB.
8787
RuntimeEnvironment.getInstance().setStoreHistoryCacheInDB(true);
88+
89+
// The tests expect support for renamed files.
90+
System.setProperty("org.opensolaris.opengrok.history.RenamedHandlingEnabled", "1");
8891
}
8992

9093
/**

0 commit comments

Comments
 (0)