Fossil SCM

Cache get_comment_format() result to avoid that the global config db is queried once per timeline row, which brings fossil to a standstill when ~/ is NFS-mounted. Discussion in [forum:9aaefe4e536e01bf].

drh 2022-10-18 16:55 trunk
Commit 6e62c8510fd61716190926595bd985042dfa4bd39a014fa8e3c414b6ab482059
1 file changed +10 -4
+10 -4
--- src/comformat.c
+++ src/comformat.c
@@ -513,25 +513,31 @@
513513
** 3. The global (all-repositories) "comment-format" setting.
514514
** 4. The default value COMMENT_PRINT_DEFAULT.
515515
*/
516516
int get_comment_format(){
517517
int comFmtFlags;
518
+
519
+ /* We must cache this result, else
520
+ ** running the timeline can end up querying the comment-format
521
+ ** setting from the global db once per timeline entry, which brings
522
+ ** it to a crawl if that db is network-mounted. Discussed in:
523
+ ** https://fossil-scm.org/forum/forumpost/9aaefe4e536e01bf */
524
+
518525
/* The global command-line option is present, or the value has been cached. */
519526
if( g.comFmtFlags!=COMMENT_PRINT_UNSET ){
520
- comFmtFlags = g.comFmtFlags;
521
- return comFmtFlags;
527
+ return g.comFmtFlags;
522528
}
523529
/* Load the local (per-repository) or global (all-repositories) value, and use
524530
** g.comFmtFlags as a cache. */
525531
comFmtFlags = db_get_int("comment-format", COMMENT_PRINT_UNSET);
526532
if( comFmtFlags!=COMMENT_PRINT_UNSET ){
527533
g.comFmtFlags = comFmtFlags;
528534
return comFmtFlags;
529535
}
530536
/* Fallback to the default value. */
531
- comFmtFlags = COMMENT_PRINT_DEFAULT;
532
- return comFmtFlags;
537
+ g.comFmtFlags = COMMENT_PRINT_DEFAULT;
538
+ return g.comFmtFlags;
533539
}
534540
535541
/*
536542
**
537543
** COMMAND: test-comment-format
538544
--- src/comformat.c
+++ src/comformat.c
@@ -513,25 +513,31 @@
513 ** 3. The global (all-repositories) "comment-format" setting.
514 ** 4. The default value COMMENT_PRINT_DEFAULT.
515 */
516 int get_comment_format(){
517 int comFmtFlags;
 
 
 
 
 
 
 
518 /* The global command-line option is present, or the value has been cached. */
519 if( g.comFmtFlags!=COMMENT_PRINT_UNSET ){
520 comFmtFlags = g.comFmtFlags;
521 return comFmtFlags;
522 }
523 /* Load the local (per-repository) or global (all-repositories) value, and use
524 ** g.comFmtFlags as a cache. */
525 comFmtFlags = db_get_int("comment-format", COMMENT_PRINT_UNSET);
526 if( comFmtFlags!=COMMENT_PRINT_UNSET ){
527 g.comFmtFlags = comFmtFlags;
528 return comFmtFlags;
529 }
530 /* Fallback to the default value. */
531 comFmtFlags = COMMENT_PRINT_DEFAULT;
532 return comFmtFlags;
533 }
534
535 /*
536 **
537 ** COMMAND: test-comment-format
538
--- src/comformat.c
+++ src/comformat.c
@@ -513,25 +513,31 @@
513 ** 3. The global (all-repositories) "comment-format" setting.
514 ** 4. The default value COMMENT_PRINT_DEFAULT.
515 */
516 int get_comment_format(){
517 int comFmtFlags;
518
519 /* We must cache this result, else
520 ** running the timeline can end up querying the comment-format
521 ** setting from the global db once per timeline entry, which brings
522 ** it to a crawl if that db is network-mounted. Discussed in:
523 ** https://fossil-scm.org/forum/forumpost/9aaefe4e536e01bf */
524
525 /* The global command-line option is present, or the value has been cached. */
526 if( g.comFmtFlags!=COMMENT_PRINT_UNSET ){
527 return g.comFmtFlags;
 
528 }
529 /* Load the local (per-repository) or global (all-repositories) value, and use
530 ** g.comFmtFlags as a cache. */
531 comFmtFlags = db_get_int("comment-format", COMMENT_PRINT_UNSET);
532 if( comFmtFlags!=COMMENT_PRINT_UNSET ){
533 g.comFmtFlags = comFmtFlags;
534 return comFmtFlags;
535 }
536 /* Fallback to the default value. */
537 g.comFmtFlags = COMMENT_PRINT_DEFAULT;
538 return g.comFmtFlags;
539 }
540
541 /*
542 **
543 ** COMMAND: test-comment-format
544

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button